Skip to content

Commit

Permalink
Fixed blog post sorting, added link to Starter Storm
Browse files Browse the repository at this point in the history
  • Loading branch information
crock committed Feb 18, 2020
1 parent 1ac35aa commit 019df97
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 27 deletions.
16 changes: 10 additions & 6 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage } = actions
const result = await graphql(`
{
allMarkdownRemark(
sort: { order: DESC, fields: [frontmatter___date] }
limit: 1000
) {
allMarkdownRemark(sort: {fields: frontmatter___date, order: DESC}, filter: {frontmatter: {type: {eq: "blog"}}}) {
edges {
node {
id
html
frontmatter {
categories
date
slug
title
}
}
}
Expand All @@ -28,12 +30,14 @@ exports.createPages = async ({ graphql, actions, reporter }) => {

const postTemplate = path.resolve(`./src/templates/post.js`)
_.each(result.data.allMarkdownRemark.edges, edge => {
const { frontmatter, html } = edge.node
createPage({
// will be the url for the page
path: `/blog/${edge.node.frontmatter.slug}`,
path: `/blog/${frontmatter.slug}`,
component: slash(postTemplate),
context: {
slug: edge.node.frontmatter.slug,
frontmatter,
html
},
})
})
Expand Down
5 changes: 4 additions & 1 deletion src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ const Header = ({ siteTitle, siteDesc }) => (
The Swamp
</Link>
{/* eslint-disable-next-line */}
<a href="https://domaincord.com" target="_blank">
<a href="https://domaincord.com" target="_blank" rel="noopener noreferrer">
Domaincord
</a>
<a href="https://starterstorm.com" target="_blank" rel="noopener noreferrer">
Starter Storm
</a>
</nav>
</div>
</header>
Expand Down
1 change: 1 addition & 0 deletions src/markdown-posts/post_2019-01-23.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
type: "blog"
slug: "the-future-of-social-media"
date: "2019-01-23"
title: "The Future of Social Media"
Expand Down
1 change: 1 addition & 0 deletions src/markdown-posts/post_2019-09-17.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
type: "blog"
slug: "how-to-find-the-best-lists-of-expiring-domains-for-dropcatching"
date: "2019-09-17"
title: "How to find the best lists of expiring domains for dropcatching"
Expand Down
1 change: 1 addition & 0 deletions src/markdown-posts/post_2020-02-01.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
type: "blog"
slug: "the-ultimate-discord-bot-command"
date: "2020-02-01"
title: "The Ultimate Discord Bot Command?"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ReadButton = styled(Link)`
const IndexPage = () => {
const data = useStaticQuery(graphql`
{
allMarkdownRemark {
allMarkdownRemark(sort: {fields: frontmatter___date, order: DESC}, filter: {frontmatter: {type: {eq: "blog"}}}) {
edges {
node {
id
Expand Down
21 changes: 2 additions & 19 deletions src/templates/post.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
import React from 'react'
import { graphql } from 'gatsby'
import BlogPost from '../components/blog-post'
import Layout from '../components/layout'

const PostTemplate = function Template({ data }) {
const { markdownRemark } = data

const PostTemplate = ({ pageContext }) => {
return (
<Layout fullWidth>
<BlogPost post={markdownRemark} />
<BlogPost post={pageContext} />
</Layout>
)
}

export const pageQuery = graphql`
query($slug: String!) {
markdownRemark(frontmatter: { slug: { eq: $slug } }) {
html
frontmatter {
categories
date(formatString: "MMMM DD, YYYY")
slug
title
}
}
}
`

export default PostTemplate

0 comments on commit 019df97

Please sign in to comment.