@driftime/sanity-plugin-handbook 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -77
- package/dist/index.d.ts +203 -110
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2790 -2064
- package/dist/index.js.map +1 -1
- package/package.json +36 -34
- package/dist/index.cjs +0 -2094
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -143
- package/src/blocks/callout/block.tsx +0 -56
- package/src/blocks/callout/content.tsx +0 -41
- package/src/blocks/callout/preview.tsx +0 -15
- package/src/blocks/code/block.tsx +0 -18
- package/src/blocks/code/content.tsx +0 -18
- package/src/blocks/code/preview.tsx +0 -17
- package/src/blocks/horizontal-rule/block.tsx +0 -5
- package/src/blocks/horizontal-rule/content.tsx +0 -8
- package/src/blocks/horizontal-rule/preview.tsx +0 -5
- package/src/blocks/image/block.tsx +0 -23
- package/src/blocks/image/content.tsx +0 -31
- package/src/blocks/image/preview.tsx +0 -23
- package/src/blocks/video/block.tsx +0 -21
- package/src/blocks/video/content.tsx +0 -37
- package/src/blocks/video/preview.tsx +0 -21
- package/src/components/content-panel.tsx +0 -58
- package/src/components/decorators.tsx +0 -53
- package/src/components/document-types.tsx +0 -49
- package/src/components/field.tsx +0 -530
- package/src/components/guide-content.tsx +0 -117
- package/src/components/guides.tsx +0 -36
- package/src/components/pane-header.tsx +0 -26
- package/src/components/sidebar-group.tsx +0 -30
- package/src/components/sidebar-tab.tsx +0 -78
- package/src/contexts/handbook-context.tsx +0 -84
- package/src/getting-started/document-types.tsx +0 -104
- package/src/getting-started/how-to-use.tsx +0 -95
- package/src/getting-started/overview.tsx +0 -65
- package/src/hooks/use-container-width.ts +0 -41
- package/src/hooks/use-handbook-configuration.ts +0 -74
- package/src/hooks/use-is-handbook-editor.ts +0 -18
- package/src/icons/book-open-text.tsx +0 -22
- package/src/icons/book-text.tsx +0 -19
- package/src/icons/code.tsx +0 -18
- package/src/icons/image.tsx +0 -19
- package/src/icons/info.tsx +0 -19
- package/src/icons/layout-grid.tsx +0 -20
- package/src/icons/lightbulb.tsx +0 -19
- package/src/icons/list-plus.tsx +0 -21
- package/src/icons/message-circle-question-mark.tsx +0 -19
- package/src/icons/minus.tsx +0 -17
- package/src/icons/triangle-alert.tsx +0 -19
- package/src/icons/video.tsx +0 -18
- package/src/index.ts +0 -145
- package/src/layouts/content.tsx +0 -13
- package/src/layouts/sidebar.tsx +0 -15
- package/src/layouts/tool.tsx +0 -205
- package/src/lib/handbook-structure.ts +0 -47
- package/src/lib/icons.ts +0 -16
- package/src/lib/utils.ts +0 -69
- package/src/schemas/annotations/link.ts +0 -19
- package/src/schemas/blocks/callout.ts +0 -69
- package/src/schemas/blocks/code.ts +0 -46
- package/src/schemas/blocks/horizontal-rule.ts +0 -31
- package/src/schemas/blocks/image.ts +0 -40
- package/src/schemas/blocks/video.ts +0 -34
- package/src/schemas/guide-content.ts +0 -58
- package/src/schemas/types/guide.ts +0 -48
- package/src/schemas/types/handbook.ts +0 -86
- package/src/types.ts +0 -101
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
<br />
|
|
2
|
-
|
|
3
1
|
<div align="center">
|
|
4
2
|
<picture>
|
|
5
3
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/icon-dark.svg" />
|
|
6
|
-
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/icon.svg" />
|
|
7
|
-
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/icon.svg" alt="Handbook icon" width="48" />
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/icon-light.svg" />
|
|
5
|
+
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/icon-light.svg" alt="Handbook icon" width="48" />
|
|
8
6
|
</picture>
|
|
9
7
|
<h1>Handbook — A Sanity Plugin</h1>
|
|
10
8
|
<p>Schema-driven documentation and editorial guides, built right into Sanity Studio.</p>
|
|
@@ -14,15 +12,15 @@
|
|
|
14
12
|
|
|
15
13
|
## Overview
|
|
16
14
|
|
|
17
|
-
Handbook adds a dedicated tool to Sanity Studio that serves two purposes: it automatically generates browsable documentation from your document type schemas, and it provides a rich text guide authoring system for editorial teams. Field descriptions, examples, tips, and warnings are pulled directly from your schema definitions, so your documentation stays in sync with your content model.
|
|
15
|
+
Handbook adds a dedicated tool to Sanity Studio that serves two purposes: it automatically generates browsable documentation from your document type schemas, and it provides a rich text guide authoring system for editorial teams. Field descriptions, examples, tips, notes, and warnings are pulled directly from your schema definitions, so your documentation stays in sync with your content model.
|
|
18
16
|
|
|
19
17
|
<br />
|
|
20
18
|
|
|
21
19
|
<figure>
|
|
22
20
|
<picture>
|
|
23
21
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-fields-dark.png" />
|
|
24
|
-
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-fields.png" />
|
|
25
|
-
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-fields.png" alt="The Handbook tool displaying field documentation for a Pages document type, with field names, types, descriptions, and
|
|
22
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-fields-light.png" />
|
|
23
|
+
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-fields-light.png" alt="The Handbook tool displaying field documentation for a Pages document type, with field names, types, descriptions, example values, and an expanded subfields section" />
|
|
26
24
|
</picture>
|
|
27
25
|
<p align="center"><sub><em>Field documentation generated automatically from your schema definitions.</em></sub></p>
|
|
28
26
|
</figure>
|
|
@@ -31,13 +29,15 @@ Handbook adds a dedicated tool to Sanity Studio that serves two purposes: it aut
|
|
|
31
29
|
|
|
32
30
|
## Installation
|
|
33
31
|
|
|
32
|
+
Handbook is built for Sanity Studio 6 and React 19, and declares both as peer dependencies, so your Studio must already be on those versions. You'll need Node 22.12 or later.
|
|
33
|
+
|
|
34
34
|
```bash
|
|
35
35
|
bun add -E @driftime/sanity-plugin-handbook
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
## Basic Setup
|
|
39
39
|
|
|
40
|
-
Add the plugin to your Sanity configuration and pass in the document types you want to document. Each
|
|
40
|
+
Add the plugin to your Sanity configuration and pass in the document types you want to document, grouped by the role they play in your content model. Each role appears as a labelled section in the sidebar.
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
43
|
import { defineConfig } from "sanity";
|
|
@@ -48,17 +48,21 @@ export default defineConfig({
|
|
|
48
48
|
// ...
|
|
49
49
|
plugins: [
|
|
50
50
|
handbookPlugin({
|
|
51
|
-
|
|
51
|
+
roles: [
|
|
52
52
|
{
|
|
53
53
|
title: "Singletons",
|
|
54
|
-
description: "
|
|
55
|
-
documents: [home
|
|
54
|
+
description: "Document types that exist as a single instance.",
|
|
55
|
+
documents: [home],
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
title: "Collections",
|
|
59
|
-
description:
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
description: "Document types with multiple entries.",
|
|
60
|
+
documents: [page],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
title: "Globals",
|
|
64
|
+
description: "Document types shared across the site.",
|
|
65
|
+
documents: [navigation, templates, settings],
|
|
62
66
|
},
|
|
63
67
|
],
|
|
64
68
|
}),
|
|
@@ -66,48 +70,50 @@ export default defineConfig({
|
|
|
66
70
|
});
|
|
67
71
|
```
|
|
68
72
|
|
|
69
|
-
This registers a Handbook tool in the Studio navigation. Opening it
|
|
73
|
+
This registers a Handbook tool in the Studio navigation. Opening it shows a sidebar that starts with a built-in Getting Started section: a page on how to read the Handbook, and an overview of every role and its document types. Your own roles follow, one labelled section each. Selecting a document type shows its fields and their descriptions, with the `icon` from its schema. See [Configuration](#configuration) for all available options.
|
|
70
74
|
|
|
71
75
|
<br />
|
|
72
76
|
|
|
73
77
|
<figure>
|
|
74
78
|
<picture>
|
|
75
79
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-document-types-dark.png" />
|
|
76
|
-
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-document-types.png" />
|
|
77
|
-
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-document-types.png" alt="The Handbook tool showing
|
|
80
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-document-types-light.png" />
|
|
81
|
+
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-document-types-light.png" alt="The Handbook tool showing the Document Types overview, with Singletons, Collections, and Globals roles each listing their document types and descriptions" />
|
|
78
82
|
</picture>
|
|
79
|
-
<p align="center"><sub><em>Document types organised
|
|
83
|
+
<p align="center"><sub><em>Document types organised by role, browsable from the sidebar.</em></sub></p>
|
|
80
84
|
</figure>
|
|
81
85
|
|
|
82
86
|
<br />
|
|
83
87
|
|
|
84
88
|
## Handbook Metadata
|
|
85
89
|
|
|
86
|
-
The plugin augments Sanity's `FieldDefinitionBase` and `DocumentDefinition` interfaces, adding a `handbook` property that TypeScript recognises automatically.
|
|
90
|
+
The plugin augments Sanity's `FieldDefinitionBase` and `DocumentDefinition` interfaces, adding a `handbook` property that TypeScript recognises automatically.
|
|
87
91
|
|
|
88
92
|
```typescript
|
|
89
93
|
import { defineField, defineType } from "sanity";
|
|
90
94
|
|
|
91
95
|
export const pageType = defineType({
|
|
92
96
|
name: "page",
|
|
93
|
-
title: "Page",
|
|
94
97
|
type: "document",
|
|
98
|
+
title: "Pages",
|
|
99
|
+
description: "General-purpose pages.",
|
|
95
100
|
handbook: {
|
|
96
101
|
title: "Page",
|
|
97
|
-
description:
|
|
102
|
+
description:
|
|
103
|
+
"Standalone pages for anything that does not warrant a document type of its own. Each is reached at its own address and assembled from blocks rather than following a fixed layout.",
|
|
98
104
|
},
|
|
99
105
|
fields: [
|
|
100
106
|
defineField({
|
|
101
107
|
name: "title",
|
|
102
|
-
title: "Title",
|
|
103
108
|
type: "string",
|
|
104
|
-
description: "
|
|
109
|
+
description: "Appears in navigation, browser tabs, and search results.",
|
|
105
110
|
handbook: {
|
|
111
|
+
description:
|
|
112
|
+
"The name this page goes by wherever it is referred to rather than read — navigation menus, browser tabs, and search results. Every page needs one, and it stands behind the slug whenever that is left blank.",
|
|
106
113
|
example: "About Acme Inc.",
|
|
107
|
-
tip: "Keep
|
|
108
|
-
info: "The
|
|
109
|
-
caution:
|
|
110
|
-
"This field is required. Publishing without a title will cause the page to be excluded from navigation and search indexing.",
|
|
114
|
+
tip: "Keep it short enough to sit comfortably in a navigation menu, and put any fuller opening line in the heading instead.",
|
|
115
|
+
info: "The slug is generated from the title once, so renaming a page later leaves its address unchanged.",
|
|
116
|
+
caution: "Required. Publishing is blocked until it is filled in.",
|
|
111
117
|
},
|
|
112
118
|
}),
|
|
113
119
|
],
|
|
@@ -129,17 +135,17 @@ If no `handbook` property is provided, the tool falls back to the field's `title
|
|
|
129
135
|
|
|
130
136
|
### Subfield Browsing
|
|
131
137
|
|
|
132
|
-
Fields with nested structure display a collapsible section that editors can expand to explore subfields. Custom types extending built-in types like `image` or `file` show only the fields you add
|
|
138
|
+
Fields with nested structure display a collapsible section that editors can expand to explore subfields. Custom types extending built-in types like `image` or `file` show only the fields you add. Inherited fields are excluded automatically. Circular type references are detected and labelled rather than rendering infinitely.
|
|
133
139
|
|
|
134
140
|
## Guide Content
|
|
135
141
|
|
|
136
|
-
Handbook includes a guide authoring system powered by Portable Text. The plugin automatically registers a `handbook.handbook` singleton and a `handbook.guide` document type
|
|
142
|
+
Handbook includes a guide authoring system powered by Portable Text. The plugin automatically registers a `handbook.handbook` singleton and a `handbook.guide` document type. No additional schema setup is required.
|
|
137
143
|
|
|
138
|
-
The singleton defines the groups and ordering of your guides. Each group contains references to guide documents, which
|
|
144
|
+
The singleton defines the groups and ordering of your guides. Each group contains references to guide documents, which carry a title, an optional description shown beneath the heading, and a rich text body with built-in support for:
|
|
139
145
|
|
|
140
146
|
- Paragraph, heading, and blockquote styles
|
|
141
|
-
- Bold, italic, strikethrough, and inline code formatting
|
|
142
147
|
- Bullet and numbered lists
|
|
148
|
+
- Bold, italic, strikethrough, and inline code formatting
|
|
143
149
|
- Inline links
|
|
144
150
|
- Image blocks with caption and alternative text
|
|
145
151
|
- Video blocks with caption
|
|
@@ -153,9 +159,9 @@ The Handbook tool displays guides in the sidebar alongside your document types.
|
|
|
153
159
|
|
|
154
160
|
<figure>
|
|
155
161
|
<picture>
|
|
156
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
157
|
-
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
158
|
-
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
162
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-guide-dark.png" />
|
|
163
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-guide-light.png" />
|
|
164
|
+
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-guide-light.png" alt="A guide displayed in the Handbook tool with headings, paragraphs, a blockquote, a bullet list, a callout, and a captioned image" />
|
|
159
165
|
</picture>
|
|
160
166
|
<p align="center"><sub><em>Editorial guides authored with Portable Text and rendered directly in the tool.</em></sub></p>
|
|
161
167
|
</figure>
|
|
@@ -166,32 +172,34 @@ The Handbook tool displays guides in the sidebar alongside your document types.
|
|
|
166
172
|
|
|
167
173
|
Register custom Portable Text blocks for use in guide content by providing a schema definition and a React component. Custom blocks appear as insertion options in the guide content editor and are rendered using the provided component in the Handbook viewer.
|
|
168
174
|
|
|
169
|
-
```
|
|
175
|
+
```tsx
|
|
170
176
|
import { defineConfig, defineField, defineType } from "sanity";
|
|
177
|
+
import type { PortableTextObject } from "sanity";
|
|
171
178
|
import { handbookPlugin } from "@driftime/sanity-plugin-handbook";
|
|
172
179
|
// ...
|
|
173
180
|
|
|
174
181
|
const exampleSchema = defineType({
|
|
175
182
|
name: "handbook.example",
|
|
176
|
-
title: "Example",
|
|
177
183
|
type: "object",
|
|
184
|
+
title: "Example",
|
|
178
185
|
fields: [
|
|
179
186
|
defineField({
|
|
180
187
|
name: "label",
|
|
181
|
-
title: "Label",
|
|
182
188
|
type: "string",
|
|
189
|
+
description: "Text displayed inside the block.",
|
|
183
190
|
}),
|
|
184
191
|
],
|
|
185
192
|
});
|
|
186
193
|
|
|
187
194
|
function ExampleBlock({ value }: { value: PortableTextObject & { label?: string } }) {
|
|
188
|
-
return <
|
|
195
|
+
return <p>{value.label}</p>;
|
|
189
196
|
}
|
|
190
197
|
|
|
191
198
|
export default defineConfig({
|
|
192
199
|
// ...
|
|
193
200
|
plugins: [
|
|
194
201
|
handbookPlugin({
|
|
202
|
+
// ...
|
|
195
203
|
blocks: [
|
|
196
204
|
{
|
|
197
205
|
schema: exampleSchema,
|
|
@@ -205,67 +213,81 @@ export default defineConfig({
|
|
|
205
213
|
|
|
206
214
|
## Editor Permissions
|
|
207
215
|
|
|
208
|
-
Restrict who can create and edit
|
|
216
|
+
Restrict who can create and edit Handbook documents by providing a list of email addresses.
|
|
209
217
|
|
|
210
218
|
```typescript
|
|
211
219
|
handbookPlugin({
|
|
212
|
-
|
|
220
|
+
// ...
|
|
221
|
+
editors: ["admin@acme.com", "editor@acme.com"],
|
|
213
222
|
});
|
|
214
223
|
```
|
|
215
224
|
|
|
216
|
-
When an editors list is provided, only users whose email appears in the list can create or manage
|
|
225
|
+
When an editors list is provided, only users whose email appears in the list can create or manage Handbook documents. Users not in the list are excluded entirely. If no editors list is provided, all users have full access.
|
|
217
226
|
|
|
218
|
-
|
|
227
|
+
Independently of that list, the Handbook singleton is locked for everyone: it never appears in the create-new menu, and its delete, duplicate, and unpublish actions are removed. Anyone the list permits can still create guides.
|
|
228
|
+
|
|
229
|
+
The `useIsHandbookEditor` hook is exported for use in your own components if you need to conditionally render UI based on editor permissions. It reads the `editors` you gave the plugin, and takes a list as an optional argument to override that.
|
|
219
230
|
|
|
220
231
|
```typescript
|
|
221
232
|
import { useIsHandbookEditor } from "@driftime/sanity-plugin-handbook";
|
|
222
233
|
|
|
223
|
-
const isEditor = useIsHandbookEditor(
|
|
234
|
+
const isEditor = useIsHandbookEditor();
|
|
224
235
|
```
|
|
225
236
|
|
|
226
237
|
## Structure Integration
|
|
227
238
|
|
|
228
|
-
|
|
239
|
+
The Handbook tool displays guides, but you author them in the Structure tool. Nothing appears there until you add it. Use the `handbookStructure` helper to add a Handbook singleton editor and a Handbook Guides list, both restricted to the same editors you gave the plugin.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { handbookStructure } from "@driftime/sanity-plugin-handbook";
|
|
243
|
+
import type { StructureResolver } from "sanity/structure";
|
|
244
|
+
|
|
245
|
+
export const structure: StructureResolver = (structureBuilder, context) => {
|
|
246
|
+
const { list, documentTypeListItems, divider } = structureBuilder;
|
|
247
|
+
|
|
248
|
+
const handbookItems = handbookStructure(structureBuilder, context);
|
|
249
|
+
|
|
250
|
+
return list()
|
|
251
|
+
.title("Content")
|
|
252
|
+
.items([
|
|
253
|
+
...documentTypeListItems().filter(
|
|
254
|
+
(item) => !["handbook.handbook", "handbook.guide"].includes(item.getId() ?? ""),
|
|
255
|
+
),
|
|
256
|
+
...(handbookItems.length > 0 ? [divider(), ...handbookItems] : []),
|
|
257
|
+
]);
|
|
258
|
+
};
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The helper needs two things from your structure. It reads the current user from the resolver's second argument, so accept both parameters even if the rest of your structure only needs the builder. It also returns an empty array for users outside the editors list, so only add the divider when there are items. Otherwise those users see a divider with nothing under it.
|
|
262
|
+
|
|
263
|
+
The helper reads the `editors` you gave the plugin, so you don't declare them twice. Pass a list as the optional third argument to override that, which you need if your Studio runs several workspaces with different editors.
|
|
264
|
+
|
|
265
|
+
The filter is only needed where a structure draws on `documentTypeListItems()`, which lists every registered type and so includes the two the plugin adds. A structure built from your own document definitions won't include them, so you can drop the filter.
|
|
266
|
+
|
|
267
|
+
The Handbook singleton is where you define guide groups and their ordering. Each group contains references to individual guide documents that editors can reorder as needed.
|
|
229
268
|
|
|
230
269
|
<br />
|
|
231
270
|
|
|
232
271
|
<figure>
|
|
233
272
|
<picture>
|
|
234
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
235
|
-
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
236
|
-
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
273
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-groups-dark.png" />
|
|
274
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-groups-light.png" />
|
|
275
|
+
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-groups-light.png" alt="The Handbook singleton editor in the Structure tool, showing reorderable groups each containing guide references" />
|
|
237
276
|
</picture>
|
|
238
277
|
<p align="center"><sub><em>The Handbook singleton where groups and their ordering are managed.</em></sub></p>
|
|
239
278
|
</figure>
|
|
240
279
|
|
|
241
280
|
<br />
|
|
242
281
|
|
|
243
|
-
|
|
244
|
-
import { handbookStructure } from "@driftime/sanity-plugin-handbook";
|
|
245
|
-
|
|
246
|
-
export const structure = (structureBuilder, context) => {
|
|
247
|
-
return structureBuilder
|
|
248
|
-
.list()
|
|
249
|
-
.title("Content")
|
|
250
|
-
.items([
|
|
251
|
-
...structureBuilder
|
|
252
|
-
.documentTypeListItems()
|
|
253
|
-
.filter((item) => !["handbook.handbook", "handbook.guide"].includes(item.getId() ?? "")),
|
|
254
|
-
structureBuilder.divider(),
|
|
255
|
-
...handbookStructure(structureBuilder, context),
|
|
256
|
-
]);
|
|
257
|
-
};
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
Individual guides are authored as `handbook.guide` documents, which can be created and edited directly from the Structure tool.
|
|
282
|
+
Individual guides are authored as `handbook.guide` documents, which can be created and edited directly from the Structure tool using the built-in Portable Text editor.
|
|
261
283
|
|
|
262
284
|
<br />
|
|
263
285
|
|
|
264
286
|
<figure>
|
|
265
287
|
<picture>
|
|
266
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
267
|
-
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
268
|
-
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-
|
|
288
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-editor-dark.png" />
|
|
289
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-editor-light.png" />
|
|
290
|
+
<img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/handbook-editor-light.png" alt="The Handbook Guides list in the Structure tool with a guide open beside it, showing its title, description, and Portable Text content editor" />
|
|
269
291
|
</picture>
|
|
270
292
|
<p align="center"><sub><em>Handbook Guides listed in the Structure tool for authoring and editing.</em></sub></p>
|
|
271
293
|
</figure>
|
|
@@ -274,16 +296,47 @@ Individual guides are authored as `handbook.guide` documents, which can be creat
|
|
|
274
296
|
|
|
275
297
|
## Configuration
|
|
276
298
|
|
|
277
|
-
|
|
299
|
+
Only `roles` is required, since it tells the plugin which document types to cover. Everything else falls back to a sensible default.
|
|
300
|
+
|
|
301
|
+
| Option | Type | Default | Purpose |
|
|
302
|
+
| -------------------------- | --------------------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
303
|
+
| `title` | `string` | `"Handbook"` | Title shown in the Studio tool navigation. |
|
|
304
|
+
| `sidebarTitle` | `string` | `"Handbook"` | Heading displayed at the top of the sidebar. |
|
|
305
|
+
| `roles` | `SanityHandbookDocumentRole[]` | — (required) | Document roles, each shown as a labelled section in the sidebar. |
|
|
306
|
+
| `blocks` | `SanityHandbookBlockDefinition[]` | `[]` | Custom Portable Text block definitions for guide content. |
|
|
307
|
+
| `editors` | `string[]` | `undefined` | Email addresses permitted to edit Handbook documents. Unrestricted when omitted. |
|
|
308
|
+
| `undocumentedFieldMessage` | `string` | `"This field has not been documented yet. Contact your development team for guidance."` | Fallback message shown when a field has no description. |
|
|
309
|
+
|
|
310
|
+
## Exported Types
|
|
311
|
+
|
|
312
|
+
These types are exported for typing your own configuration and for querying Handbook content outside the Studio.
|
|
313
|
+
|
|
314
|
+
Configuration you supply:
|
|
315
|
+
|
|
316
|
+
| Type | Purpose |
|
|
317
|
+
| ------------------------------- | --------------------------------------------------------------------------- |
|
|
318
|
+
| `SanityHandbookMetadata` | The `handbook` property added to field and document definitions. |
|
|
319
|
+
| `SanityHandbookDocumentRole` | A named role, holding the document types that fill it. |
|
|
320
|
+
| `SanityHandbookBlockDefinition` | A custom Portable Text block, pairing a schema definition with a component. |
|
|
321
|
+
| `SanityHandbookConfig` | The full plugin configuration accepted by `handbookPlugin`. |
|
|
322
|
+
|
|
323
|
+
Content the dataset stores:
|
|
324
|
+
|
|
325
|
+
| Type | Purpose |
|
|
326
|
+
| ------------------------------ | ------------------------------------------------------------------------- |
|
|
327
|
+
| `SanityHandbook` | The Handbook singleton document, defining the groups and their ordering. |
|
|
328
|
+
| `SanityHandbookGuideGroup` | A group within the Handbook singleton, holding an ordered list of guides. |
|
|
329
|
+
| `SanityHandbookGuide` | A guide document, with its title, description, and Portable Text content. |
|
|
330
|
+
| `SanityHandbookCallout` | A callout block, with its variant and Portable Text body. |
|
|
331
|
+
| `SanityHandbookCode` | A code block, with its source and language. |
|
|
332
|
+
| `SanityHandbookHorizontalRule` | A horizontal rule block. |
|
|
333
|
+
| `SanityHandbookImage` | An image block, with its asset, caption, and alternative text. |
|
|
334
|
+
| `SanityHandbookVideo` | A video block, with its asset and caption. |
|
|
335
|
+
| `SanityHandbookLink` | A link annotation, with the web address it points to. |
|
|
336
|
+
|
|
337
|
+
## Acknowledgements
|
|
278
338
|
|
|
279
|
-
|
|
280
|
-
| -------------------------- | --------------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
281
|
-
| `title` | `string` | `"Handbook"` | Title shown in the Studio tool navigation. |
|
|
282
|
-
| `sidebarTitle` | `string` | `"Handbook"` | Heading displayed at the top of the sidebar. |
|
|
283
|
-
| `groups` | `HandbookStructureGroup[]` | `[]` | Document type groups defining the sidebar hierarchy. |
|
|
284
|
-
| `blocks` | `HandbookBlockDefinition[]` | `[]` | Custom Portable Text block definitions for guide content. |
|
|
285
|
-
| `editors` | `string[]` | `undefined` | Email addresses permitted to edit handbook documents. Unrestricted when omitted. |
|
|
286
|
-
| `undocumentedFieldMessage` | `string` | `"This field has not been documented yet. Contact your development team for guidance."` | Fallback message shown when a field has no description. |
|
|
339
|
+
The icons in `src/icons` are derived from [Lucide](https://lucide.dev) and redrawn as standalone components, so the plugin ships its own icons without depending on the Lucide package. Icons for controls the Studio already draws, such as disclosure arrows, come from `@sanity/icons` so they match their surroundings. Lucide is distributed under the [ISC License](https://github.com/lucide-icons/lucide/blob/main/LICENSE).
|
|
287
340
|
|
|
288
341
|
<br />
|
|
289
342
|
<br />
|