per-page data fetching like Next.js getStaticProps for Gatsby #29622
Unanswered
nibtime
asked this question in
Ideas / Feature Requests
Replies: 1 comment 1 reply
-
What do you see this doing/solving differently than using source plugins and page queries? For example, each node can be localization-aware and you can use this as a filter: export const query = graphql`
query ($locale: String) {
myNode(locale: {eq: $locale}) {
id
title
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Last week I started writing my first Gatsby Theme. I want to include some nice patterns there that I learned from developing a multilingual website (7 languages) with Gatsby and MDX. Overall, this was a very pleasant experience, when it comes to meshing large content structures Gatsby is awesome and unbeatable. However, the thing I was missing most in this process was a proper solution for i18n content and pages with/and a per-page data fetching abstraction like Next.JS has with getStaticProps. Does anybody have similar requirements and is interested in a theme like this?
Goals
streamline the page generation process via templates for i18n content (with a primary focus on MDX, but in principle every source/transformer plugin that exposes content through GraphQL nodes should be supportable). Both multilingual and multiregional content should be well representable and well maintainable with a Git-based CMS like Forestry. Page paths should never depend on filenames and folder hierarchy and should be sourced entirely from the content.
create a getStaticProps-ish per-page data fetching abstraction that complements Gatsby's page queries and that is aware of the i18n page generation process. getStaticProps should re-fetch when data changes are triggered for a good developer experience.
support the CDN-level i18n-rewrites of Firebase Hosting
I couldn't find any existing plugins or themes that would provide all of those things. I know that there are i18n plugins available, but I think none of them quite hits the spot, at least not in a way like i18n routing of Next.JS 10 does (which is unsurprisingly intertwined with getStaticProps).
First impression
I am still in the PoC phase and exploring how this could be done best. I managed to get all of the above to work in the first iteration. Here are some GIFs and images to give a gist on how that all sort of looks like:
getStaticProps (language-aware data fetching from a weather API)
pulling region-specific MDX content fragments into a page via query (this is where Gatsby is great)
on Firebase Hosting with i18n rewrites
the page
localized MDX page content
template
file and folder organization
configuration interface
page specification
theme configuration
Beta Was this translation helpful? Give feedback.
All reactions