Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Last active September 26, 2018 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xjamundx/8fa4c003f8b42ee823638e716281b7aa to your computer and use it in GitHub Desktop.
Save xjamundx/8fa4c003f8b42ee823638e716281b7aa to your computer and use it in GitHub Desktop.
gatsby properties source plugin
// i am expecting this to generate an allPropertiesFile thing in graphqil
// but it doesn't seem to be reflected in there at all
exports.sourceNodes = async ({ actions, createNodeId }) => {
const { createNode } = actions
// sample data will actually come from files.
const data = {
'myfolder/file2': { text: 'hi', buttonThing: 'hey' },
'myfolder/file1': { header: 'hi', footer: 'bye' },
}
// create 1 node per file???
Object.keys(data).forEach(key => {
let node = {
id: key,
internal: {
contentDigest: key,
type: 'PropertiesFile',
},
node: createNodeId(`properties-file-${key}`),
worked: false,
test: 123,
value: data[key],
}
createNode(node)
console.log('creating node', node)
})
// We're done, return.
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment