Skip to content

Commit 1baeeed

Browse files
committed
now returns just posts that have the published: true tag
1 parent 594a55d commit 1baeeed

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

gatsby-src/gatsby-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
resolve: `gatsby-source-filesystem`,
1010
options: {
1111
name: `src`,
12-
path: `${__dirname}/src/`,
12+
path: `${__dirname}/src/content`,
1313
},
1414
},
1515
{

gatsby-src/src/pages/pandas-and-bananas.md renamed to gatsby-src/src/content/pandas-and-bananas.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Pandas and Bananas
33
date: "2017-08-21"
4+
publish: false
45
---
56

67
Do Pandas eat bananas? Check out this short video that shows that yes! pandas do

gatsby-src/src/pages/sweet-pandas.md renamed to gatsby-src/src/content/sweet-pandas.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "Sweet Pandas Eating Sweets"
33
date: "2017-08-10"
4+
publish: true
45
---
56

67
Pandas are really sweet.

gatsby-src/src/pages/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ export default ({ data }) => {
3535

3636
export const query = graphql`
3737
query IndexQuery {
38-
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
38+
allMarkdownRemark(
39+
sort: { fields: [frontmatter___date], order: DESC }
40+
filter: { frontmatter: { publish: { eq: true } } }
41+
) {
3942
totalCount
4043
edges {
4144
node {
4245
id
4346
frontmatter {
4447
title
4548
date(formatString: "DD MMMM, YYYY")
49+
publish
4650
}
4751
fields {
4852
slug

gatsby-src/src/templates/blog-post.js

+3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import React from "react";
22

33
export default ({ data }) => {
44
const post = data.markdownRemark;
5+
console.log(post);
56
return (
67
<div>
78
<h1>{post.frontmatter.title}</h1>
9+
<h3>Published: {post.frontmatter.publish}</h3>
810
<div dangerouslySetInnerHTML={{ __html: post.html }} />
911
</div>
1012
);
@@ -16,6 +18,7 @@ export const query = graphql`
1618
html
1719
frontmatter {
1820
title
21+
publish
1922
}
2023
}
2124
}

0 commit comments

Comments
 (0)