Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions content/blog/helloworld/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
path: "/{placeholder}/helloworld"
---

<h1>Test<h1>
Just a test!
10 changes: 9 additions & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,13 @@ module.exports = {
},
__key: "images",
},
{
resolve: "gatsby-source-filesystem",
options: {
path: `./content/blog`,
name: `blog`,
}
},
"gatsby-transformer-remark"
],
};
};
42 changes: 42 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const path = require("path")

// Implement the Gatsby API “createPages”. This is called once the
// data layer is bootstrapped to let plugins create pages from data.
exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage } = actions
// Query for markdown nodes to use in creating pages.
const result = await graphql(
`
{
allMarkdownRemark(limit: 1000) {
edges {
node {
frontmatter {
path
}
}
}
}
}
`
)
// Handle errors
if (result.errors) {
reporter.panicOnBuild(`Error while running GraphQL query.`)
return
}
// Create pages for each markdown file.
const blogPostTemplate = path.resolve(`src/templates/blog-post.js`)
result.data.allMarkdownRemark.edges.forEach(({ node }) => {
const path = node.frontmatter.path
createPage({
path,
component: blogPostTemplate,
// In your blog post template's graphql query, you can use pagePath
// as a GraphQL variable to query for data from the markdown file.
context: {
pagePath: path,
},
})
})
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"gatsby-plugin-sharp": "^3.14.1",
"gatsby-source-filesystem": "^3.14.0",
"gatsby-transformer-sharp": "^3.14.0",
"gatsby-transformer-remark": "^5.7.0",
"react": "^17.0.1",
"react-compare-slider": "^2.1.0",
"react-dom": "^17.0.1",
Expand All @@ -38,4 +39,4 @@
"postcss": "^8.3.9",
"tailwindcss": "^2.2.16"
}
}
}
29 changes: 19 additions & 10 deletions src/pages/blog.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import React from 'react';
import Layout from '../components/Layout';
import { graphql } from "gatsby"

const Blog = () => {
const BlogPost = () => {
return (
<div>

</div>
)
}
const Blog = ({ data, location }) => {
console.log(pageQuery)
return (
<Layout>
<div className='w-max'>
Expand All @@ -21,7 +17,20 @@ const Blog = () => {
</div>
</div>
</Layout>
)
}
)
}

export default Blog;

export default Blog;
export const pageQuery = graphql`
query MyQuery {
allMarkdownRemark {
nodes {
frontmatter {
path
title
}
}
}
}
`
Empty file added src/templates/blog-post.js
Empty file.
Loading