Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// in gatsby-config.js
const path = require('path')
module.exports = {
siteMetadata: {
siteUrl: "https://sanjaypanda.com",
Expand Down Expand Up @@ -128,5 +129,11 @@ module.exports = {
},
`gatsby-plugin-sitemap`,
"gatsby-plugin-robots-txt",
{
resolve: `gatsby-plugin-mdx`,
options: {
defaultLayouts: { default: path.resolve('./src/components/layout-posts.js') },
},
},
],
}
33 changes: 18 additions & 15 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions

return new Promise((resolve, reject) => {
const comingSoonTemplate = path.resolve(`src/templates/ComingSoon.js`)
const comingSoonTemplate = path.resolve(`src/templates/ComingSoon.jsx`)
// Query for markdown nodes to use in creating pages.
resolve(
graphql(
Expand All @@ -28,14 +28,15 @@ exports.createPages = ({ graphql, actions }) => {
}
}
}
allMarkdownRemark {
allMdx {
edges {
node {
fields {
slug
}
frontmatter {
tags
tags,
title
}
}
}
Expand Down Expand Up @@ -66,27 +67,28 @@ exports.createPages = ({ graphql, actions }) => {
header: "MY WORKS",
},
})
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
createPage({
path: node.fields.slug,
component: path.resolve(`./src/templates/blog-post.jsx`),
context: {
slug: node.fields.slug,
},
})
result.data.allMdx.edges.forEach(({ node }) => {
// createPage({
// path: node.fields.slug,
// component: path.resolve(`./src/templates/blog-post.jsx`),
// context: {
// slug: node.fields.slug,
// },
// })

const pageName = node.fields.slug.split("/")[1]
createPage({
path: pageName,
component: path.resolve(`./src/templates/page-list-post.jsx`),
context: {
pageName,
regex: `/${pageName}\//gi`,
regex: /${pageName}/gi,
},
})

})

//Tages pages
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
result.data.allMdx.edges.forEach(({ node }) => {
(node.frontmatter.tags || "").split(",").forEach((tag) => {
const tagFinal = tag.trim().replace(/ /ig, "")
createPage({
Expand All @@ -106,7 +108,8 @@ exports.createPages = ({ graphql, actions }) => {

exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions
if (node.internal.type === `MarkdownRemark`) {

if (node.internal.type === `Mdx`) {
const slug = createFilePath({ node, getNode, basePath: `pages` })
createNodeField({
node,
Expand Down
Loading