Content Collections
Get started with Content Collections.
By default, TurboStarter uses Content Collections to store and retrieve content from the MDX files.
Content from there is used to populate data in the following places:
- Blog
- Legal pages
- Documentation
Why content-collections?
It is a great alternative to headless CMS like Contentful or Prismic based on MDX (a more powerful version of markdown). It is free, open source and the content is located right in your repository.
Of course, you can add more collections and views, as it's very flexible.
Defining new collection
To define a new collection, you need to create a new file in the packages/cms/src/collections
directory:
Then it's passed to the config in packages/cms/content-collections.ts
file which is used to generate types and parse content from MDX files.
When you run a development server, content collections will be automatically rebuilt (in .content-collections
directory) and you will be able to import the content and metadata of each file in your application.
It's fully type-safe!
By exporting the generated content you get fully type-safe API to interact with the content. We can have type safety on the data that we're receiving from the MDX files.
Using content collections
To get some content from @turbostarter/cms
package, you need to use the exposed API that we described in the Overview section:
Voila! You can now access the content from the MDX files.
Last updated on