-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal to move path configuration to dedicated page (#540)
- Loading branch information
1 parent
dde276d
commit 412a577
Showing
5 changed files
with
101 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
title: Path configuration | ||
summary: Granular control over where Keystatic stores content. | ||
--- | ||
|
||
You can define *where* Keystatic should store collection entries and singletons via the `path` property in the collection/singleton top-level options. | ||
|
||
```javascript | ||
// Keystatic config | ||
export default config({ | ||
collections: { | ||
posts: collection({ | ||
label: 'Posts', | ||
path: 'content/posts/*/', | ||
// ... | ||
}) | ||
}, | ||
singletons: { | ||
settings: singleton({ | ||
label: 'Settings', | ||
path: 'content/posts/', | ||
// ... | ||
}) | ||
} | ||
}) | ||
|
||
``` | ||
|
||
The optional trailing slash `/` on that path has an impact on the content structure - read below for more details on `collection paths` and `singleton paths`. | ||
|
||
## Path wildcard for collections | ||
|
||
The `path` property for [collections](/docs/collections) must contain a `*` wildcard. | ||
|
||
It represents the `slug` of an entry. | ||
|
||
This wildcard gives you flexibility and control over your where your content is being output. | ||
|
||
## Nested folder output example | ||
|
||
{% aside icon="👉" %} | ||
`path: 'packages/design-system/*/docs/'` | ||
{% /aside %} | ||
|
||
Imagine a Design System inside a monorepo: | ||
|
||
```sh | ||
root | ||
├── packages | ||
├── design-system | ||
├── button | ||
└── src | ||
├── dropdown | ||
└── src | ||
└── apps | ||
└── docs(keystatic) | ||
``` | ||
|
||
Your Keystatic site lives in `apps/docs`, but you want your documentation entries in `packages/design-system/{component-name}/docs/`, to collocate them with each component. | ||
|
||
The following path will let you do exactly that: | ||
|
||
``` | ||
path: 'packages/design-system/*/docs/' | ||
``` | ||
|
||
## Nested slug example | ||
|
||
{% aside icon="👉" %} | ||
`path: 'content/posts/**'` | ||
{% /aside %} | ||
|
||
There may be situations where you need the `slug` of an entry to be following a multi-folder structure. | ||
|
||
Say you want the **same collection** to support this following tree structure: | ||
|
||
```sh | ||
content | ||
├── posts | ||
├── en | ||
└── post-1.mdoc | ||
├── fr | ||
└── post-1.mdoc | ||
``` | ||
|
||
You can enable this by using the `**` wildcard in your `path`: | ||
|
||
``` | ||
path: 'content/posts/**' | ||
``` | ||
|
||
Since Keystatic `slugs` can contain `/` characters, you construct a multi-folder structure with `slug` field values like: `en/post-1` and `fr/post-1`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
412a577
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystatic – ./dev-projects/next-app
keystatic-thinkmill-labs.vercel.app
keystatic.vercel.app
keystatic-git-main-thinkmill-labs.vercel.app
412a577
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystar-ui – ./design-system/docs
keystar-ui-thinkmill-labs.vercel.app
keystar-ui-git-main-thinkmill-labs.vercel.app
keystar-ui.vercel.app
voussoir.vercel.app
412a577
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
keystatic-site – ./docs
keystatic-site-git-main-thinkmill-labs.vercel.app
keystatic-site.vercel.app
keystatic-site-thinkmill-labs.vercel.app
keystatic.thinkmill.com
www.keystatic.com
keystatic.com
keystatic.thinkmill.com.au