From 1c779d2110a13de9572c8bcaf3e6b30f2d5582d8 Mon Sep 17 00:00:00 2001 From: neri Date: Wed, 19 Feb 2020 00:00:11 +0100 Subject: [PATCH] begin blog implementation --- blog/test-entry.md | 7 +++++++ gatsby-config.js | 7 +++++++ gatsby-node.js | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 blog/test-entry.md diff --git a/blog/test-entry.md b/blog/test-entry.md new file mode 100644 index 0000000..5d93558 --- /dev/null +++ b/blog/test-entry.md @@ -0,0 +1,7 @@ +--- +title: Test Entry +date: '1970-01-01T22:45:00-01:00' +description: 'testing the log posts' +--- + +# This is a test diff --git a/gatsby-config.js b/gatsby-config.js index 0564c1b..e8595cf 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -14,6 +14,13 @@ module.exports = { path: `${__dirname}/src/pages`, }, }, + { + resolve: `gatsby-source-filesystem`, + options: { + name: `blog`, + path: `${__dirname}/blog`, + }, + }, { resolve: `gatsby-plugin-mdx`, options: { diff --git a/gatsby-node.js b/gatsby-node.js index 919ce9b..d82229f 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -7,7 +7,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => { const result = await graphql(` { - allMdx(limit: 1000) { + allMdx(limit: 1000, filter: { fields: { source: { eq: "pages" } } }) { edges { node { frontmatter { @@ -36,11 +36,24 @@ exports.createPages = async ({ actions, graphql, reporter }) => { }) } +exports.onCreateNode = ({ node, getNode, actions }) => { + const { createNodeField } = actions + + if (node.internal.type === `Mdx`) { + const value = getNode(node.parent).sourceInstanceName + createNodeField({ + node, + name: `source`, + value, + }) + } +} + exports.createSchemaCustomization = ({ actions }) => { const { createTypes } = actions const typeDefs = ` type Mdx implements Node { - frontmatter: Frontmatter + frontmatter: Frontmatter } type Frontmatter {