From c36d8288f7fbacf4b0b0f322f04a3b0fc19bae17 Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Tue, 7 Nov 2023 09:15:45 +1100 Subject: [PATCH] Update src/content/pages/using-in-a-monorepo Co-authored-by: Luke Bennett --- docs/src/content/navigation.yaml | 4 ++ .../content/pages/using-in-a-monorepo.mdoc | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 docs/src/content/pages/using-in-a-monorepo.mdoc diff --git a/docs/src/content/navigation.yaml b/docs/src/content/navigation.yaml index 0f27fd715..9886fe252 100644 --- a/docs/src/content/navigation.yaml +++ b/docs/src/content/navigation.yaml @@ -44,6 +44,10 @@ navGroups: link: discriminant: page value: cloud + - label: Using in a monorepo + link: + discriminant: page + value: using-in-a-monorepo - groupName: Recipes items: - label: 'Astro: Disable Admin UI Routes in Production' diff --git a/docs/src/content/pages/using-in-a-monorepo.mdoc b/docs/src/content/pages/using-in-a-monorepo.mdoc new file mode 100644 index 000000000..cf6eff074 --- /dev/null +++ b/docs/src/content/pages/using-in-a-monorepo.mdoc @@ -0,0 +1,41 @@ +--- +title: Using in a monorepo +--- +To use Keystatic in a monorepo there are just a few things you need to be aware of. + +## Schema path + +The `path` in your schema should be relative to the root of your app rather than the root of the repo. Your post collection should look like this: + +```diff +const posts = collection({ + label: 'Posts', + slugField: 'title', +- path: 'apps/docs/content/posts/*', ++ path: 'content/posts/*', + format: { data: 'json' }, + schema: { + title: fields.slug({ name: { label: 'Title' } }), + content: fields.document({ + label: 'Content', + }), + }, +}); +``` + +## Storage mode + +When using Keystatic in [GitHub](/docs/github-mode) or [Cloud](/docs/cloud) mode, you will need to specify the path prefix: + +```javascript +const storage: Config["storage"] = + process.env.NODE_ENV === "production" + ? { + kind: "github", + pathPrefix: "apps/docs", + repo: "thinkmill/keystatic", + } + : { + kind: "local", + }; +```