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] Refactor and document APIs #1053

Merged
merged 23 commits into from
May 31, 2017
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b46a59b
Add basic version of new documentation.js transformer
KyleAMathews May 28, 2017
ab7ba98
Change api 'addFieldToNode' to 'createNodeField'
KyleAMathews May 29, 2017
45f7a31
Fix up node creation and add some simple tests
KyleAMathews May 30, 2017
1067771
Get basic docs page for action creators up
KyleAMathews May 30, 2017
0e39282
change deletePageByPath to just deletePage also sort action creators …
KyleAMathews May 30, 2017
d27833d
Change 'upsertPage' to 'createPage' and document it
KyleAMathews May 30, 2017
8a7575d
Only hide parent object description if its a desctructured object + i…
KyleAMathews May 30, 2017
61b79ff
Update action type
KyleAMathews May 30, 2017
776f77d
Support third level of parameters
KyleAMathews May 30, 2017
8863d25
Document createNode
KyleAMathews May 30, 2017
3697716
change 'addNodeToParent' to 'createParentChildLink' and document
KyleAMathews May 30, 2017
9e1c25a
Change 'addPageDependency' to 'createPageDependency' and document
KyleAMathews May 30, 2017
a8108ab
rename internal APIs
KyleAMathews May 30, 2017
5b0528b
Add links from function names at top to reference
KyleAMathews May 30, 2017
cba9b46
Ignore yarn.lock
KyleAMathews May 30, 2017
3ad7e09
Don't change the changelog...
KyleAMathews May 30, 2017
3c77aa3
Document and slightly modify node APIs
KyleAMathews May 31, 2017
6acd904
Factor out a FunctionsList component for rendering function docs
KyleAMathews May 31, 2017
6d536b3
Add browser/ssr docs and make a few tweaks to APIs
KyleAMathews May 31, 2017
62461fe
Add API specification document
KyleAMathews May 31, 2017
b5d634c
Actually add docs for node/browser/ssr
KyleAMathews May 31, 2017
e6600ab
Tweaks
KyleAMathews May 31, 2017
385bc78
Add README for gatsby-transformer-documentationjs
KyleAMathews May 31, 2017
File filter

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
Document createNode
  • Loading branch information
KyleAMathews committed May 30, 2017
commit 8863d255fcfd71b81b49fd483344a31ab9154c92
60 changes: 51 additions & 9 deletions packages/gatsby/src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ actions.deleteNode = (nodeId, plugin = ``) => {
}

/**
* Batch delete multiple nodes
* Batch delete nodes
* @param {array} nodes an array of node ids
* @example
* deleteNodes([`node1`, `node2`])
Expand All @@ -113,15 +113,57 @@ actions.deleteNodes = (nodes, plugin = ``) => {
}
}

actions.touchNode = (nodeId, plugin = ``) => {
return {
type: `TOUCH_NODE`,
plugin,
payload: nodeId,
}
}

const typeOwners = {}
/**
* Create a new node
* @param {object} node a node object
* @param {string} node.id The node's ID. Must be globally unique.
* @param {string} node.parent The ID of the parent's node. If the node is
* derived from another node, set that node as the parent. Otherwise it can
* just be an empty string.
* @param {array} node.children An array of children node IDs. If you're
* creating the children nodes while creating the parent node, add the
* children node IDs here directly. If you're adding a child node to a
* parent node created by a plugin, you can't mutate this value directly
* to add your node id, instead use the action creator `addNodeToParent`.
* @param {object} node.internal node fields that aren't generally
* interesting to consumers of node data but are very useful for plugin writers
* and Gatsby core.
* @param {string} node.internal.mediaType Either an official media type (we use
* mime-db as our source (https://www.npmjs.com/package/mime-db) or a made-up
* one if your data doesn't fit in any existing bucket. Transformer plugins
* frequently use node media types for deciding if they should transform a
* node into a new one. E.g. markdown transformers look for media types of
* text/x-markdown.
* @param {string} node.internal.type An arbitrary globally unique type
* choosen by the plugin creating the node. Should be descriptive of the
* node as the type is used in forming GraphQL types so users will query
* for nodes based on the type choosen here. Nodes of a given type can
* only be created by one plugin.
* @param {string} node.internal.content raw content of the node. Can be
* excluded if it'd be memory intensive to load in which case you must
* define a `loadNodeContent` function for this node.
* @param {string} node.internal.contentDigest the digest for the content
* of this node. Helps Gatsby avoid doing extra work on data that hasn't
* changed.
* @example
* createNode({
* // Data for the node.
* ...fieldData,
* id: `a-node-id`,
* parent: `the-id-of-the-parent-node`,
* children: [],
* internal: {
* mediaType: `text/x-markdown`,
* type: `CoolServiceMarkdownField`,
* content: JSON.stringify(fieldData),
* contentDigest: crypto
* .createHash(`md5`)
* .update(JSON.stringify(fieldData))
* .digest(`hex`),
* }
* })
*/
actions.createNode = (node, plugin) => {
if (!_.isObject(node)) {
return console.log(
Expand Down