@tenphi/cookbook 0.27.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.
- package/README.md +13 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/docs/ai-agents.md +5 -3
- package/docs/architecture.md +10 -7
- package/docs/authoring.mdx +142 -38
- package/docs/cli.md +92 -33
- package/docs/component-styles.md +286 -279
- package/docs/configuration.md +232 -153
- package/docs/content-sources.md +39 -21
- package/docs/custom-components.md +117 -169
- package/docs/customization-rules.md +23 -14
- package/docs/deployment.md +101 -53
- package/docs/es/getting-started.md +7 -5
- package/docs/es/index.md +1 -1
- package/docs/examples.md +65 -28
- package/docs/fonts-and-typography.md +32 -27
- package/docs/getting-started.md +17 -10
- package/docs/ja/getting-started.md +7 -5
- package/docs/ja/index.md +1 -1
- package/docs/migration.md +188 -65
- package/docs/plugins.md +28 -16
- package/docs/publishing.md +3 -2
- package/docs/quality-checks.md +18 -42
- package/docs/recipes.md +38 -54
- package/docs/ru/getting-started.md +7 -5
- package/docs/ru/index.md +1 -1
- package/docs/site-navigation.md +47 -47
- package/docs/theme-and-components.md +126 -59
- package/docs/troubleshooting.md +4 -3
- package/docs/upstream/manifest.json +2 -2
- package/docs/upstream/tasty/README.md +404 -381
- package/docs/upstream/tasty/docs/README.md +4 -1
- package/docs/upstream/tasty/docs/adoption.md +25 -17
- package/docs/upstream/tasty/docs/ai-agents.md +42 -34
- package/docs/upstream/tasty/docs/comparison.md +9 -8
- package/docs/upstream/tasty/docs/configuration.md +187 -69
- package/docs/upstream/tasty/docs/debug.md +3 -2
- package/docs/upstream/tasty/docs/design-system.md +117 -15
- package/docs/upstream/tasty/docs/dsl.md +211 -117
- package/docs/upstream/tasty/docs/getting-started.md +81 -24
- package/docs/upstream/tasty/docs/injector.md +41 -40
- package/docs/upstream/tasty/docs/methodology.md +46 -21
- package/docs/upstream/tasty/docs/migration-v3.md +3 -3
- package/docs/upstream/tasty/docs/pipeline.md +111 -116
- package/docs/upstream/tasty/docs/plugins.md +21 -41
- package/docs/upstream/tasty/docs/react-api.md +73 -10
- package/docs/upstream/tasty/docs/runtime-benchmarks.md +46 -46
- package/docs/upstream/tasty/docs/ssr.md +92 -66
- package/docs/upstream/tasty/docs/styles.md +37 -17
- package/docs/upstream/tasty/docs/tasty-static.md +175 -57
- package/docs/zh/getting-started.md +7 -5
- package/docs/zh/index.md +1 -1
- 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](
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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](
|
|
43
|
-
sub-elements and [Custom components](
|
|
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 `
|
|
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,
|
|
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,
|
|
41
|
-
|
|
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
|
|
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
|
|
package/docs/architecture.md
CHANGED
|
@@ -14,12 +14,12 @@ maintained in this repository.
|
|
|
14
14
|
|
|
15
15
|
## Packages
|
|
16
16
|
|
|
17
|
-
| Package | Responsibility
|
|
18
|
-
| ------------------------- |
|
|
19
|
-
| `@tenphi/create-cookbook` |
|
|
20
|
-
| `@tenphi/cookbook` | Provide the memorable Astro integration, public config exports, and CLI
|
|
21
|
-
| `@tenphi/docs` |
|
|
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).
|
package/docs/authoring.mdx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Authoring components
|
|
3
|
-
description:
|
|
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
|
|
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. `
|
|
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,21 +174,72 @@ 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
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
177
|
+
### Frame size
|
|
178
|
+
|
|
179
|
+
A preview that runs scripts, with `javascript` or `scripts`, fits its frame to
|
|
180
|
+
its content. The frame grows and shrinks as the content changes, the page
|
|
181
|
+
width changes, or fonts load. It is at least `10rem` tall and at most as tall
|
|
182
|
+
as the browser window; taller content scrolls inside the frame. A preview
|
|
183
|
+
without scripts keeps a `10rem` frame, and content beyond it scrolls.
|
|
184
|
+
|
|
185
|
+
```mdx
|
|
186
|
+
<Preview
|
|
187
|
+
title="Growing list"
|
|
188
|
+
html={'<button type="button">Add item</button><ol></ol>'}
|
|
189
|
+
javascript={
|
|
190
|
+
"document.querySelector('button').addEventListener('click', () => document.querySelector('ol').append(document.createElement('li')));"
|
|
191
|
+
}
|
|
192
|
+
/>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
<Preview
|
|
196
|
+
title="Growing list"
|
|
197
|
+
html={'<button type="button">Add item</button><ol></ol>'}
|
|
198
|
+
javascript={
|
|
199
|
+
"document.querySelector('button').addEventListener('click', () => document.querySelector('ol').append(document.createElement('li')));"
|
|
200
|
+
}
|
|
201
|
+
/>
|
|
202
|
+
|
|
203
|
+
The frame fits the content in the document's flow. An overlay, such as a
|
|
204
|
+
listbox, a popover, a modal dialog, or an absolutely positioned menu, doesn't
|
|
205
|
+
make it taller when it opens, so reserve room for it:
|
|
206
|
+
|
|
207
|
+
- `buffer` adds room below the content for a picker's list, such as a select's
|
|
208
|
+
or a combobox's. The room follows the content as the page width changes it.
|
|
209
|
+
It defaults to no extra room. A preview without scripts can't measure its
|
|
210
|
+
content, so `buffer` has no effect there.
|
|
211
|
+
- `height` sets the frame's minimum height in place of `10rem`, for an overlay
|
|
212
|
+
that uses the whole frame, such as a modal dialog. It also applies to
|
|
213
|
+
previews without scripts.
|
|
214
|
+
|
|
215
|
+
The frame is as tall as the content plus `buffer`, up to the window's height,
|
|
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
|
|
219
|
+
`theme.styles.Preview.Frame` instead.
|
|
162
220
|
|
|
163
221
|
```mdx
|
|
164
222
|
<Preview
|
|
165
223
|
title="Library select"
|
|
166
|
-
|
|
224
|
+
buffer="15rem"
|
|
167
225
|
html={"<acme-select label='Fruit'></acme-select>"}
|
|
168
226
|
scripts={["/demo/select.js"]}
|
|
169
227
|
/>
|
|
228
|
+
|
|
229
|
+
<Preview
|
|
230
|
+
title="Library dialog"
|
|
231
|
+
height="24rem"
|
|
232
|
+
html={"<acme-dialog open>Saved</acme-dialog>"}
|
|
233
|
+
scripts={["/demo/dialog.js"]}
|
|
234
|
+
/>
|
|
170
235
|
```
|
|
171
236
|
|
|
237
|
+
Don't size the content by the frame, for example with `100vh` or
|
|
238
|
+
`height: 100%` on the root element: the frame can't fit such content, and it
|
|
239
|
+
can grow to the window's height.
|
|
240
|
+
|
|
241
|
+
### Forms
|
|
242
|
+
|
|
172
243
|
Forms in a preview can be submitted. To show what a form sends, call
|
|
173
244
|
`event.preventDefault()` in a `submit` listener and read its `FormData`;
|
|
174
245
|
otherwise the submission navigates the frame away from the demo. The
|
|
@@ -202,62 +273,95 @@ origin.
|
|
|
202
273
|
`Logo` renders the Cookbook mark. Use `label` when it carries meaning or
|
|
203
274
|
`decorative` beside nearby text that already names the site. To display your
|
|
204
275
|
own artwork in the header and drawer, configure
|
|
205
|
-
[`site.logo`](./
|
|
276
|
+
[`site.logo`](./theme-and-components.md#logo-and-favicon).
|
|
206
277
|
|
|
207
|
-
##
|
|
278
|
+
## Code fences
|
|
208
279
|
|
|
209
|
-
|
|
210
|
-
|
|
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:
|
|
211
283
|
|
|
212
284
|
```diff
|
|
213
285
|
-formatOkhsl(v.h, v.s * 100, l * 100);
|
|
214
286
|
+formatOkhsl(v.h, v.s, l);
|
|
215
287
|
```
|
|
216
288
|
|
|
289
|
+
A `mermaid` fence renders a static, theme-aware diagram; see
|
|
290
|
+
[Mermaid diagrams](./configuration.md#markdown).
|
|
291
|
+
|
|
217
292
|
## Component props
|
|
218
293
|
|
|
219
|
-
| Component
|
|
220
|
-
|
|
|
221
|
-
| `
|
|
222
|
-
| `
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
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 |
|
|
225
304
|
|
|
226
305
|
The public package exports each component's props type, such as `TabProps`,
|
|
227
306
|
`CalloutProps`, and `CodeGroupProps`. Styles and all named sub-elements are
|
|
228
|
-
listed in [Component styles](./component-styles.md#
|
|
307
|
+
listed in [Component styles](./component-styles.md#complete-component-anatomy).
|
|
229
308
|
|
|
230
309
|
## On-page navigation
|
|
231
310
|
|
|
232
|
-
Desktop pages show a table of contents
|
|
233
|
-
|
|
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:
|
|
234
315
|
|
|
235
|
-
```
|
|
236
|
-
tableOfContents:
|
|
316
|
+
```yaml
|
|
317
|
+
tableOfContents:
|
|
318
|
+
mobile: true
|
|
319
|
+
maxHeadingLevel: 4
|
|
237
320
|
```
|
|
238
321
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
list
|
|
244
|
-
Customize `theme.styles.
|
|
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`.
|
|
245
329
|
|
|
246
|
-
## Hero
|
|
330
|
+
## Hero
|
|
247
331
|
|
|
248
|
-
|
|
249
|
-
|
|
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:
|
|
250
334
|
|
|
251
335
|
```yaml
|
|
336
|
+
template: splash
|
|
252
337
|
hero:
|
|
253
|
-
|
|
338
|
+
title: Build something useful
|
|
339
|
+
tagline: Documentation that stays with the code.
|
|
254
340
|
image:
|
|
255
341
|
file: ./assets/hero.png
|
|
256
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
|
|
257
350
|
```
|
|
258
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.
|
|
259
360
|
Use `light` and `dark` instead of `file` for appearance variants; both must have
|
|
260
361
|
the same aspect ratio. Remote or public-path images require explicit `width` and
|
|
261
|
-
`height
|
|
262
|
-
|
|
263
|
-
|
|
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
|
|
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
|
|
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
|
|
73
|
-
production site URL is a warning:
|
|
74
|
-
|
|
75
|
-
This checks output and hosting;
|
|
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
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
| `--
|
|
118
|
-
| `--
|
|
119
|
-
| `--
|
|
120
|
-
| `--
|
|
121
|
-
| `--
|
|
122
|
-
| `--
|
|
123
|
-
| `--
|
|
124
|
-
| `--
|
|
125
|
-
| `--
|
|
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
|
|
130
|
-
|
|
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.
|