Comments (8)
I handled this in statinamic by creating a collection.json in the webpack loader that consume md.
I also provide a simple helper to play with the collection.
from gatsby.
The page index json could be written out to file as a custom module. The createIndex
call could be rewritten by a babel plugin perhaps to be a require call to the custom module e.g. createIndex()
becomes require('indices/a12')
. If this sounds crazy and you're curious I'll clarify :)
from gatsby.
You might be interested in Query API for sitegen which does similar thing: https://sitegen.github.io/api
It doesn't implement chunked indices yet though so all metadata is always in the main chunk (which can be an overhead for super large sites > 1000 pages or something).
from gatsby.
👍 yeah, that's pretty much what I'm thinking for v1 of this. v2 where I'm writing out custom modules w/ metadata could be a later optimization.
from gatsby.
Also note that passing a function for sorting is not a great API for that purpose, I think, cause that function should be evaluated during build at webpack context (so it can sort and then chunk results).
The API should be static enough, for example using query string:
let index = createIndex('./posts/*.md?sort-by=published_date&chunk-by=50')
from gatsby.
Not 100% sure now this is needed. It's been simple enough to either filter/sort pages or to put index information in config files. Closing for now but if someone has strong thoughts on this, we can reopen it in the future.
from gatsby.
For people which are interested, statinamic will handle that and more by adding a way to generate pages based on some metadata filters (eg: pages per categories, year, tags etc)
from gatsby.
@MoOx a utility module for pagination (filter then sort then paginate) would be a nice project that could be shared across projects. It'd definitely be nice for Gatsby sites. I closed this issue as it's not something that'll be handled natively in core. Instead components will declare themselves as multi-page components as described in #33 (comment) and handle pagination there.
from gatsby.
Related Issues (20)
- function build error: Error: Module build failed: UnhandledSchemeError HOT 2
- Gatsby 5 is dead? HOT 1
- webpack and other js resources not found when using a subfolder of a static s3 website to serve public files
- Gatsby static site generation not fully prerendering HTML with loadable imports
- Gatsby minimal TS starter generates code with deprecated React import
- gatsby-transformer-remark doesn't accept "engines" plugin option for graymatter
- matchPath seems to be broken since adapters
- The first Headless CMS starter link is broken
- Gatsby + Directus = Build not working HOT 1
- Validation error
- Unexpected missing while creating page
- Invoking imported function inside `createPages` results in error HOT 1
- Gatsby 4 Upgrade - SyntaxError: Invalid left-hand side in assignment
- command curl -X POST http://localhost:8000/__refresh doesn't delete the documents from the CMS
- Serverless function in Gatsby site throwing error and not returning data locally
- Using webpack-dev-middleware results with npm audit high vulnerability
- Add a short how-to article for removing the 8px margin in html body
- Error using TypeScript package using workspace in gatsby-node.ts : ReferenceError: Cannot access 'D' before initialization
- React Peer Dependency Issue with gatsby-plugin-mdx HOT 3
- Gatsby performance/page-load issue on Mobile. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby.