@driftime/sanity-plugin-handbook 0.3.0 → 0.3.2

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 CHANGED
@@ -2,9 +2,10 @@
2
2
  <picture>
3
3
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/icon-dark.svg" />
4
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" />
5
+ <img src="https://raw.githubusercontent.com/driftime/sanity-plugin-handbook/HEAD/.github/assets/icon-light.svg" alt="Handbook plugin logo" width="48" />
6
6
  </picture>
7
- <h1>Handbook — A Sanity Plugin</h1>
7
+ <h1>Handbook</h1>
8
+ <p><strong>A Sanity Studio plugin by Driftime®</strong></p>
8
9
  <p>Schema-driven documentation and editorial guides, built right into Sanity Studio.</p>
9
10
  </div>
10
11
 
@@ -35,6 +36,8 @@ Handbook is built for Sanity Studio 6 and React 19, and declares both as peer de
35
36
  bun add -E @driftime/sanity-plugin-handbook
36
37
  ```
37
38
 
39
+ <br />
40
+
38
41
  ## Basic Setup
39
42
 
40
43
  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.
@@ -137,6 +140,8 @@ If no `handbook` property is provided, the tool falls back to the field's `title
137
140
 
138
141
  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.
139
142
 
143
+ <br />
144
+
140
145
  ## Guide Content
141
146
 
142
147
  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.
@@ -211,6 +216,8 @@ export default defineConfig({
211
216
  });
212
217
  ```
213
218
 
219
+ <br />
220
+
214
221
  ## Editor Permissions
215
222
 
216
223
  Restrict who can create and edit Handbook documents by providing a list of email addresses.
@@ -234,6 +241,8 @@ import { useIsHandbookEditor } from "@driftime/sanity-plugin-handbook";
234
241
  const isEditor = useIsHandbookEditor();
235
242
  ```
236
243
 
244
+ <br />
245
+
237
246
  ## Structure Integration
238
247
 
239
248
  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.
@@ -307,6 +316,8 @@ Only `roles` is required, since it tells the plugin which document types to cove
307
316
  | `editors` | `string[]` | `undefined` | Email addresses permitted to edit Handbook documents. Unrestricted when omitted. |
308
317
  | `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
318
 
319
+ <br />
320
+
310
321
  ## Exported Types
311
322
 
312
323
  These types are exported for typing your own configuration and for querying Handbook content outside the Studio.
@@ -334,6 +345,8 @@ Content the dataset stores:
334
345
  | `SanityHandbookVideo` | A video block, with its asset and caption. |
335
346
  | `SanityHandbookLink` | A link annotation, with the web address it points to. |
336
347
 
348
+ <br />
349
+
337
350
  ## Acknowledgements
338
351
 
339
352
  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).
@@ -342,7 +355,15 @@ The icons in `src/icons` are derived from [Lucide](https://lucide.dev) and redra
342
355
  <br />
343
356
 
344
357
  <div align="center">
345
- <a href="https://driftime.com" target="_blank">
358
+ <p><strong>Built alongside <a href="https://cairn.driftime.com">Cairn</a>, a starting point for responsible web experiences.</strong></p>
359
+ <p>Part of a suite of Sanity Studio plugins by Driftime®</p>
360
+ <p><a href="https://github.com/driftime/sanity-plugin-handbook">Handbook</a> · <a href="https://github.com/driftime/sanity-plugin-icon">Icon</a></p>
361
+ </div>
362
+
363
+ <br />
364
+
365
+ <div align="center">
366
+ <a href="https://driftime.com">
346
367
  <picture>
347
368
  <source media="(prefers-color-scheme: dark)" srcset="https://driftime.com/driftime-github-logo-dark.svg" />
348
369
  <source media="(prefers-color-scheme: light)" srcset="https://driftime.com/driftime-github-logo.svg" />
package/dist/index.d.ts CHANGED
@@ -82,7 +82,7 @@ interface SanityHandbookConfig {
82
82
  * @returns Sanity plugin definition.
83
83
  * @public
84
84
  */
85
- declare const handbookPlugin: import("sanity").Plugin<SanityHandbookConfig>;
85
+ export declare const handbookPlugin: import("sanity").Plugin<SanityHandbookConfig>;
86
86
  /**
87
87
  * Creates the Structure tool items for Handbook documents, yielding nothing when the current user is
88
88
  * not permitted to edit them.
@@ -93,7 +93,7 @@ declare const handbookPlugin: import("sanity").Plugin<SanityHandbookConfig>;
93
93
  * @returns The list items for the Handbook singleton and the guides list.
94
94
  * @public
95
95
  */
96
- declare function handbookStructure(structureBuilder: StructureBuilder, context: {
96
+ export declare function handbookStructure(structureBuilder: StructureBuilder, context: {
97
97
  currentUser: CurrentUser | null;
98
98
  }, editors?: string[]): import("sanity/structure").ListItemBuilder[];
99
99
  /**
@@ -104,7 +104,7 @@ declare function handbookStructure(structureBuilder: StructureBuilder, context:
104
104
  * @returns Whether the current user can edit Handbook documents.
105
105
  * @public
106
106
  */
107
- declare function useIsHandbookEditor(editors?: string[]): boolean;
107
+ export declare function useIsHandbookEditor(editors?: string[]): boolean;
108
108
  /** Drops a type's catch-all index signature, so a mistyped field name is an error rather than an unknown value. */
109
109
  type Strict<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
110
110
  /** Array of objects each carrying the key Sanity assigns to array items, keeping members identifiable. */
@@ -232,5 +232,5 @@ type SanityHandbookLink = Strict<PortableTextObject> & {
232
232
  /** Web address the link points to. */
233
233
  href?: string;
234
234
  };
235
- export { type SanityHandbook, type SanityHandbookBlockDefinition, type SanityHandbookCallout, type SanityHandbookCode, type SanityHandbookConfig, type SanityHandbookDocumentRole, type SanityHandbookGuide, type SanityHandbookGuideGroup, type SanityHandbookHorizontalRule, type SanityHandbookImage, type SanityHandbookLink, type SanityHandbookMetadata, type SanityHandbookVideo, handbookPlugin, handbookStructure, useIsHandbookEditor };
235
+ export type { SanityHandbook, SanityHandbookBlockDefinition, SanityHandbookCallout, SanityHandbookCode, SanityHandbookConfig, SanityHandbookDocumentRole, SanityHandbookGuide, SanityHandbookGuideGroup, SanityHandbookHorizontalRule, SanityHandbookImage, SanityHandbookLink, SanityHandbookMetadata, SanityHandbookVideo };
236
236
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/plugin.ts","../src/lib/structure.ts","../src/hooks/use-is-handbook-editor.ts","../src/types.ts","../src/schemas/types/guide.ts","../src/schemas/types/handbook.ts","../src/blocks/callout/content.tsx","../src/schemas/blocks/callout.ts","../src/schemas/blocks/code.ts","../src/schemas/blocks/horizontal-rule.ts","../src/schemas/blocks/image.ts","../src/schemas/blocks/video.ts","../src/schemas/annotations/link.ts"],"mappings":";;;;;YAoBY;IACR,WAAW;;YAIH;IACR,WAAW;;;;;;;;UASE;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;;EAEf;;EAEA;;EAEA,WAAW;;;;;;;UAQI;;EAEf,QAAQ;;EAER,WAAW;IAAgB,OAAO;;;;;;;;UAQnB;;EAEf;;EAEA;;EAEA,OAAO;;EAEP,SAAS;;EAET;;EAEA;;;;;;;;;;cAWW,iCAAc,OAAA;;;;;;;;;;;iBCpFX,kBACd,kBAAkB,kBAClB;EAAW,aAAa;GACxB,gDAAkB;;;;;;;;;iBCXJ,oBAAoB;;KCNxB,OAAO,QAAQ,WAAW,oBAAoB,2BAA2B,YAAY,IAAI,EAAE;;KAG3F,iBAAiB,MAAM,eAAe;;;;;;KCMtC,sBAAsB,OAAO;EACvC,cAAc;;EAEd;;EAEA;;EAEA,SAAS,iBAAiB;;;cAIf;;;;;;UCVI;;EAEf;;EAEA,QAAQ,iBAAiB;;;;;;;KAQf,iBAAiB,OAAO;EAClC,cAAc;;EAEd,QAAQ,iBAAiB;;;cAId;;KCzBD;;;;;;KCOA,wBAAwB,OAAO;EACzC,cAAc;;EAEd,SAAS;;EAET,MAAM,iBAAiB,sBAAsB;;;cAIlC;;;;;;KCbD,qBAAqB,OAAO;EACtC,cAAc;;EAEd;;EAEA;;;cAIW;;;;;;KCTD,+BAA+B,OAAO;EAChD,cAAc;;;cAIH;;;;;;KCLD,sBAAsB,OAAO;EACvC,cAAc;;EAEd;IAAU;;;EAEV;;EAEA;;;cAIW;;;;;;KCXD,sBAAsB,OAAO;EACvC,cAAc;;EAEd;IAAU;;;EAEV;;;cAIW;;;;;;KCZD,qBAAqB,OAAO;EACtC;;EAEA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/plugin.ts","../src/lib/structure.ts","../src/hooks/use-is-handbook-editor.ts","../src/types.ts","../src/schemas/types/guide.ts","../src/schemas/types/handbook.ts","../src/blocks/callout/content.tsx","../src/schemas/blocks/callout.ts","../src/schemas/blocks/code.ts","../src/schemas/blocks/horizontal-rule.ts","../src/schemas/blocks/image.ts","../src/schemas/blocks/video.ts","../src/schemas/annotations/link.ts"],"mappings":";;;;;YAoBY;IACR,WAAW;;YAIH;IACR,WAAW;;;;;;;;UASE;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;;EAEf;;EAEA;;EAEA,WAAW;;;;;;;UAQI;;EAEf,QAAQ;;EAER,WAAW;IAAgB,OAAO;;;;;;;;UAQnB;;EAEf;;EAEA;;EAEA,OAAO;;EAEP,SAAS;;EAET;;EAEA;;;;;;;;;;qBAWW,iCAAc,OAAA;;;;;;;;;;;wBCpFX,kBACd,kBAAkB,kBAClB;EAAW,aAAa;GACxB,gDAAkB;;;;;;;;;wBCXJ,oBAAoB;;KCNxB,OAAO,QAAQ,WAAW,oBAAoB,2BAA2B,YAAY,IAAI,EAAE;;KAG3F,iBAAiB,MAAM,eAAe;;;;;;KCMtC,sBAAsB,OAAO;EACvC,cAAc;;EAEd;;EAEA;;EAEA,SAAS,iBAAiB;;;cAIf;;;;;;UCVI;;EAEf;;EAEA,QAAQ,iBAAiB;;;;;;;KAQf,iBAAiB,OAAO;EAClC,cAAc;;EAEd,QAAQ,iBAAiB;;;cAId;;KCzBD;;;;;;KCOA,wBAAwB,OAAO;EACzC,cAAc;;EAEd,SAAS;;EAET,MAAM,iBAAiB,sBAAsB;;;cAIlC;;;;;;KCbD,qBAAqB,OAAO;EACtC,cAAc;;EAEd;;EAEA;;;cAIW;;;;;;KCTD,+BAA+B,OAAO;EAChD,cAAc;;;cAIH;;;;;;KCLD,sBAAsB,OAAO;EACvC,cAAc;;EAEd;IAAU;;;EAEV;;EAEA;;;cAIW;;;;;;KCXD,sBAAsB,OAAO;EACvC,cAAc;;EAEd;IAAU;;;EAEV;;;cAIW;;;;;;KCZD,qBAAqB,OAAO;EACtC;;EAEA"}
package/dist/index.js CHANGED
@@ -1604,7 +1604,7 @@ function hasOfArray(value) {
1604
1604
  * @returns The type name, or undefined when the value declares none.
1605
1605
  */
1606
1606
  function getTypeName(value) {
1607
- if (!(typeof value != "object" || !value || !("type" in value))) return typeof value.type == "string" ? value.type : void 0;
1607
+ if (typeof value == "object" && value && "type" in value) return typeof value.type == "string" ? value.type : void 0;
1608
1608
  }
1609
1609
  /**
1610
1610
  * Extracts the parent type name from a compiled schema type, if present.
@@ -1613,7 +1613,7 @@ function getTypeName(value) {
1613
1613
  * @returns The parent type name, or undefined when the type extends none.
1614
1614
  */
1615
1615
  function getParentTypeName(resolvedType) {
1616
- if (!(typeof resolvedType != "object" || !resolvedType || !("type" in resolvedType)) && !(typeof resolvedType.type != "object" || resolvedType.type === null || !("name" in resolvedType.type))) return String(resolvedType.type.name);
1616
+ if (typeof resolvedType == "object" && resolvedType && "type" in resolvedType && typeof resolvedType.type == "object" && resolvedType.type !== null && "name" in resolvedType.type) return String(resolvedType.type.name);
1617
1617
  }
1618
1618
  /**
1619
1619
  * Normalises a compiled schema field into the shape the Handbook renders. Type names already seen are