- pgSchema "mesh" with 4 tables isolating the peer mesh domain - Enums: visibility, transport, tier, role - audit_log is metadata-only (E2E encryption enforced at broker/client) - Cascade on mesh delete, soft-delete via archivedAt/revokedAt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.0 KiB
title, description, url
| title | description | url |
|---|---|---|
| Content Collections | Get started with Content Collections. | /docs/web/cms/content-collections |
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
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:
import { defineCollection } from "@content-collections/core";
export const legal = defineCollection({
name: "legal",
directory: "src/collections/legal/content",
include: "**/*.mdx",
schema: (z) => ({
title: z.string(),
description: z.string(),
}),
transform: async (doc, context) => {
const mdx = await transformMDX(doc, context);
return {
...mdx,
slug: doc._meta.directory,
locale: doc._meta.fileName.split(".")[0],
};
},
});
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.
import { defineConfig } from "@content-collections/core";
import { legal } from "./src/collections/legal";
export default defineConfig({
collections: [legal],
});
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.
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:
import { content } from "@turbostarter/cms";
export default async function Page({
params,
}: {
params: Promise<{ slug: string; locale: string }>;
}) {
const item = getContentItemBySlug({
collection: CollectionType.LEGAL,
slug: (await params).slug,
locale: (await params).locale,
});
return <h1>{title}</h1>;
}
Voila! You can now access the content from the MDX files.