@tenphi/cookbook 0.28.0 → 0.30.0

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.
Files changed (54) hide show
  1. package/README.md +13 -11
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.js +2 -2
  4. package/docs/ai-agents.md +5 -3
  5. package/docs/architecture.md +10 -7
  6. package/docs/authoring.mdx +94 -36
  7. package/docs/cli.md +92 -33
  8. package/docs/component-styles.md +286 -282
  9. package/docs/configuration.md +232 -153
  10. package/docs/content-sources.md +39 -21
  11. package/docs/custom-components.md +117 -169
  12. package/docs/customization-rules.md +23 -14
  13. package/docs/deployment.md +101 -53
  14. package/docs/es/getting-started.md +7 -5
  15. package/docs/es/index.md +1 -1
  16. package/docs/examples.md +65 -28
  17. package/docs/fonts-and-typography.md +32 -27
  18. package/docs/getting-started.md +17 -10
  19. package/docs/ja/getting-started.md +7 -5
  20. package/docs/ja/index.md +1 -1
  21. package/docs/migration.md +188 -65
  22. package/docs/plugins.md +28 -16
  23. package/docs/publishing.md +3 -2
  24. package/docs/quality-checks.md +18 -42
  25. package/docs/recipes.md +38 -54
  26. package/docs/ru/getting-started.md +7 -5
  27. package/docs/ru/index.md +1 -1
  28. package/docs/site-navigation.md +47 -47
  29. package/docs/theme-and-components.md +126 -59
  30. package/docs/troubleshooting.md +4 -3
  31. package/docs/upstream/manifest.json +2 -2
  32. package/docs/upstream/tasty/README.md +404 -381
  33. package/docs/upstream/tasty/docs/README.md +4 -1
  34. package/docs/upstream/tasty/docs/adoption.md +25 -17
  35. package/docs/upstream/tasty/docs/ai-agents.md +42 -34
  36. package/docs/upstream/tasty/docs/comparison.md +9 -8
  37. package/docs/upstream/tasty/docs/configuration.md +187 -69
  38. package/docs/upstream/tasty/docs/debug.md +3 -2
  39. package/docs/upstream/tasty/docs/design-system.md +117 -15
  40. package/docs/upstream/tasty/docs/dsl.md +211 -117
  41. package/docs/upstream/tasty/docs/getting-started.md +81 -24
  42. package/docs/upstream/tasty/docs/injector.md +41 -40
  43. package/docs/upstream/tasty/docs/methodology.md +46 -21
  44. package/docs/upstream/tasty/docs/migration-v3.md +3 -3
  45. package/docs/upstream/tasty/docs/pipeline.md +111 -116
  46. package/docs/upstream/tasty/docs/plugins.md +21 -41
  47. package/docs/upstream/tasty/docs/react-api.md +73 -10
  48. package/docs/upstream/tasty/docs/runtime-benchmarks.md +46 -46
  49. package/docs/upstream/tasty/docs/ssr.md +92 -66
  50. package/docs/upstream/tasty/docs/styles.md +37 -17
  51. package/docs/upstream/tasty/docs/tasty-static.md +175 -57
  52. package/docs/zh/getting-started.md +7 -5
  53. package/docs/zh/index.md +1 -1
  54. package/package.json +3 -3
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @tenphi/cookbook
2
2
 
3
3
  Before changing a site's appearance, read the
4
- [customization rules](./docs/customization-rules.md)
5
- ([online](https://cookbook.tenphi.me/customization-rules/)). The package ships
6
- the complete [Cookbook documentation](./docs/index.md) and local Tasty and Glaze
7
- references under `docs/upstream/`, including Tasty's
8
- [style rules for AI agents](./docs/upstream/tasty/docs/ai-agents.md).
9
- The guide includes a project instruction snippet and the lint setup.
4
+ [customization rules](https://cookbook.tenphi.me/customization-rules/). The
5
+ package ships the complete [Cookbook documentation](https://cookbook.tenphi.me/)
6
+ in `node_modules/@tenphi/cookbook/docs/`, with local Tasty and Glaze references
7
+ under `docs/upstream/`, including Tasty's style rules for AI agents at
8
+ `docs/upstream/tasty/docs/ai-agents.md`. The customization rules include a
9
+ project instruction snippet and the lint setup.
10
10
 
11
11
  Install the complete integration with `npx astro add @tenphi/cookbook`:
12
12
 
@@ -39,9 +39,9 @@ export default defineDocsConfig({
39
39
 
40
40
  For local fonts, place files in `public/fonts/` and use
41
41
  `fonts: { body: { family: "My Font", files: [{ src: "/fonts/my-font.woff2" }] } }`.
42
- See [Component styles](./docs/component-styles.md) for all named
43
- sub-elements and [Custom components](./docs/custom-components.md) for the
44
- custom component flow.
42
+ See [Component styles](https://cookbook.tenphi.me/component-styles/) for all
43
+ named sub-elements and [Custom components](https://cookbook.tenphi.me/custom-components/)
44
+ for the custom component flow.
45
45
 
46
46
  Without configuration, a root `README.md` becomes `/` and
47
47
  `docs/**/*.{md,mdx}` supplies the remaining pages. Cookbook includes its Astro renderer,
@@ -60,7 +60,8 @@ export const ProjectBadge = defineComponent("ProjectBadge", {
60
60
  ```
61
61
 
62
62
  Customize this component's root through `theme.customStyles.ProjectBadge`; it has no
63
- named sub-elements. The `/styling` entry point also exports `tasty`, `useGlobalStyles`,
63
+ named sub-elements. The `/styling` entry point also exports `extendComponent`,
64
+ the shared `Button` foundation, `tasty`, `useGlobalStyles`,
64
65
  `resolveComponentStyles`, `mergeStyles`, and the `Styles` type. Cookbook extracts
65
66
  the CSS automatically. See [Custom components](https://cookbook.tenphi.me/custom-components/)
66
67
  for a complete custom logo and site title example.
@@ -77,7 +78,8 @@ export default {
77
78
  ```
78
79
 
79
80
  The entry point exports the default Tasty ESLint plugin, `recommended` and `strict`
80
- rule maps, and the upstream configuration types. The preset recognizes Cookbook's
81
+ rule maps, the `validationConfig` preset, `createValidationConfig(theme)` for
82
+ deriving names from a theme, and the upstream configuration types. The preset recognizes Cookbook's
81
83
  theme names and custom styling helpers, including `defineComponent`. `extends`
82
84
  merges your additional tokens, states, and presets with these built-ins.
83
85
  See [Linting custom styles](https://cookbook.tenphi.me/custom-components/#linting-custom-styles)
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- import renderer_default, { CookbookOptions, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS } from "@tenphi/renderer";
2
+ import renderer_default, { CookbookOptions, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, ResolvedDocsTheme, resolveDocsTheme } from "@tenphi/renderer";
3
3
  import { BrandConfig, BrandDeclaration, BreadcrumbItem, BuildConfig, COOKBOOK_COMPONENT_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, ComponentStyleConfig, ComponentStyles, ComponentStylesConfig, ComponentsConfig, ContentConfig, CookbookComponentName, CookbookComponentStyles, CookbookComponentSubElementName, DocsAsset, DocsConfig, DocsDiagnostic, DocsEntry, DocsFrontmatter, DocsGraph, DocsRoute, DocsSource, EditLinkConfig, FontLoadingConfig, HeadConfig, LocaleConfig, MarkdownConfig, NavigationConfig, NavigationItem, NavigationPlacement, NavigationTab, PageSeoConfig, SearchConfig, SiteConfig, SiteIconConfig, SiteLogoConfig, SiteSeoConfig, SiteVersion, SocialImage, TableOfContentsConfig, ThemeConfig, ThemeFont, ThemeFontFile, ThemeFonts, ThemePaletteColor, ThemePaletteConfig, ThemeTokenValue, ThemeTokens, TypographyPreset, TypographyPresets, defineDocsConfig, mergeDocsConfig } from "@tenphi/docs";
4
- export { type BrandConfig, type BrandDeclaration, type BreadcrumbItem, type BuildConfig, COOKBOOK_COMPONENT_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, type ComponentStyleConfig, type ComponentStyles, type ComponentStylesConfig, type ComponentsConfig, type ContentConfig, type CookbookComponentName, type CookbookComponentStyles, type CookbookComponentSubElementName, type CookbookOptions, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, type DocsAsset, type DocsConfig, type DocsDiagnostic, type DocsEntry, type DocsFrontmatter, type DocsGraph, type DocsRoute, type DocsSource, type EditLinkConfig, type FontLoadingConfig, type HeadConfig, type LocaleConfig, type MarkdownConfig, type NavigationConfig, type NavigationItem, type NavigationPlacement, type NavigationTab, type PageSeoConfig, type SearchConfig, type SiteConfig, type SiteIconConfig, type SiteLogoConfig, type SiteSeoConfig, type SiteVersion, type SocialImage, type TableOfContentsConfig, type ThemeConfig, type ThemeFont, type ThemeFontFile, type ThemeFonts, type ThemePaletteColor, type ThemePaletteConfig, type ThemeTokenValue, type ThemeTokens, type TypographyPreset, type TypographyPresets, renderer_default as default, defineDocsConfig, mergeDocsConfig };
4
+ export { type BrandConfig, type BrandDeclaration, type BreadcrumbItem, type BuildConfig, COOKBOOK_COMPONENT_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, type ComponentStyleConfig, type ComponentStyles, type ComponentStylesConfig, type ComponentsConfig, type ContentConfig, type CookbookComponentName, type CookbookComponentStyles, type CookbookComponentSubElementName, type CookbookOptions, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, type DocsAsset, type DocsConfig, type DocsDiagnostic, type DocsEntry, type DocsFrontmatter, type DocsGraph, type DocsRoute, type DocsSource, type EditLinkConfig, type FontLoadingConfig, type HeadConfig, type LocaleConfig, type MarkdownConfig, type NavigationConfig, type NavigationItem, type NavigationPlacement, type NavigationTab, type PageSeoConfig, type ResolvedDocsTheme, type SearchConfig, type SiteConfig, type SiteIconConfig, type SiteLogoConfig, type SiteSeoConfig, type SiteVersion, type SocialImage, type TableOfContentsConfig, type ThemeConfig, type ThemeFont, type ThemeFontFile, type ThemeFonts, type ThemePaletteColor, type ThemePaletteConfig, type ThemeTokenValue, type ThemeTokens, type TypographyPreset, type TypographyPresets, renderer_default as default, defineDocsConfig, mergeDocsConfig, resolveDocsTheme };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import renderer_default, { DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS } from "@tenphi/renderer";
2
+ import renderer_default, { DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, resolveDocsTheme } from "@tenphi/renderer";
3
3
  import { COOKBOOK_COMPONENT_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, defineDocsConfig, mergeDocsConfig } from "@tenphi/docs";
4
- export { COOKBOOK_COMPONENT_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, renderer_default as default, defineDocsConfig, mergeDocsConfig };
4
+ export { COOKBOOK_COMPONENT_NAMES, COOKBOOK_COMPONENT_SUB_ELEMENTS, COOKBOOK_PALETTE_NAMES, DEFAULT_THEME_TOKENS, DEFAULT_TYPOGRAPHY_PRESETS, renderer_default as default, defineDocsConfig, mergeDocsConfig, resolveDocsTheme };
package/docs/ai-agents.md CHANGED
@@ -37,10 +37,12 @@ Set `site.url` in `docs.config.ts` to the public HTTPS origin. If the site is
37
37
  hosted under a path, set Astro's `base` in `astro.config.ts`. A production build
38
38
  then gives every page a canonical URL and creates a sitemap. Cookbook also writes:
39
39
 
40
- - `llms.txt`, a short index of published pages with titles, descriptions, and
41
- links to their readable HTML pages. Drafts are omitted. This is an optional
40
+ - `llms.txt`, a short index of published pages with titles, descriptions, links
41
+ to their HTML pages and, unless `site.seo.copyPage` is `false`, their Markdown
42
+ copies. Drafts, noindex pages, and non-canonical duplicates are omitted. This is an optional
42
43
  discovery aid for agents that choose to read it.
43
- - `robots.txt` at origin-root deployments with a pointer to the sitemap. A
44
+ - `robots.txt` at origin-root deployments with `site.url` set, with a pointer to
45
+ the sitemap. A
44
46
  `robots.txt` below a path such as `/project/` would not control the origin's
45
47
  crawlers, so Cookbook does not generate one there.
46
48
 
@@ -14,12 +14,12 @@ maintained in this repository.
14
14
 
15
15
  ## Packages
16
16
 
17
- | Package | Responsibility |
18
- | ------------------------- | ------------------------------------------------------------------------------------------------------- |
19
- | `@tenphi/create-cookbook` | Inspect an npm artifact and scaffold a reproducible documentation project |
20
- | `@tenphi/cookbook` | Provide the memorable Astro integration, public config exports, and CLI |
21
- | `@tenphi/docs` | Discover sources, resolve packages, build the content graph, transform Markdown, and report diagnostics |
22
- | `@tenphi/renderer` | Render the graph with Astro and provide the Tasty/Glaze theme, components, search, and static assets |
17
+ | Package | Responsibility |
18
+ | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
19
+ | `@tenphi/create-cookbook` | Scaffold a documentation project for a new site, an existing repository, or a locked npm package |
20
+ | `@tenphi/cookbook` | Provide the memorable Astro integration, public config exports, and CLI |
21
+ | `@tenphi/docs` | Validate configuration, resolve the Glaze palette, discover sources, resolve packages, build the content graph, transform Markdown, and report diagnostics |
22
+ | `@tenphi/renderer` | Render the graph with Astro and provide the Tasty/Glaze theme, components, search, and static assets |
23
23
 
24
24
  The `@tenphi/cookbook` default export represents the complete product. Consumers do
25
25
  not compose renderer internals themselves.
@@ -27,7 +27,7 @@ not compose renderer internals themselves.
27
27
  ## Build pipeline
28
28
 
29
29
  1. Validate and normalize the configuration.
30
- 2. Collect local and locked package sources.
30
+ 2. Collect local files, local OpenAPI documents, and locked package sources.
31
31
  3. Assign canonical routes to every document.
32
32
  4. Parse Markdown and collect headings, links, and assets.
33
33
  5. Rewrite internal references through the completed route graph.
@@ -135,6 +135,9 @@ The monorepo's `apps/reference` project is both the deployed documentation site
135
135
  and an end-to-end fixture. Its integration discovers `docs.config.ts`, whose
136
136
  `root: "../.."` loads this `docs/` tree through the same route pipeline used by
137
137
  convention-mode sites. CI builds the same app before GitHub Pages publishes it.
138
+ The site is deployed only after a package release: the release workflow creates
139
+ a version tag and starts the Pages workflow from that tag, so the public
140
+ reference matches the published code.
138
141
 
139
142
  Return to [Cookbook](./index.md) or inspect the
140
143
  [repository](https://github.com/tenphi/cookbook).
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Authoring components
3
- description: Use accessible tabs, callouts, code groups, cards, steps, and isolated previews.
3
+ description: Write pages, then use accessible tabs, callouts, code groups, cards, steps, and isolated previews.
4
4
  sidebar:
5
5
  order: 4
6
6
  ---
@@ -19,6 +19,18 @@ Write ordinary Markdown for most pages. Use MDX when a page needs components,
19
19
  and import them from `@tenphi/cookbook/components`. Local MDX is supported by
20
20
  default; npm MDX requires an explicit `trust: "mdx"` source declaration.
21
21
 
22
+ ## Page titles and descriptions
23
+
24
+ A page's title comes from its frontmatter `title`, then the source
25
+ declaration's `title`, then its first `#` heading, then its file name. When the
26
+ page starts with an `#` heading equal to its title, Cookbook removes that heading
27
+ from the body so the title is not shown twice. The description comes from
28
+ frontmatter `description`, then the source declaration, then the first prose
29
+ paragraph of at least 20 characters, cut to 240 characters.
30
+
31
+ See [page frontmatter](./configuration.md#page-frontmatter) for every field,
32
+ including `slug`, `draft`, `sidebar`, `prev`, and `next`.
33
+
22
34
  ## Tabs
23
35
 
24
36
  Every panel requires a `label`. Arrow keys, Home, and End move between tabs;
@@ -44,7 +56,8 @@ import { Tab, Tabs } from "@tenphi/cookbook/components";
44
56
  Use `kind="note"`, `"tip"`, `"caution"`, or `"danger"`; `title` overrides the
45
57
  visible label. The default kind is `note`. Status colors come from
46
58
  `theme.palette.info`, `success`, `warning`, and `danger` and adapt to all schemes
47
- and contrast modes.
59
+ and contrast modes. For callouts written in plain Markdown, use
60
+ [GitHub alerts](./plugins.md#github-alerts).
48
61
 
49
62
  ```mdx
50
63
  <Callout kind="tip" title="Keep content close to code">
@@ -81,10 +94,13 @@ Each panel retains keyboard-accessible tabs and readable fallback content.
81
94
  ]}
82
95
  />
83
96
 
84
- ## Cards, steps, and previews
97
+ ## Cards and steps
85
98
 
86
99
  Use a card to link to another page, or omit `href` to present a standalone
87
- summary. `Steps` renders an ordered list; put ordinary `li` elements inside it.
100
+ summary. `href` is used as written: give a public URL, including any Astro
101
+ `base`, or a `#fragment`. Unlike Markdown links, `.md` paths are not rewritten;
102
+ `cookbook check-build` reports broken targets. `Steps` renders an ordered list;
103
+ put ordinary `li` elements inside it.
88
104
 
89
105
  ```mdx
90
106
  import { Card, Steps } from "@tenphi/cookbook/components";
@@ -110,6 +126,8 @@ import { Card, Steps } from "@tenphi/cookbook/components";
110
126
  <li>Build and check the output.</li>
111
127
  </Steps>
112
128
 
129
+ ## Previews
130
+
113
131
  `Preview` runs HTML and optional JavaScript in a sandboxed iframe with a source
114
132
  disclosure. It cannot access the documentation page's origin. Its `css` prop is
115
133
  for the isolated preview document; style the documentation shell with Tasty.
@@ -130,6 +148,8 @@ import { Preview } from "@tenphi/cookbook/components";
130
148
  css={"button { padding: 0.75rem; }"}
131
149
  />
132
150
 
151
+ ### Run your own library
152
+
133
153
  To demonstrate your own library, build it into the site's public directory
134
154
  (`public/` by default) and list the files in `scripts` by their public path,
135
155
  without the Astro `base`. Cookbook inlines each file, in order, before
@@ -154,6 +174,8 @@ shows each inlined file as a `<script src>` tag. Every preview embeds its own
154
174
  copy, so keep demo bundles small. A missing file or a path outside the public
155
175
  directory fails the build.
156
176
 
177
+ ### Frame size
178
+
157
179
  A preview that runs scripts, with `javascript` or `scripts`, fits its frame to
158
180
  its content. The frame grows and shrinks as the content changes, the page
159
181
  width changes, or fonts load. It is at least `10rem` tall and at most as tall
@@ -184,15 +206,16 @@ make it taller when it opens, so reserve room for it:
184
206
 
185
207
  - `buffer` adds room below the content for a picker's list, such as a select's
186
208
  or a combobox's. The room follows the content as the page width changes it.
187
- It defaults to `0`. A preview without scripts can't measure its content, so
188
- `buffer` has no effect there.
209
+ It defaults to no extra room. A preview without scripts can't measure its
210
+ content, so `buffer` has no effect there.
189
211
  - `height` sets the frame's minimum height in place of `10rem`, for an overlay
190
212
  that uses the whole frame, such as a modal dialog. It also applies to
191
213
  previews without scripts.
192
214
 
193
215
  The frame is as tall as the content plus `buffer`, up to the window's height,
194
- and never shorter than `height`. Both take a CSS length, such as `12rem` or `320px`; any other value, including
195
- a percentage or `calc()`, fails the build. To change every preview, style
216
+ and never shorter than `height`. Both take a CSS length with a unit, such as
217
+ `12rem`, `320px`, or `0px`; any other value, including a unitless `0`, a
218
+ percentage, or `calc()`, fails the build. To change every preview, style
196
219
  `theme.styles.Preview.Frame` instead.
197
220
 
198
221
  ```mdx
@@ -215,6 +238,8 @@ Don't size the content by the frame, for example with `100vh` or
215
238
  `height: 100%` on the root element: the frame can't fit such content, and it
216
239
  can grow to the window's height.
217
240
 
241
+ ### Forms
242
+
218
243
  Forms in a preview can be submitted. To show what a form sends, call
219
244
  `event.preventDefault()` in a `submit` listener and read its `FormData`;
220
245
  otherwise the submission navigates the frame away from the demo. The
@@ -248,62 +273,95 @@ origin.
248
273
  `Logo` renders the Cookbook mark. Use `label` when it carries meaning or
249
274
  `decorative` beside nearby text that already names the site. To display your
250
275
  own artwork in the header and drawer, configure
251
- [`site.logo`](./configuration.md#site-logo).
276
+ [`site.logo`](./theme-and-components.md#logo-and-favicon).
252
277
 
253
- ## Diff snippets
278
+ ## Code fences
254
279
 
255
- Use a `diff` code fence to highlight additions and deletions. The `+` and `-`
256
- markers remain visible independently of their theme-aware backgrounds:
280
+ Fenced code blocks get Shiki highlighting and a copy control. Use a `diff` or
281
+ `patch` fence to highlight additions and deletions. The `+` and `-` markers
282
+ remain visible independently of their theme-aware backgrounds:
257
283
 
258
284
  ```diff
259
285
  -formatOkhsl(v.h, v.s * 100, l * 100);
260
286
  +formatOkhsl(v.h, v.s, l);
261
287
  ```
262
288
 
289
+ A `mermaid` fence renders a static, theme-aware diagram; see
290
+ [Mermaid diagrams](./configuration.md#markdown).
291
+
263
292
  ## Component props
264
293
 
265
- | Component | Props and behavior |
266
- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
267
- | `Card` | Optional `title` and `href`; renders an article or link with slot content |
268
- | `Steps` | Ordered list container; supply `li` elements |
269
- | `Logo` | Optional `label`, `decorative`, and root `class`; renders the Cookbook mark |
270
- | `Preview` | Required `title`; optional `html`, `css`, `javascript`, public-file `scripts`, minimum frame `height`, and overlay `buffer`; isolates examples in a sandboxed iframe that fits scripted content |
294
+ | Component | Props and behavior |
295
+ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
296
+ | `Tabs` | Optional `label`, the tab list's accessible name (default "Examples"); contains `Tab` elements |
297
+ | `Tab` | Required `label`, used as the tab button text and as the panel heading without JavaScript |
298
+ | `Callout` | Optional `kind` (`note` by default, `tip`, `caution`, or `danger`) and `title` |
299
+ | `CodeGroup` | Optional `label` (default "Code examples") and required `items`: `{ label, code, language? }[]` |
300
+ | `Card` | Optional `title` and `href`; renders an article or link with slot content |
301
+ | `Steps` | Ordered list container; supply `li` elements |
302
+ | `Logo` | Optional `label`, `decorative`, and root `class`; renders the Cookbook mark |
303
+ | `Preview` | Required `title`; optional `html`, `css`, `javascript`, public-file `scripts`, minimum frame `height`, and overlay `buffer`; isolates examples in a sandboxed iframe that fits scripted content |
271
304
 
272
305
  The public package exports each component's props type, such as `TabProps`,
273
306
  `CalloutProps`, and `CodeGroupProps`. Styles and all named sub-elements are
274
- listed in [Component styles](./component-styles.md#style-customization).
307
+ listed in [Component styles](./component-styles.md#complete-component-anatomy).
275
308
 
276
309
  ## On-page navigation
277
310
 
278
- Desktop pages show a table of contents. Opt into a compact disclosure below the
279
- header on smaller screens, globally in `docs.config.ts`:
311
+ Desktop pages show a table of contents for heading levels 2 and 3. Set the
312
+ site defaults with the top-level
313
+ [`tableOfContents`](./configuration.md#table-of-contents) key; set the same
314
+ field in a page's frontmatter to change one page:
280
315
 
281
- ```ts
282
- tableOfContents: { mobile: true, minHeadingLevel: 2, maxHeadingLevel: 3 }
316
+ ```yaml
317
+ tableOfContents:
318
+ mobile: true
319
+ maxHeadingLevel: 4
283
320
  ```
284
321
 
285
- The same frontmatter field can change heading levels or set `mobile: false` on
286
- one page. `tableOfContents: false` disables both versions. Selecting a mobile
287
- contents link closes the disclosure and moves keyboard focus to the heading.
288
- The desktop contents list highlights the current section and scrolls its own
289
- list when the active link moves out of view.
290
- Customize `theme.styles.MobileTableOfContents` and `TableOfContentsLayout`.
322
+ A page's `tableOfContents` object replaces the site's heading levels; omitted
323
+ levels fall back to 2 and 3. Only `mobile` falls back to `docs.config.ts`.
324
+ `tableOfContents: false` disables both versions. Selecting a mobile contents
325
+ link closes the disclosure and moves keyboard focus to the heading. The desktop
326
+ contents list highlights the current section and scrolls its own list when the
327
+ active link moves out of view. Customize `theme.styles.TableOfContents` (desktop
328
+ list), `MobileTableOfContents`, and `TableOfContentsLayout`.
291
329
 
292
- ## Hero images
330
+ ## Hero
293
331
 
294
- Use a relative local image in frontmatter. Cookbook reads its intrinsic dimensions
295
- and reserves the correct aspect ratio as the layout responds to screen width:
332
+ Add `hero` to a page's frontmatter to show a hero above the content. Home
333
+ pages usually combine it with the wide `template: splash` layout:
296
334
 
297
335
  ```yaml
336
+ template: splash
298
337
  hero:
299
- tagline: Build something useful.
338
+ title: Build something useful
339
+ tagline: Documentation that stays with the code.
300
340
  image:
301
341
  file: ./assets/hero.png
302
342
  alt: A preview of the documentation
343
+ actions:
344
+ - text: Get started
345
+ link: ./getting-started.md
346
+ variant: primary
347
+ - text: Compare tools
348
+ link: /comparison
349
+ variant: secondary
303
350
  ```
304
351
 
352
+ `title` defaults to the page title. Each action needs `text` and `link`;
353
+ `variant` is `primary`, `secondary`, or `minimal`. Action links go through the
354
+ same link rewriting as Markdown, so a relative `.md` path works.
355
+
356
+ ### Hero images
357
+
358
+ Use a relative local image. Cookbook reads its intrinsic dimensions and
359
+ reserves the correct aspect ratio as the layout responds to screen width.
305
360
  Use `light` and `dark` instead of `file` for appearance variants; both must have
306
361
  the same aspect ratio. Remote or public-path images require explicit `width` and
307
- `height`. Hero images load eagerly with high fetch priority; use ordinary Markdown
308
- images for content farther down the page. `theme.styles.Hero.Visual` controls
309
- responsive sizing without changing the intrinsic dimensions.
362
+ `height`; explicit dimensions on a local image must match its aspect ratio.
363
+ `image.html` accepts inline HTML, such as an SVG, in local content and is
364
+ removed from untrusted package Markdown. Hero images load eagerly with high fetch priority;
365
+ use ordinary Markdown images for content farther down the page.
366
+ `theme.styles.Hero.Visual` controls responsive sizing without changing the
367
+ intrinsic dimensions.
package/docs/cli.md CHANGED
@@ -5,10 +5,37 @@ sidebar:
5
5
  order: 6
6
6
  ---
7
7
 
8
+ Cookbook has two command-line tools: the `cookbook` command from
9
+ `@tenphi/cookbook`, and the project creator run through
10
+ `npm create @tenphi/cookbook`.
11
+
12
+ | Command | Purpose |
13
+ | ---------------------- | ---------------------------------------------------------------- |
14
+ | `cookbook doctor` | Check configuration, content, links, and local files (preflight) |
15
+ | `cookbook check-build` | Check the built site and, with `--url`, its deployment |
16
+ | `cookbook update` | Create or refresh `cookbook.lock.json` for npm package sources |
17
+ | `cookbook --help` | Print usage; `cookbook` without a command does the same |
18
+
8
19
  The integration and CLI discover `docs.config.ts`, `.mts`, `.js`, or `.mjs` in the
9
20
  project directory. Its `root` sets the content and lock directory. Use `--root`
10
21
  to select another project, or `--config` for an explicit config path relative to
11
- that project.
22
+ that project. Add `--json` to any command for machine-readable output.
23
+
24
+ Projects made by the creator wrap these commands in `package.json` scripts:
25
+
26
+ | Script | Runs |
27
+ | ------------- | ------------------------------------------------------------------------ |
28
+ | `dev` | `astro dev` |
29
+ | `build` | `astro build` |
30
+ | `preview` | `astro preview` |
31
+ | `typecheck` | `tsc --noEmit` |
32
+ | `doctor` | `cookbook doctor` |
33
+ | `check-build` | `cookbook check-build` |
34
+ | `validate` | `tsc --noEmit && cookbook doctor && astro build && cookbook check-build` |
35
+ | `update` | `cookbook update` |
36
+
37
+ In a project you set up yourself, add the same scripts or run
38
+ `npx @tenphi/cookbook <command>`.
12
39
 
13
40
  ## Validate with doctor
14
41
 
@@ -28,7 +55,9 @@ Doctor reports **preflight** health. It does not compile MDX or components,
28
55
  download Google fonts, check image decoding, inspect Astro plugins, or verify
29
56
  the emitted site. These checks happen during the build and output validation.
30
57
 
31
- JSON results use a stable envelope, including configuration failures:
58
+ Every JSON result has `ok`, `pages`, `assets`, and `diagnostics`, including
59
+ argument and configuration failures. Doctor adds `scope: "preflight"` and
60
+ `buildVerified: false`:
32
61
 
33
62
  ```json
34
63
  {
@@ -49,11 +78,9 @@ npx @tenphi/cookbook check-build --out dist --json
49
78
  npx @tenphi/cookbook check-build --out dist --url https://docs.example.com/manual/
50
79
  ```
51
80
 
52
- New projects include `validate`, which runs `cookbook doctor && astro build &&
53
- cookbook check-build`. Existing projects can add that script to `package.json`.
54
81
  Use the same environment variables and configuration for building and checking.
55
- `--out` is relative to the selected app directory, even when `docs.config.ts`
56
- points at a different content root.
82
+ `--out` defaults to `dist` and is relative to the selected app directory, even
83
+ when `docs.config.ts` points at a different content root.
57
84
 
58
85
  `check-build` reads actual HTML and CSS plus Cookbook's publishing manifest. It
59
86
  checks local page/asset URLs, heading fragments, referenced fonts, social images,
@@ -69,11 +96,11 @@ remain unchanged on a preview host. An unexpected `X-Robots-Tag: noindex` on an
69
96
  indexable page is reported. Network failures exit non-zero; rerun after the host
70
97
  has finished deploying.
71
98
 
72
- JSON adds `scope` (`built-output` or `deployment`) and `checkedUrls`. A missing
73
- production site URL is a warning: configure `site.url` or Astro's `site` before
74
- relying on canonical or sitemap checks. Warnings do not fail the command.
75
- This checks output and hosting; browser accessibility and interaction testing
76
- remain separate steps.
99
+ JSON output has `scope` (`built-output` or `deployment`) and `checkedUrls`
100
+ instead of `buildVerified`. A missing production site URL is a warning:
101
+ configure `site.url` or Astro's `site` before relying on canonical or sitemap
102
+ checks. Warnings do not fail the command. This checks output and hosting;
103
+ browser accessibility and interaction testing remain separate steps.
77
104
 
78
105
  ## Update package content
79
106
 
@@ -84,14 +111,16 @@ npx @tenphi/cookbook update --json
84
111
  ```
85
112
 
86
113
  `update` reads package sources from configuration, creates the first lock,
87
- resolves changed tags or ranges, and removes entries that are no longer declared.
88
- A package name or exact requested specifier selects individual updates. An
89
- unselected source must already have a matching lock; otherwise run a full update.
114
+ resolves every declared tag or range again, and removes entries that are no
115
+ longer declared. An unchanged `@latest` or `^1` therefore moves to its newest
116
+ match. A package name or exact requested specifier selects individual updates.
117
+ An unselected source must already have a matching lock; otherwise run a full
118
+ update.
90
119
 
91
120
  `--dry-run` resolves versions and shows the proposed changes without writing
92
- files. JSON output adds `dryRun`, `changes`, `removed`, and `lock` to the envelope.
93
- Review and commit the resulting lock diff before deploying. Builds require an
94
- exact requested-specifier match and never silently substitute a lock for another
121
+ files. JSON output adds `dryRun`, `changes`, `removed`, and `lock`. Review and
122
+ commit the resulting lock diff before deploying. Builds require an exact
123
+ requested-specifier match and never silently substitute a lock for another
95
124
  range or tag.
96
125
 
97
126
  Vendored sources remain vendored. New artifacts are stored in separate integrity
@@ -109,22 +138,52 @@ npm create @tenphi/cookbook@latest docs-site -- --source . --yes
109
138
  npm create @tenphi/cookbook@latest docs-site -- --package @scope/package --yes
110
139
  ```
111
140
 
112
- | Flag | Purpose |
113
- | ---------------------------------------------------------------- | ------------------------------------------------- |
114
- | `--source <directory>` | Document an existing local repository |
115
- | `--package <specifier>` | Document a locked npm artifact |
116
- | `--yes`, `-y` | Use non-interactive defaults |
117
- | `--brand <color>` | Set the Glaze brand seed |
118
- | `--site <url>` | Set the canonical site URL |
119
- | `--base <path>` | Set Astro's hosting subpath |
120
- | `--deploy github-pages\|netlify\|cloudflare-pages\|vercel\|none` | Add deployment setup or a host guide |
121
- | `--package-manager npm\|pnpm\|yarn` | Select the project manager |
122
- | `--no-install` | Generate files without installing dependencies |
123
- | `--vendor` | Vendor the npm artifact for offline builds |
124
- | `--trust-package` | Permit MDX execution from the locked npm artifact |
125
- | `--open` | Start and open the development server |
141
+ Pass creator flags after `--` so `npm create` forwards them.
142
+
143
+ | Argument or flag | Purpose |
144
+ | ---------------------------------------------------------------- | ------------------------------------------------------------------------------ |
145
+ | `[destination]` | Target directory; defaults to `docs-site`, or `<name>-docs` with `--package` |
146
+ | `--source <directory>` | Document an existing local repository |
147
+ | `--package <specifier>` | Document a locked npm artifact |
148
+ | `--yes`, `-y` | Never prompt; fail instead of asking to overwrite a non-empty destination |
149
+ | `--brand <color>` | Set the Glaze brand seed |
150
+ | `--site <url>` | Set the canonical site URL |
151
+ | `--base <path>` | Set Astro's hosting subpath |
152
+ | `--deploy github-pages\|netlify\|cloudflare-pages\|vercel\|none` | Add a [deployment workflow or host guide](./deployment.md) |
153
+ | `--package-manager npm\|pnpm\|yarn` | Select the package manager; defaults to the one that ran the creator, then npm |
154
+ | `--no-install` | Generate files without installing dependencies |
155
+ | `--vendor` | Vendor the npm artifact for offline builds |
156
+ | `--trust-package` | Permit MDX execution from the locked npm artifact |
157
+ | `--open` | Start the development server in the background, without output, and open it |
158
+ | `--help`, `-h` | Print usage |
126
159
 
127
160
  `--source` and `--package` are mutually exclusive. With neither, the creator
128
161
  writes a local starter. `--vendor` and `--trust-package` require `--package`.
129
- `--open` requires installation. A non-empty destination requires interactive
130
- confirmation before generated files can be overwritten.
162
+ `--open` requires installation; stop the background server yourself when you
163
+ are done. A non-empty destination requires interactive confirmation before
164
+ generated files can be overwritten.
165
+
166
+ Yarn 4 uses Plug'n'Play by default, which Cookbook does not support. For Yarn,
167
+ the creator writes `.yarnrc.yml` with `nodeLinker: node-modules` and an empty
168
+ `yarn.lock`, so the site also installs as its own project inside an existing
169
+ Yarn repository. With `--deploy github-pages`, a site created inside a Git
170
+ repository gets its workflow at the repository root; see
171
+ [GitHub Pages](./deployment.md#github-pages).
172
+
173
+ ## Diagnostic codes
174
+
175
+ Each diagnostic has a code, a severity, a message, and usually a source file,
176
+ line, and hint. Errors fail the command; warnings do not.
177
+
178
+ | Stage | Codes |
179
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
180
+ | Configuration | `DOCS_CONFIG_INVALID`, `DOCS_CONFIG_UNKNOWN_KEY` |
181
+ | Sources and routes | `DOCS_NO_PAGES`, `DOCS_SOURCE_NOT_FOUND`, `DOCS_SOURCE_OUTSIDE_ROOT`, `DOCS_DUPLICATE_SOURCE`, `DOCS_DUPLICATE_ROUTE`, `DOCS_FRONTMATTER_INVALID`, `DOCS_REDIRECT_INVALID`, `DOCS_VERSION_ROOT_MISSING`, `DOCS_NAV_TARGET_NOT_FOUND`, `DOCS_OPENAPI_INVALID` |
182
+ | Links and assets | `DOCS_LINK_NOT_FOUND` (a warning unless `build.strict`), `DOCS_FRAGMENT_NOT_FOUND` (an error with `build.ci`), `DOCS_LINK_UNSAFE`, `DOCS_AMBIGUOUS_LINK`, `DOCS_HEADING_DUPLICATE`, `DOCS_ASSET_NOT_FOUND`, `DOCS_ASSET_UNSAFE` |
183
+ | Content safety | `DOCS_RAW_HTML_STRIPPED`, `DOCS_RAW_HTML_REJECTED`, `DOCS_UNTRUSTED_HTML`, `DOCS_UNTRUSTED_MDX` |
184
+ | Doctor only | `DOCS_CONFIG_ASSET_MISSING`, `DOCS_COMPONENT_UNRESOLVED`, `DOCS_SEMANTIC_CONTRAST_UNMET`, `DOCS_BRAND_CONTRAST_UNMET` |
185
+ | Built output (`check-build`) | `DOCS_BUILD_MISSING`, `DOCS_SITE_URL_MISSING` (a warning), `DOCS_OUTPUT_URL_INVALID`, `DOCS_OUTPUT_LINK_MISSING`, `DOCS_OUTPUT_FRAGMENT_MISSING`, `DOCS_PUBLISHING_PAGE_MISSING`, `DOCS_CANONICAL_INVALID`, `DOCS_INDEX_POLICY_MISMATCH`, `DOCS_SITEMAP_PAGE_MISSING`, `DOCS_SITEMAP_UNLISTED_PAGE`, `DOCS_AGENT_UNLISTED_PAGE` |
186
+ | Deployment (`--url`) | `DOCS_DEPLOYMENT_HTTP`, `DOCS_DEPLOYMENT_PAGE_MISMATCH`, `DOCS_DEPLOYMENT_NOINDEX`, `DOCS_DEPLOYMENT_ASSET_INVALID`, `DOCS_DEPLOYMENT_FETCH` |
187
+ | Command line | `COOKBOOK_CLI_ERROR` for invalid arguments and other command failures |
188
+
189
+ See [troubleshooting](./troubleshooting.md) for common fixes.