lavaldi / lavaldi.com

Personal website
http://lavaldi.com
Other
4 stars 4 forks source link

Filtered out Markdown files showing in article count #2

Closed lavaldi closed 4 years ago

lavaldi commented 4 years ago

Go to lavaldi.com/blog and try to search for "about" in the input.

No posts are showing, but the number of posts to the right says 1.

Why?

In addition to blog posts there are three markdown files in content/pages:

They are queried along with blog posts in this query:

https://github.com/lavaldi/lavaldi.github.com/blob/gatsby/src/pages/blog.js#L106-L131

They will never show up in the list of posts because posts that don't have the post template specified in frontmatter are filtered out client-side in the PostListing component:

https://github.com/lavaldi/lavaldi.github.com/blob/gatsby/src/components/PostListing.js#L11

But they are still counted in the number of filtered posts:

https://github.com/lavaldi/lavaldi.github.com/blob/gatsby/src/pages/blog.js#L59

Solution

Filter these out server-side with GraphQL. Then the client-side filtering in PostListing can even be removed.