I'm working with my first Gatsby template (Hello Friend by Panr), and I have absolutely no experience with React.js.
I am trying to understand some of the logic of the template's design in gatsby-node.js
and gatsby-config.js
- specifically:
From gatsby-config.js
:
{
resolve: `gatsby-source-filesystem`,
options: {
name: `posts`,
path: `${__dirname}/src/posts`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/pages`,
},
},
And from gatsby-node.js
:
const sortedPages = markdownPages.sort((pageA, pageB) => {
const typeA = getType(pageA.node)
const typeB = getType(pageB.node)
return (typeA > typeB) - (typeA < typeB)
})
const posts = allNodes.filter(
({ internal, fileAbsolutePath }) =>
internal.type === 'MarkdownRemark' &&
fileAbsolutePath.indexOf('/posts/') !== -1,
)
// Create posts index with pagination
paginate({
createPage,
items: posts,
component: indexTemplate,
itemsPerPage: siteMetadata.postsPerPage,
pathPrefix: '/',
})
Am I following this correctly in thinking there are two content categories:
1.pages
2.posts
And the posts are enumerated (paginated) but the pages are not?
What does the sorting of pageA
and pageB
achieve?
Also, how would I go about adding additional content categories?
Note: I realize this is a vague question not well-suited for Stack Overflow. I would ask this question on a Gatsby-specific forum, but I do not believe one exists, and this is the forum recommended in the Gatsby community page.