Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0 #852

Closed
wants to merge 433 commits into from
Closed

1.0 #852

Changes from 1 commit
Commits
Show all changes
433 commits
Select commit Hold shift + click to select a range
bd2aa99
Merge branch '1.0' into unist-graphql
KyleAMathews Nov 21, 2016
ec7cd4e
Initial conversion to use Lerna
KyleAMathews Nov 21, 2016
eff1c21
Try Prata for header typeface (#563)
KyleAMathews Nov 28, 2016
509175e
Initial commit of multiple interlocking changes
KyleAMathews Dec 1, 2016
0a0b854
Add initial set of query operators to connections
KyleAMathews Dec 6, 2016
31aa2e4
Fix sorting for fields in sub-objects
KyleAMathews Dec 6, 2016
c4be0fb
Create connection field to pull out unique values for a field
KyleAMathews Dec 6, 2016
84b54c1
Don't flatten arrays for enum values
KyleAMathews Dec 6, 2016
12c8556
Ignore built tests
KyleAMathews Dec 6, 2016
749cde7
Use flatten to extract field examples
KyleAMathews Dec 6, 2016
a35d613
Bootstrap lerna before running tests
KyleAMathews Dec 6, 2016
8c700c2
Add groupBy field to connections
KyleAMathews Dec 7, 2016
0d54c31
Ignore compiled gatsby-node.js files
KyleAMathews Dec 9, 2016
a02705f
Copy referenced files/images from markdown files to public directory
KyleAMathews Dec 9, 2016
cb56344
Prototype way to create links between node types
KyleAMathews Dec 9, 2016
e0c7a4d
Restore correct .npmignores
KyleAMathews Dec 9, 2016
7683637
Add script for publishing canaries
KyleAMathews Dec 9, 2016
444221c
Just use relative links for files/images in markdown
KyleAMathews Dec 9, 2016
ef03495
Autogen GraphQL types from AST types
KyleAMathews Dec 27, 2016
89f2fc2
Update dependencies for gatsby-source-filesystem + gen hash for all f…
KyleAMathews Dec 27, 2016
77f70d8
Various markdown experiments — most likely to be moved to plugins
KyleAMathews Dec 27, 2016
8d5eba2
Define template file format as 'template-'
KyleAMathews Dec 27, 2016
60cf1d4
Make bootstrap more robust
KyleAMathews Dec 27, 2016
03dafb2
refactor
KyleAMathews Dec 27, 2016
df503d0
Throw error if site doesn't have html.js
KyleAMathews Dec 27, 2016
9d0ae6e
Temp way to load images in dev
KyleAMathews Dec 27, 2016
1e150d2
Update yarn.lock
KyleAMathews Dec 27, 2016
9f20185
Init support for image manipulation with Sharp
KyleAMathews Dec 27, 2016
1f41853
Extract out image processing to util package gatsby-sharp
KyleAMathews Dec 28, 2016
5653515
Always lowercase extensions (this is safe?)
KyleAMathews Dec 28, 2016
00fcfe9
Add start to new module which gens responsive images for markdown files
KyleAMathews Dec 28, 2016
e51dc4f
Add plugins to modify remark ast
KyleAMathews Dec 30, 2016
94e1fc3
Add support for async/await to default .babelrc
KyleAMathews Jan 2, 2017
245d29e
Just use root .babelrc
KyleAMathews Jan 2, 2017
c174c5c
Add functions/graphql fields to generate responsive sizes/resolutions…
KyleAMathews Jan 2, 2017
239ee38
Update dependencies
KyleAMathews Jan 2, 2017
4665124
Add .babelrc to gatsby so it can compile react
KyleAMathews Jan 2, 2017
0b9c105
Fix small errors
KyleAMathews Jan 2, 2017
a310916
Remove leftover code from 0.x
KyleAMathews Jan 3, 2017
2e7707b
Disable api-runner-browser until can refactor
KyleAMathews Jan 3, 2017
ef926ac
remove unused flow interfaces
KyleAMathews Jan 3, 2017
da03570
Debugging
KyleAMathews Jan 3, 2017
7265d52
Remove some testing code
KyleAMathews Jan 3, 2017
c0e2403
Better label
KyleAMathews Jan 3, 2017
703baa9
Typo fix
KyleAMathews Jan 3, 2017
901be86
Just treat the site's gatsby-x files as another plugin
KyleAMathews Jan 5, 2017
90ad60b
Find which plugins implement browser/ssr apis and write this out to I…
KyleAMathews Jan 5, 2017
cbd7931
Check if gatsby-node.js exists before requiring it
KyleAMathews Jan 5, 2017
c2d725f
Add initial version of graphql-skip-limit
KyleAMathews Jan 5, 2017
49b15be
Use 'quality' arg for jpeg&png and account for height arg
KyleAMathews Jan 11, 2017
3e009a3
Add classes to markdown responsive images
KyleAMathews Jan 11, 2017
3597013
Better method for creating excerpt for markdown bodies
KyleAMathews Jan 11, 2017
39786dc
Add two new ways to link fields to types
KyleAMathews Jan 11, 2017
3b6f655
Add gatsby-parser-yaml
KyleAMathews Jan 11, 2017
64d3ce7
Memoize base64 image creation
KyleAMathews Jan 11, 2017
4defb10
Warn if image width is smaller than what's requested
KyleAMathews Jan 11, 2017
ae38f2d
cleanups
KyleAMathews Jan 12, 2017
4351108
Add plugin for Glamor
KyleAMathews Jan 12, 2017
6e55685
Add new remark plugin to make iframe embeds responsive
KyleAMathews Jan 12, 2017
fdcf888
Add smartypants plugin for remark
KyleAMathews Jan 12, 2017
e61cadf
Enable a few more options for remark parsing, footnotes and pedantic
KyleAMathews Jan 12, 2017
c2f187c
Treat quality as the lower-bound for png
KyleAMathews Jan 12, 2017
4bc1452
Add support for remark plugins to modify src before parsing
KyleAMathews Jan 12, 2017
68e8f9a
Add initial version of a gatsby-link component which prefetches compo…
KyleAMathews Jan 12, 2017
4042fd0
Add missing index.js
KyleAMathews Jan 12, 2017
e814ddf
Small fixes
KyleAMathews Jan 12, 2017
24b9cc3
Remove noisy console.log
KyleAMathews Jan 13, 2017
a2bf086
Handle when no plugin modifies the babelrc
KyleAMathews Jan 13, 2017
696c2e3
On errors generating HTML, return before deleting the render-page.js
KyleAMathews Jan 13, 2017
930a4aa
Just copy gifs as Sharp can't process them
KyleAMathews Jan 13, 2017
bf7ce71
Add gatsby-plugin-google-analytics
KyleAMathews Jan 13, 2017
c061d10
Pass options to browser/ssr plugins
KyleAMathews Jan 13, 2017
69d037f
Bug fixes for google analytics/api-runner-browser
KyleAMathews Jan 13, 2017
5b0191b
Add gatsby-typegen-remark-autolink-headers
KyleAMathews Jan 18, 2017
3b0066c
Allow subplugins to use APIs in gatsby-*
KyleAMathews Jan 18, 2017
74cc553
Don't use express.static as can't filter out HTML files
KyleAMathews Jan 18, 2017
990d35b
Simplify image processing queue
KyleAMathews Jan 19, 2017
899d713
Add linkPrefix to links when activated
KyleAMathews Jan 19, 2017
a515c4c
Pass linkPrefix around and small changes
KyleAMathews Jan 19, 2017
ef5273b
Add publish-canary script
KyleAMathews Jan 19, 2017
7c86b91
Add missing dependency
KyleAMathews Jan 20, 2017
e3858f3
Up image processing concurency for slightly better CPU utilization
KyleAMathews Jan 20, 2017
268aa2c
Fix copy/paste error
KyleAMathews Jan 20, 2017
7c01ebf
Add README for google analytics plugin
KyleAMathews Jan 20, 2017
1085c13
Initial commit of GatsbyGram
KyleAMathews Jan 22, 2017
4e4f53f
Self-host our font
KyleAMathews Jan 24, 2017
18ab689
Move concurrency back to 1 — most files have multiple transforms
KyleAMathews Jan 24, 2017
eeea77f
Sometimes results can be false so only check for undefined
KyleAMathews Jan 24, 2017
ce276e7
Add API to override shouldUpdateScroll
KyleAMathews Jan 24, 2017
11a846c
Add args to date fields for fromNow and difference calculation
KyleAMathews Jan 24, 2017
f8f11d4
Send 404 errors for files in development
KyleAMathews Jan 24, 2017
2ceff12
Use all babylon parse plugins
KyleAMathews Jan 24, 2017
96d7a80
Add new gatsby-parser-json package
KyleAMathews Jan 24, 2017
79a528d
Include the glamor babel-hoist plugin
KyleAMathews Jan 24, 2017
3757e4a
Pass develop-html to plugins
KyleAMathews Jan 24, 2017
f19f649
Add gatsby-plugin-preact
KyleAMathews Jan 24, 2017
3539e8b
Attention strategy is apparently faster & better
KyleAMathews Jan 24, 2017
a5e523b
Didn't need to invert the aspect ratio
KyleAMathews Jan 24, 2017
9a073a0
Only return defaultReturn if it's set
KyleAMathews Jan 24, 2017
9e7a535
Reverse aspect ratio change
KyleAMathews Jan 24, 2017
6b60b3c
Support object embeds as well as iframe
KyleAMathews Jan 25, 2017
e7a5f8a
Better to err on under than over for size to reduce image size
KyleAMathews Jan 25, 2017
ee2cc7e
Make deciding to inline woff2 files an explicit decision
KyleAMathews Jan 25, 2017
5a808e5
Update website to latest Gatsby + update typography/colors
KyleAMathews Jan 27, 2017
c83a144
update website building instructions
KyleAMathews Jan 27, 2017
cd0228b
Bump desktop base size a bit so more readable
KyleAMathews Jan 28, 2017
18e3c08
Also disable ligatures on ios
KyleAMathews Jan 28, 2017
fabe233
srcset width has to use ints
KyleAMathews Feb 1, 2017
8ca6d25
Didn't end up using this package
KyleAMathews Feb 2, 2017
5efcfde
Raise the bar slightly for a module to be included in the commons chunk
KyleAMathews Feb 2, 2017
c249aef
Shrink body + header font sizes somewhat
KyleAMathews Feb 3, 2017
03bff6a
Make inline code use same styles as pre code blocks
KyleAMathews Feb 3, 2017
9711b0d
Border on inline code too much contrast
KyleAMathews Feb 3, 2017
f125dfb
offsetY not always set as an option
KyleAMathews Feb 4, 2017
dc621b0
Various updates to the gatsby website
KyleAMathews Feb 4, 2017
a764a59
Don't use node-glob for finding files, recursive-readdir is much much…
KyleAMathews Feb 4, 2017
6ffa976
Add or update package READMEs
KyleAMathews Feb 4, 2017
3f33af1
Update Gatsby packages
KyleAMathews Feb 4, 2017
68a54ff
Copy edit
KyleAMathews Feb 4, 2017
59fc20d
Copy edit
KyleAMathews Feb 4, 2017
2a26b5f
Copy edits
KyleAMathews Feb 4, 2017
900e94a
Pull out html-styles component into new package gatsby-inline-css
KyleAMathews Feb 6, 2017
f46304a
Rename gatsby-sharp to gatsby-plugin-sharp as it is a plugin
KyleAMathews Feb 6, 2017
e642a0e
Update gatsby website for latest canary
KyleAMathews Feb 6, 2017
3f3a1c0
Add gatsby-inline-css README
KyleAMathews Feb 6, 2017
3e77155
Update yarn.lock
KyleAMathews Feb 6, 2017
e083703
Set code block's language to jsx for React components
KyleAMathews Feb 6, 2017
3e34137
Set the path of the public directory in webpack for gatsby-inline-css
KyleAMathews Feb 6, 2017
62ce0be
update website to latest canary
KyleAMathews Feb 6, 2017
5b6024a
Use forked version of library for now
KyleAMathews Feb 6, 2017
a014b2d
Stop trying to use inlining css component for now
KyleAMathews Feb 6, 2017
c381d08
Remove failed experiment gatsby-inline-css
KyleAMathews Feb 6, 2017
c623e1c
Stop using exiftool as it's very slow compared to using native node.j…
KyleAMathews Feb 6, 2017
f047312
Update website
KyleAMathews Feb 6, 2017
8321a46
Use JSX for code block
KyleAMathews Feb 7, 2017
3ef6ba1
Merge branch '1.0' into unist-graphql
KyleAMathews Feb 7, 2017
419f75b
Merge pull request #662 from gatsbyjs/unist-graphql
KyleAMathews Feb 7, 2017
9400b8a
Prettier conversion (#664)
KyleAMathews Feb 7, 2017
b1e9a06
v1.0.0-alpha11
KyleAMathews Feb 7, 2017
ba3eba1
Add publish-next command
KyleAMathews Feb 7, 2017
c553e57
Merge branch '1.0' of github.com:gatsbyjs/gatsby into 1.0
KyleAMathews Feb 7, 2017
a0ef09f
Add theme color (#665)
KyleAMathews Feb 7, 2017
6c8e8f5
Copy edits
KyleAMathews Feb 7, 2017
215f626
Update GatsbyGram to Alpha11
KyleAMathews Feb 8, 2017
285c469
Restrict width of image post so last row w/ < 3 posts aren't large
KyleAMathews Feb 8, 2017
ebf51c4
Ensure the code language is lowercase
KyleAMathews Feb 8, 2017
d701670
Don't show hover state on mobile (if touched)
KyleAMathews Feb 8, 2017
eee2a95
Fix up header on small screens for GatsbyGram
KyleAMathews Feb 8, 2017
c54231e
Fix wildly updating posts count bug on mobile
KyleAMathews Feb 8, 2017
206e2de
Add script to build gatsbygram site on Netlify (#667)
KyleAMathews Feb 9, 2017
5079957
Add favicon, meta description, preload fonts
KyleAMathews Feb 9, 2017
49f7adc
Update README
KyleAMathews Feb 9, 2017
2663ade
Add Google Analytics to GatsbyGram
KyleAMathews Feb 9, 2017
6704345
Wait for the browser to finish rendering before scrolling
KyleAMathews Feb 10, 2017
91b8040
WIP: Website UI/IA updates (#672)
KyleAMathews Feb 14, 2017
d0ccb34
Run some code through Prettier 0.17
KyleAMathews Feb 14, 2017
bdc68bf
Always use gatsby-link
KyleAMathews Feb 17, 2017
45b3627
Add Offline and Manifest plugin (#687)
KyleAMathews Feb 22, 2017
8dc728b
v1.0.0-alpha12
KyleAMathews Feb 22, 2017
ae5ef29
Add READMEs for the offline & manifest plugins (#689)
KyleAMathews Feb 22, 2017
afb5c87
Copy Instagram and don't use camelcase
KyleAMathews Mar 1, 2017
36b8190
Small tweaks + add an about page (#701)
KyleAMathews Mar 3, 2017
553f76d
Add Gatsbygram case study and code for blog (#707)
KyleAMathews Mar 9, 2017
b5eda0f
Fix publish date
KyleAMathews Mar 9, 2017
9dec83e
Game time decision — don't add date to url
KyleAMathews Mar 9, 2017
62e846e
Update post with new webpagetest results + suggestions from Addy (#713)
KyleAMathews Mar 10, 2017
893fa98
Quick typo fix in README (#714)
tonyxiao Mar 11, 2017
00dd0e0
Correct sizes syntax 😅
KyleAMathews Mar 11, 2017
ccd42c2
Update glamor to v3 and inlined styles (#720)
KyleAMathews Mar 14, 2017
6b4dca2
Move headComponents higher
KyleAMathews Mar 14, 2017
4ba57c8
Move webpack manifest to after body but before loading other scripts
KyleAMathews Mar 14, 2017
793896c
Up sites to latest canary
KyleAMathews Mar 14, 2017
c9778da
Add prettier (#722)
KyleAMathews Mar 15, 2017
4af3700
User .babelrc files should be merged with defaults not override it
KyleAMathews Mar 15, 2017
b97941e
Up to latest canary
KyleAMathews Mar 15, 2017
afbe7b1
Correct smartphone model
KyleAMathews Mar 16, 2017
c005d79
Small changes to gatsbygram case study
KyleAMathews Mar 16, 2017
4124c5a
Use eslint-plugin-prettier instead of old messy airbnb based config
KyleAMathews Mar 16, 2017
dfc40de
Let users of gatsby-plugin-offline override default options
KyleAMathews Mar 17, 2017
b60aca4
Adds preferDefault helper to generated scripts (#725)
noahlange Mar 18, 2017
d86b873
Update snapshot + fix code error (#726)
KyleAMathews Mar 18, 2017
547467c
Check that path is relative as otherwise can't link to a file
KyleAMathews Mar 20, 2017
f88f64e
Fixing what looks like a copy-paste oversight. (#734)
Mar 20, 2017
3d7a5eb
Allow mapping from an array to another node type (#737)
KyleAMathews Mar 21, 2017
e4db6cb
1.0 fix windows scripts (#741)
fabien0102 Mar 21, 2017
41c5ce6
Adds support for arbitrary compile-to-JS languages (#732)
noahlange Mar 21, 2017
b61b05c
Allow remark headings to be queried by level (#738)
jamiebuilds Mar 21, 2017
508537e
Contributing Guide for 1.0 (#727)
Mar 21, 2017
b3dbfd2
Tweak contributing.md (#742)
KyleAMathews Mar 21, 2017
1b15986
Use minChunks callback function to ensure framework code in commons.j…
KyleAMathews Mar 21, 2017
9680770
Run lerna bootstrap on postinstall (#735)
jamiebuilds Mar 21, 2017
bc8d810
Remove yarn.lock from packages as they get out of date easily and not…
KyleAMathews Mar 21, 2017
5e425f6
Adds plugin support for CoffeeScript 2.x. (#745)
noahlange Mar 21, 2017
1b1c742
Remove yarn.lock
KyleAMathews Mar 21, 2017
b800590
Adds plugin support for TypeScript. (#747)
noahlange Mar 21, 2017
545e4a0
Merge branch '1.0' of github.com:gatsbyjs/gatsby into 1.0
KyleAMathews Mar 21, 2017
4f30010
Add two new plugins to list
KyleAMathews Mar 21, 2017
ca84c46
updates on how-to-contribute page (#751)
m4rrc0 Mar 23, 2017
92a8af8
eslint/prettier changes
KyleAMathews Mar 23, 2017
e1f27e4
Remove extra slash when adding a prefix
KyleAMathews Mar 23, 2017
90f8b08
selector isn't always set
KyleAMathews Mar 24, 2017
58c3990
Add guide for prefixing a site's paths (#753)
KyleAMathews Mar 24, 2017
fb347ff
[1.0] add support for 404 pages (#755)
KyleAMathews Mar 25, 2017
ca1e2da
Check if there's a 404 page before adding its route
KyleAMathews Mar 27, 2017
dbf1a59
Add gatsby dev cli (#758)
KyleAMathews Mar 27, 2017
bd3e428
Update dependencies for sites
KyleAMathews Mar 27, 2017
10141fd
Fix 404 fallback route for production
KyleAMathews Mar 27, 2017
20afce7
Update dependencies for sites
KyleAMathews Mar 27, 2017
ab76608
404 docs (#759)
KyleAMathews Mar 27, 2017
7ea9ebb
Update flow, remove dead code (#760)
KyleAMathews Mar 27, 2017
82ff66a
Fix gatsby dev (#761)
KyleAMathews Mar 28, 2017
80e93d6
Fix gatsby dev round #2 (#762)
KyleAMathews Mar 28, 2017
699f4ea
Specify that people need to install canary tag of gatsby-dev-cli (#763)
KyleAMathews Mar 28, 2017
351006c
Add trailing slash when creating script tags for prefixed sites
KyleAMathews Mar 28, 2017
5854cb7
[1.0] improve gatsby-dev-cli (#766)
fabien0102 Mar 29, 2017
1abb2b9
[1.0] Fix gatsby-dev-cli regex for windows (#767)
fabien0102 Mar 29, 2017
1cd25ea
[1.0] fix windows (#771)
fabien0102 Apr 3, 2017
f3143ec
Correct gatsby-plugin-glamor README (#774)
djm Apr 3, 2017
4899b20
Clarify relationship between css and default style prop
KyleAMathews Apr 3, 2017
dcde7f3
Copy edits + add link to style prop docs (#776)
KyleAMathews Apr 4, 2017
a034e91
[1.0] Fix windows paths (#781)
fabien0102 Apr 10, 2017
1fbc633
Use Yarn to install packages by default (#790)
donysukardi Apr 11, 2017
f186b91
[1.0] gatsbygram gravatar (#792)
fabien0102 Apr 11, 2017
4b15bd2
Use Redux for internal state plus add prototype for data hot reloadin…
KyleAMathews Apr 11, 2017
7b0bf37
Update gatsbygram case study for latest canaries (#793)
KyleAMathews Apr 12, 2017
af1aed8
Upgrade Prettier to 1.0 (#797)
KyleAMathews Apr 13, 2017
27acf64
Add a pre-commit hook to run prettier fixes #800 (#805)
KyleAMathews Apr 14, 2017
d26e24f
fix typo in error message
KyleAMathews Apr 15, 2017
1206e21
Update tests (#813)
KyleAMathews Apr 17, 2017
718e22a
[1.0] Change directory structure (#802)
fabien0102 Apr 18, 2017
c95be69
Don't set a root. Use normal node.js module resolution rules
KyleAMathews Apr 18, 2017
e7ad98d
[1.0] Refactor data layer (#818)
KyleAMathews Apr 19, 2017
2097bff
Update the readme for gatsby-dev-cli (#820)
0x80 Apr 19, 2017
9ffb1fa
[1.0] Fix duplicate node (#822)
fabien0102 Apr 19, 2017
814a03f
Update gatsby dev readme (#823)
KyleAMathews Apr 19, 2017
d54b34f
Fix id generation for JSON/YAML nodes + more tests (#824)
KyleAMathews Apr 19, 2017
7da5ef4
Update gatsby dev readme (#825) (#825)
0x80 Apr 19, 2017
b0ce38b
Link directly to the README page
KyleAMathews Apr 19, 2017
5d7bcdc
Allow use of babel options (#830)
0x80 Apr 20, 2017
0e9731b
Don't filter boolean values (#829)
fabien0102 Apr 20, 2017
f850a6c
[1.0 WIP Query runner refactor (#828)
KyleAMathews Apr 21, 2017
8b87236
Minor updates for Lerna (#834)
KyleAMathews Apr 21, 2017
777ca60
Small bug fixes (#835)
KyleAMathews Apr 21, 2017
8031a00
[1.0] revert change to lerna npm scripts, run still used for executin…
KyleAMathews Apr 22, 2017
ba62b14
[1.0] improve typescript config (#848)
fabien0102 Apr 24, 2017
3ca0478
Move remotedev server to npm script instead of always starting (#849)
KyleAMathews Apr 24, 2017
ed52c48
Only setup the integration with Redux devtools if dev sets env var (#…
KyleAMathews Apr 24, 2017
897a398
Update packages
KyleAMathews Apr 24, 2017
cf0fcba
v1.0.0-alpha13
KyleAMathews Apr 24, 2017
84b2c91
Update example sites to alpha13
KyleAMathews Apr 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Copy referenced files/images from markdown files to public directory
This in the future can be further refined e.g. resize images, add retina
versions, etc.
  • Loading branch information
KyleAMathews committed Dec 9, 2016
commit a02705fbf2092db0cd7951d7829791ccfd87ea9d
2 changes: 2 additions & 0 deletions packages/gatsby-typegen-remark/package.json
Original file line number Diff line number Diff line change
@@ -17,7 +17,9 @@
"dependencies": {
"excerpt-html": "^1.2.0",
"graphql": "^0.8.2",
"is-relative-url": "^2.0.0",
"lodash": "^4.17.2",
"parse-filepath": "^1.0.1",
"remark": "^6.2.0",
"remark-html": "^5.0.1",
"sanitize-html": "^1.13.0",
56 changes: 49 additions & 7 deletions packages/gatsby-typegen-remark/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -4,17 +4,17 @@ const {
GraphQLString,
GraphQLInt,
} = require(`graphql`)
const {
connectionFromArray,
connectionArgs,
connectionDefinitions,
} = require(`graphql-relay`)
const Remark = require(`remark`)
const remarkHtml = require(`remark-html`)
const excerptHTML = require(`excerpt-html`)
const select = require(`unist-util-select`)
const sanitizeHTML = require(`sanitize-html`)
const _ = require(`lodash`)
const path = require(`path`)
const fs = require(`fs`)
const fsExtra = require(`fs-extra`)
const isRelativeUrl = require(`is-relative-url`)
const parseFilepath = require(`parse-filepath`)

const { nodeInterface } = require(`../gatsby-graphql-utils`)

@@ -24,14 +24,56 @@ exports.registerGraphQLNodes = ({ args }) => {
const htmlCompiler = {}
remarkHtml(htmlCompiler)

const { ast } = args
const { ast, programDB } = args
const nodes = select(ast, `Markdown`)

const getAST = (markdownNode) => {
if (markdownNode.ast) {
return markdownNode
} else {
markdownNode.ast = remark.parse(markdownNode.src)
const markdownAST = remark.parse(markdownNode.src)

// Handle side effects — copy linked files & images to the public directory
// and modify the AST to point to new location of the files.
const links = select(markdownAST, `link`)
links.forEach((link) => {
if (isRelativeUrl(link.url) &&
parseFilepath(link.url).extname !== `` &&
link.url.slice(0, 6) !== `mailto` &&
link.url.slice(0, 4) !== `data`
) {
const linkPath = path.join(markdownNode.parent.dirname, link.url)
const linkNode = select(ast, `File[sourceFile=${linkPath}]`)[0]
if (linkNode.sourceFile) {
const newPath = path.join(programDB().directory, `public`, `${linkNode.hash}.${linkNode.extension}`)
const relativePath = path.join(`/${linkNode.hash}.${linkNode.extension}`)
link.url = `http://${programDB().host}:${programDB().port}${relativePath}`
if (!fs.existsSync(newPath)) {
fsExtra.copy(linkPath, newPath, (err) => {
if (err) { console.error(`error copying file`, err) }
})
}
}
}
})
const images = select(markdownAST, 'image')
if (images.length > 0) {
images.forEach((image) => {
const imagePath = path.join(markdownNode.parent.dirname, image.url)
const imageNode = select(ast, `File[sourceFile=${imagePath}]`)[0]
if (imageNode.sourceFile) {
const newPath = path.join(programDB().directory, `public`, `${imageNode.hash}.${imageNode.extension}`)
const relativePath = path.join(`/${imageNode.hash}.${imageNode.extension}`)
image.url = `http://${programDB().host}:${programDB().port}${relativePath}`
if (!fs.existsSync(newPath)) {
fsExtra.copy(linkPath, newPath, (err) => {
if (err) { console.error(`error copying file`, err) }
})
}
}
})
}
markdownNode.ast = markdownAST
return markdownNode
}
}
59 changes: 59 additions & 0 deletions packages/gatsby-typegen-remark/yarn.lock
Original file line number Diff line number Diff line change
@@ -1171,6 +1171,17 @@ invariant@^2.2.0:
dependencies:
loose-envify "^1.0.0"

is-absolute-url@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-2.0.0.tgz#9c4b20b0e5c0cbef9a479a367ede6f991679f359"

is-absolute@^0.2.3:
version "0.2.6"
resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-0.2.6.tgz#20de69f3db942ef2d87b9c2da36f172235b1b5eb"
dependencies:
is-relative "^0.2.1"
is-windows "^0.2.0"

is-alphabetical@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-alphabetical/-/is-alphabetical-1.0.0.tgz#e2544c13058255f2144cb757066cd3342a1c8c46"
@@ -1267,14 +1278,36 @@ is-property@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84"

is-relative-url@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-relative-url/-/is-relative-url-2.0.0.tgz#72902d7fe04b3d4792e7db15f9db84b7204c9cef"
dependencies:
is-absolute-url "^2.0.0"

is-relative@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-0.2.1.tgz#d27f4c7d516d175fb610db84bbeef23c3bc97aa5"
dependencies:
is-unc-path "^0.1.1"

is-typedarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"

is-unc-path@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-0.1.2.tgz#6ab053a72573c10250ff416a3814c35178af39b9"
dependencies:
unc-path-regex "^0.1.0"

is-whitespace-character@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-whitespace-character/-/is-whitespace-character-1.0.0.tgz#bbf4a83764ead0d451bec2a55218e91961adc275"

is-windows@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-0.2.0.tgz#de1aa6d63ea29dd248737b69f1ff8b8002d2108c"

is-word-character@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-word-character/-/is-word-character-1.0.0.tgz#a3a9e5ddad70c5c2ee36f4a9cfc9a53f44535247"
@@ -1409,6 +1442,10 @@ loose-envify@^1.0.0:
dependencies:
js-tokens "^2.0.0"

map-cache@^0.2.0:
version "0.2.2"
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"

markdown-escapes@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.0.tgz#c8ca19f1d94d682459e0a93c86db27a7ef716b23"
@@ -1630,6 +1667,14 @@ parse-entities@^1.0.2:
is-decimal "^1.0.0"
is-hexadecimal "^1.0.0"

parse-filepath@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.1.tgz#159d6155d43904d16c10ef698911da1e91969b73"
dependencies:
is-absolute "^0.2.3"
map-cache "^0.2.0"
path-root "^0.1.1"

parse-glob@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c"
@@ -1647,6 +1692,16 @@ path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"

path-root-regex@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d"

path-root@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/path-root/-/path-root-0.1.1.tgz#9a4a6814cac1c0cd73360a95f32083c8ea4745b7"
dependencies:
path-root-regex "^0.1.0"

pinkie-promise@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
@@ -2088,6 +2143,10 @@ uid-number@~0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"

unc-path-regex@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa"

unherit@^1.0.4:
version "1.1.0"
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.0.tgz#6b9aaedfbf73df1756ad9e316dd981885840cd7d"