Skip to content

Changes to build-in fields

Pre-release
Pre-release

Choose a tag to compare

@tonyketcham tonyketcham released this 25 Jun 23:07
· 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 latest tag, so all packages can be installed following the pattern of pnpm 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!

  • typeName has been renamed to collection in flatbread.config.js for the source-filesystem plugin
    • 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 -> _slug
    • filename -> _filename
    • path -> _path
    • content -> _content