This might be one for @angeloashmore
I have a repeatable Landing Page
custom type and I'd like to use it to generate my homepage. In order to do that, I can update:
- my linkResolver to
if (doc.type === 'landing_page') {
if (doc.uid === "homepage") {
return "/"
} else {
return `/${doc.uid.replace('__', '/')}/`;
}
}
-
Delete pages/index.js
-
Create the page within gatsby-node.js
However, I don't think that that public/index.html
will be generated (source no index.html file in public folder after building · Issue #21843 · gatsbyjs/gatsby · GitHub) which might cause problems when building the website.
Another approach is to copy the query of templates/landing.js into pages/index.js and hardcode the uid query to "homepage"
. I can then skip the creation of /homepage
in gatsby-node
However, this causes several problems:
- I can't preview the page due to how Prismic preview works
export const repositoryConfigs = [
{
repositoryName: process.env.GATSBY_PRISMIC_REPO_NAME,
linkResolver,
componentResolver: componentResolverFromMap({
landing_page: LandingPageTemplate,
}),
},
];
- I need to remember to keep pages/index.js and templates/landing.js query in sync
The final solution is to create a single type custom type called "Homepage" which is identical to my repeatable Landing Page custom type, but once again I need to keep both in sync.
Any help will be greatly appreciated!
PS: relevant stack-overflow ticket without a solid answer -> javascript - How can I set the index page of my Gatsby site to be one of the dynamically generated pages? - Stack Overflow