Changes to build-in fields
Pre-release
Pre-release
·
165 commits
to main
since this release
The bread's alive! Having a fun time champagne-testing this in Puerh.wtf's rewrite into SvelteKit x Flatbread 🥳
Feeling incredibly pleased with how freeing & robust Flatbread makes the experience of building a static site fueled by a relational, flat-file data source. I'm enjoying it much more than my experiences with doing the same in Gridsome and Gatsby, so hopefully that means we're onto something!
Now onto the juicy deets...
New features
- We're now releasing under the normal
latesttag, so all packages can be installed following the pattern ofpnpm i -D <package_name>without specifying a version. - A new built-in field is made available called
_collection. This field resolves to the collection name the returned elements belong to, which may not seem useful at the surface but can be powerful for advanced workflows where multiple collections are merged after querying, for example when building a file tree component.
⚠️ Breaking changes!
typeNamehas been renamed tocollectioninflatbread.config.jsfor thesource-filesystemplugin- Example of a valid Flatbread config file with this change:
import defineConfig from '@flatbread/config'; import transformer from '@flatbread/transformer-markdown'; import filesystem from '@flatbread/source-filesystem'; const transformerConfig = { markdown: { gfm: true, externalLinks: true, }, }; export default defineConfig({ source: filesystem(), transformer: transformer(transformerConfig), content: [ { path: 'content/markdown/posts', collection: 'Post', // this field used to be called `typeName` refs: { authors: 'Author', }, }, { path: 'content/markdown/authors', collection: 'Author', refs: { friend: 'Author', }, }, ], });
- Fields created by Flatbread have been prefixed with an underscore:
slug->_slugfilename->_filenamepath->_pathcontent->_content