@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
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
title: Custom components
|
|
3
3
|
description: Style your Astro and MDX components with Tasty and validate their tokens and parts.
|
|
4
4
|
---
|
|
5
|
-
Use this guide
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Use this guide when you need markup beyond Cookbook's built-in surfaces. For
|
|
6
|
+
ordinary visual changes, start with the [theme guide](./theme-and-components.md)
|
|
7
|
+
and the [component styles](./component-styles.md) reference.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Styling exports
|
|
10
10
|
|
|
11
11
|
Import styling tools from `@tenphi/cookbook/styling`. They use the same Tasty
|
|
12
12
|
runtime as Cookbook, with its semantic colors, typography presets, units, and
|
|
@@ -31,13 +31,13 @@ is needed for static components. Set shared tokens, presets, and states in
|
|
|
31
31
|
modules; configuration files should import `defineDocsConfig()` from
|
|
32
32
|
`@tenphi/cookbook/config`.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
## Define a named component
|
|
35
35
|
|
|
36
36
|
For a component used by your pages, give its root a name and define its parts
|
|
37
37
|
inside the same style object:
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
|
-
//
|
|
40
|
+
// docs/components/StatusBadge.ts
|
|
41
41
|
import { defineComponent } from "@tenphi/cookbook/styling";
|
|
42
42
|
|
|
43
43
|
export const StatusBadge = defineComponent("StatusBadge", {
|
|
@@ -45,7 +45,7 @@ export const StatusBadge = defineComponent("StatusBadge", {
|
|
|
45
45
|
styles: {
|
|
46
46
|
display: "inline-flex",
|
|
47
47
|
padding: "0.5x 1x",
|
|
48
|
-
radius: "
|
|
48
|
+
radius: "1r",
|
|
49
49
|
fill: "#surface-2",
|
|
50
50
|
color: "#text",
|
|
51
51
|
preset: "small",
|
|
@@ -69,158 +69,6 @@ theme: {
|
|
|
69
69
|
merges it with the base styles while rendering on the server. Document the
|
|
70
70
|
root name and every named part when sharing a custom component.
|
|
71
71
|
|
|
72
|
-
### A shared site logo
|
|
73
|
-
|
|
74
|
-
Set `site.logo` once to use your artwork in the header and mobile drawer:
|
|
75
|
-
|
|
76
|
-
```ts
|
|
77
|
-
site: {
|
|
78
|
-
title: "Acme",
|
|
79
|
-
logo: "./assets/acme.svg"
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Paths are local files relative to the resolved project root, just like
|
|
84
|
-
`site.favicon`. Cookbook reads the intrinsic dimensions and copies the image to
|
|
85
|
-
a content-hashed URL under the deployment base. SVG, PNG, JPEG, WebP, AVIF, and
|
|
86
|
-
GIF are supported. Missing or invalid files fail during setup.
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
site: {
|
|
90
|
-
title: "Acme",
|
|
91
|
-
logo: {
|
|
92
|
-
light: "./assets/acme-light.svg",
|
|
93
|
-
dark: "./assets/acme-dark.svg",
|
|
94
|
-
alt: "Acme documentation",
|
|
95
|
-
href: "/",
|
|
96
|
-
decorative: true
|
|
97
|
-
},
|
|
98
|
-
favicon: "./assets/acme-icon.svg"
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Use `src` for one image, or both `light` and `dark`. Variants follow the
|
|
103
|
-
appearance control and the system preference in Auto mode. They must share an
|
|
104
|
-
aspect ratio to prevent layout shifts. Optional `width` and `height` describe
|
|
105
|
-
intrinsic dimensions; Tasty controls display size. Customize
|
|
106
|
-
`theme.styles.SiteLogo` and its complete anatomy: `Image`, `Light`, and `Dark`.
|
|
107
|
-
Wide wordmarks retain their proportions within the header.
|
|
108
|
-
|
|
109
|
-
The logo is decorative by default because the neighboring title labels the
|
|
110
|
-
site. Set `decorative: false` and `alt` when the image itself carries meaningful
|
|
111
|
-
text. The header logo link still has a name when the image is decorative.
|
|
112
|
-
`href` defaults to the localized documentation home; it accepts a root-relative
|
|
113
|
-
documentation route or HTTP(S) destination. The header title and drawer use the
|
|
114
|
-
same destination. `site.logo: false` removes the mark from both locations.
|
|
115
|
-
|
|
116
|
-
A logo does not change the favicon or touch icons. Configure `site.favicon`
|
|
117
|
-
separately for square artwork; the default Cookbook icon set remains in place
|
|
118
|
-
until changed. `Logo` remains available as the standalone Cookbook book mark.
|
|
119
|
-
|
|
120
|
-
The built-in mark uses `theme.palette["logo-surface"]` and `theme.palette["logo-mark"]`.
|
|
121
|
-
The default homepage hero artwork also uses `logo-surface` for its brand fill.
|
|
122
|
-
Both default to Glaze `mode: "fixed"`: the brand background and light book keep
|
|
123
|
-
their polarity in dark mode while respecting Glaze's tone boundaries and
|
|
124
|
-
high-contrast settings. The mark-to-background contrast floor is 3:1 normally
|
|
125
|
-
and 4.5:1 in high contrast. These colors are separate from interactive accents.
|
|
126
|
-
For example, to customize the logo background while retaining brand hue:
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
theme: {
|
|
130
|
-
brand: { from: "#315efb" },
|
|
131
|
-
palette: {
|
|
132
|
-
"logo-surface": {
|
|
133
|
-
base: "logo-mark",
|
|
134
|
-
tone: 40,
|
|
135
|
-
saturation: 0.8,
|
|
136
|
-
mode: "fixed",
|
|
137
|
-
contrast: { wcag: [3, 4.5] },
|
|
138
|
-
},
|
|
139
|
-
"logo-mark": { tone: 100, saturation: 0, mode: "fixed" },
|
|
140
|
-
},
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Custom image assets keep their authored colors; use `light`/`dark` files when
|
|
145
|
-
you want distinct artwork. Header and drawer home links center logos with the
|
|
146
|
-
site title regardless of their aspect ratio. Use `theme.styles.SiteLogo` for
|
|
147
|
-
image size and `theme.styles.Header.SiteTitle` / `Sidebar.HomeLink`
|
|
148
|
-
for typography; they do not need baseline offsets for a different preset.
|
|
149
|
-
|
|
150
|
-
### Advanced site title markup
|
|
151
|
-
|
|
152
|
-
To put your own logo and title in one home link, create
|
|
153
|
-
`docs/components/site-title.ts`:
|
|
154
|
-
|
|
155
|
-
```ts
|
|
156
|
-
import { defineComponent } from "@tenphi/cookbook/styling";
|
|
157
|
-
|
|
158
|
-
export const SiteTitleRoot = defineComponent("ProjectSiteTitle", {
|
|
159
|
-
as: "a",
|
|
160
|
-
styles: {
|
|
161
|
-
display: "flex",
|
|
162
|
-
alignItems: "center",
|
|
163
|
-
gap: "1x",
|
|
164
|
-
inlineSize: "min 0",
|
|
165
|
-
color: "#text",
|
|
166
|
-
preset: { "": "h4 / strong", "!@md": "h5 / strong" },
|
|
167
|
-
textDecoration: "none",
|
|
168
|
-
Logo: {
|
|
169
|
-
$: "> svg",
|
|
170
|
-
display: "block",
|
|
171
|
-
flexShrink: "0",
|
|
172
|
-
inlineSize: { "": "2rem", "!@md": "1.75rem" },
|
|
173
|
-
blockSize: { "": "2rem", "!@md": "1.75rem" },
|
|
174
|
-
color: "#accent-text",
|
|
175
|
-
},
|
|
176
|
-
Label: {
|
|
177
|
-
$: "> span",
|
|
178
|
-
inlineSize: "min 0",
|
|
179
|
-
overflow: "hidden",
|
|
180
|
-
textOverflow: "ellipsis",
|
|
181
|
-
whiteSpace: "nowrap",
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Then create `docs/components/SiteTitle.astro`, using an SVG whose paths use
|
|
188
|
-
`currentColor` to follow the semantic accent color:
|
|
189
|
-
|
|
190
|
-
```astro
|
|
191
|
-
---
|
|
192
|
-
import ProjectLogo from "../../public/logo.svg";
|
|
193
|
-
import { SiteTitleRoot } from "./site-title.js";
|
|
194
|
-
|
|
195
|
-
const { siteTitle, siteTitleHref } = Astro.locals.cookbookRoute;
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
<SiteTitleRoot href={siteTitleHref}>
|
|
199
|
-
<ProjectLogo aria-hidden="true" focusable="false" />
|
|
200
|
-
<span translate="no">{siteTitle}</span>
|
|
201
|
-
</SiteTitleRoot>
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Register the replacement in `docs.config.ts` and disable the shared mark.
|
|
205
|
-
A `SiteTitle` override affects the header; use `site.logo` above for ordinary
|
|
206
|
-
branding shared with the drawer. For custom drawer markup, override `Sidebar`.
|
|
207
|
-
The custom component supports root styles plus its complete list of named
|
|
208
|
-
sub-elements: `Logo` and `Label`.
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
site: { logo: false },
|
|
212
|
-
components: {
|
|
213
|
-
overrides: {
|
|
214
|
-
SiteTitle: "./docs/components/SiteTitle.astro"
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
theme: {
|
|
218
|
-
customStyles: {
|
|
219
|
-
ProjectSiteTitle: { Logo: { color: "#text" } }
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
72
|
`defineComponent(name, options)` accepts Tasty factory options and a name for
|
|
225
73
|
`theme.customStyles[name]`. It merges the configured partial style object before
|
|
226
74
|
creating the component, retaining the other base properties and responsive
|
|
@@ -238,7 +86,7 @@ and named sub-elements for owned anatomy, and modifiers/state maps for variants.
|
|
|
238
86
|
Root selectors may keep stable classes, such as `.project-note`, or use
|
|
239
87
|
`data-component`; avoid classes for sub-elements and modifiers.
|
|
240
88
|
|
|
241
|
-
|
|
89
|
+
## Extend a component
|
|
242
90
|
|
|
243
91
|
Use `extendComponent(name, base, options)` to inherit an existing Tasty
|
|
244
92
|
component's styles, props, variants, and compound parts:
|
|
@@ -250,9 +98,12 @@ export const ProjectButton = extendComponent("ProjectButton", Button, {
|
|
|
250
98
|
type: "button",
|
|
251
99
|
styles: {
|
|
252
100
|
padding: "1x 2x",
|
|
253
|
-
radius: "
|
|
254
|
-
fill:
|
|
255
|
-
|
|
101
|
+
radius: "1r",
|
|
102
|
+
fill: {
|
|
103
|
+
"": "#surface-2",
|
|
104
|
+
":hover": "#surface-2-hover",
|
|
105
|
+
":active": "#surface-2-pressed",
|
|
106
|
+
},
|
|
256
107
|
},
|
|
257
108
|
});
|
|
258
109
|
|
|
@@ -263,8 +114,8 @@ export const CompactButton = extendComponent("CompactButton", ProjectButton, {
|
|
|
263
114
|
|
|
264
115
|
`theme.styles.Button` customizes the shared foundation, including Cookbook's
|
|
265
116
|
search and mobile-menu buttons. `theme.customStyles.ProjectButton` and
|
|
266
|
-
`CompactButton` customize each derived component independently.
|
|
267
|
-
|
|
117
|
+
`CompactButton` customize each derived component independently. This example
|
|
118
|
+
adds a hover fill to both descendants.
|
|
268
119
|
|
|
269
120
|
The merge order is the base component's configured styles and selected variant,
|
|
270
121
|
the extension's styles, its named theme override, and styles passed while
|
|
@@ -281,7 +132,7 @@ type. To compose reusable style fragments without a component base, use
|
|
|
281
132
|
`mergeStyles(baseStyles, extensionStyles)`; a shallow spread replaces entire
|
|
282
133
|
nested sub-elements and state maps.
|
|
283
134
|
|
|
284
|
-
|
|
135
|
+
## Global style trees
|
|
285
136
|
|
|
286
137
|
For markup you do not render through a Tasty component, call
|
|
287
138
|
`useGlobalStyles()` during rendering. For example, this Astro component
|
|
@@ -310,6 +161,85 @@ useGlobalStyles(
|
|
|
310
161
|
`defineComponent`, `extendComponent`, and `resolveComponentStyles` read the same `theme.customStyles`
|
|
311
162
|
configuration; user configuration contains only the properties to change. Each custom style name must match a call to one of these helpers.
|
|
312
163
|
|
|
164
|
+
## Replace built-in markup
|
|
165
|
+
|
|
166
|
+
When the built-in markup does not fit, replace an Astro component through
|
|
167
|
+
`components.overrides`; see the [list of override names](./configuration.md#components).
|
|
168
|
+
An override owns its markup and behavior. For ordinary branding, configure
|
|
169
|
+
[`site.logo`](./theme-and-components.md#logo-and-favicon) instead.
|
|
170
|
+
|
|
171
|
+
For example, to put your own logo and title in one home link, create
|
|
172
|
+
`docs/components/site-title.ts`:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { defineComponent } from "@tenphi/cookbook/styling";
|
|
176
|
+
|
|
177
|
+
export const SiteTitleRoot = defineComponent("ProjectSiteTitle", {
|
|
178
|
+
as: "a",
|
|
179
|
+
styles: {
|
|
180
|
+
display: "flex",
|
|
181
|
+
alignItems: "center",
|
|
182
|
+
gap: "1x",
|
|
183
|
+
inlineSize: "min 0",
|
|
184
|
+
color: "#text",
|
|
185
|
+
preset: { "": "h4 / strong", "!@md": "h5 / strong" },
|
|
186
|
+
textDecoration: "none",
|
|
187
|
+
Logo: {
|
|
188
|
+
$: "> svg",
|
|
189
|
+
display: "block",
|
|
190
|
+
flexShrink: "0",
|
|
191
|
+
inlineSize: { "": "2rem", "!@md": "1.75rem" },
|
|
192
|
+
blockSize: { "": "2rem", "!@md": "1.75rem" },
|
|
193
|
+
color: "#accent-text",
|
|
194
|
+
},
|
|
195
|
+
Label: {
|
|
196
|
+
$: "> span",
|
|
197
|
+
inlineSize: "min 0",
|
|
198
|
+
overflow: "hidden",
|
|
199
|
+
textOverflow: "ellipsis",
|
|
200
|
+
whiteSpace: "nowrap",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Then create `docs/components/SiteTitle.astro`, using an SVG whose paths use
|
|
207
|
+
`currentColor` to follow the semantic accent color:
|
|
208
|
+
|
|
209
|
+
```astro
|
|
210
|
+
---
|
|
211
|
+
import ProjectLogo from "../../public/logo.svg";
|
|
212
|
+
import { SiteTitleRoot } from "./site-title.js";
|
|
213
|
+
|
|
214
|
+
const { siteTitle, siteTitleHref } = Astro.locals.cookbookRoute;
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
<SiteTitleRoot href={siteTitleHref}>
|
|
218
|
+
<ProjectLogo aria-hidden="true" focusable="false" />
|
|
219
|
+
<span translate="no">{siteTitle}</span>
|
|
220
|
+
</SiteTitleRoot>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Register the replacement in `docs.config.ts` and disable the shared mark.
|
|
224
|
+
A `SiteTitle` override affects the header; `site.logo` covers ordinary branding
|
|
225
|
+
shared with the drawer. For custom drawer markup, override `Sidebar`.
|
|
226
|
+
The custom component supports root styles plus its complete list of named
|
|
227
|
+
sub-elements: `Logo` and `Label`.
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
site: { logo: false },
|
|
231
|
+
components: {
|
|
232
|
+
overrides: {
|
|
233
|
+
SiteTitle: "./docs/components/SiteTitle.astro"
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
theme: {
|
|
237
|
+
customStyles: {
|
|
238
|
+
ProjectSiteTitle: { Logo: { color: "#text" } }
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
313
243
|
## Linting custom styles
|
|
314
244
|
|
|
315
245
|
`@tenphi/cookbook/eslint-plugin` re-exports the Tasty ESLint plugin together with
|
|
@@ -329,10 +259,12 @@ export default {
|
|
|
329
259
|
Renderer-only consumers can use `extends: "@tenphi/renderer"` instead.
|
|
330
260
|
The preset registers both Cookbook styling import paths, its built-in tokens,
|
|
331
261
|
units, responsive states, and typography presets. It also describes
|
|
332
|
-
`defineComponent`, `extendComponent`,
|
|
262
|
+
`defineComponent`, `extendComponent`, and `resolveComponentStyles`, so their inline
|
|
333
263
|
style objects, variants, and named sub-elements receive the same checks as
|
|
334
|
-
`tasty()` calls.
|
|
335
|
-
|
|
264
|
+
`tasty()` calls. The upstream plugin recognizes `mergeStyles` directly: its first
|
|
265
|
+
argument is a base style object, and later arguments are partial overrides that
|
|
266
|
+
may omit default state values and retain the safeguards against fixes that replace
|
|
267
|
+
base styles.
|
|
336
268
|
|
|
337
269
|
### ESLint
|
|
338
270
|
|
|
@@ -406,6 +338,22 @@ export default {
|
|
|
406
338
|
`extends` merges and deduplicates these arrays with the inherited configuration,
|
|
407
339
|
so list only your additions. It also inherits the styling helper signatures;
|
|
408
340
|
entries you add to `styleFunctions` override inherited signatures by function name.
|
|
341
|
+
|
|
342
|
+
To keep the list in sync with the theme automatically, build the validation
|
|
343
|
+
configuration from `docs.config.ts` instead:
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
// tasty.config.ts
|
|
347
|
+
import { createValidationConfig } from "@tenphi/cookbook/eslint-plugin";
|
|
348
|
+
import docs from "./docs.config";
|
|
349
|
+
|
|
350
|
+
export default createValidationConfig(docs.theme);
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
`createValidationConfig(theme)` adds the theme's tokens, palette colors (as
|
|
354
|
+
`#name` tokens), units, states, presets, and recipes to Cookbook's built-in
|
|
355
|
+
vocabulary.
|
|
356
|
+
|
|
409
357
|
The exported `validationConfig` object remains available for programmatic use.
|
|
410
358
|
The entry point also exports the upstream `StyleFunctionConfig` and
|
|
411
359
|
`ResolvedConfig` types for shared lint configurations. Additional imported
|
|
@@ -11,24 +11,28 @@ registries or internal helpers.
|
|
|
11
11
|
|
|
12
12
|
## Read the configuration first
|
|
13
13
|
|
|
14
|
-
Inspect `docs.config.ts`, `tasty.config.ts
|
|
14
|
+
Inspect `docs.config.ts`, `tasty.config.ts` (when the project has adopted style
|
|
15
|
+
linting), and the components you are changing.
|
|
15
16
|
Reuse the site's existing semantic colors, tokens, presets, responsive states,
|
|
16
17
|
and named sub-elements. Do not invent configuration names. Consult the complete
|
|
17
|
-
[component anatomy reference](./component-styles.md#
|
|
18
|
+
[component anatomy reference](./component-styles.md#complete-component-anatomy)
|
|
18
19
|
before overriding a built-in component.
|
|
19
20
|
|
|
20
21
|
## Choose the customization surface
|
|
21
22
|
|
|
22
|
-
| Change
|
|
23
|
-
|
|
|
24
|
-
| Brand and semantic colors
|
|
25
|
-
| Shared dimensions and spacing
|
|
26
|
-
| Font loading and family roles
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
23
|
+
| Change | Supported surface |
|
|
24
|
+
| --------------------------------------- | ------------------------------------------------------ |
|
|
25
|
+
| Brand and semantic colors | `theme.brand` and the supported `theme.palette` inputs |
|
|
26
|
+
| Shared dimensions and spacing | `theme.tokens` |
|
|
27
|
+
| Font loading and family roles | `theme.fonts` |
|
|
28
|
+
| Font delivery and caching | `theme.fontLoading` |
|
|
29
|
+
| Typography | `theme.presets` |
|
|
30
|
+
| Responsive conditions | `theme.states` |
|
|
31
|
+
| Glaze adaptation | `theme.glaze` and `theme.contrastLevel` |
|
|
32
|
+
| Custom units and reusable style bundles | `theme.units` and `theme.recipes` |
|
|
33
|
+
| Existing component appearance | Partial Tasty objects in `theme.styles.<Name>` |
|
|
34
|
+
| Custom component appearance | `defineComponent()` and `theme.customStyles.<Name>` |
|
|
35
|
+
| Markup or behavior | `components.overrides` with an owned Astro component |
|
|
32
36
|
|
|
33
37
|
Prefer configuration changes when the markup and behavior already fit. Supply
|
|
34
38
|
only the properties you want to change: Cookbook merges partial overrides into
|
|
@@ -89,7 +93,7 @@ belong in `docs.config.ts`.
|
|
|
89
93
|
* When replacing a component, own its markup and behavior. Keep keyboard
|
|
90
94
|
access, focus, semantics, responsive behavior, and appearance modes intact.
|
|
91
95
|
|
|
92
|
-
The [custom component examples](./custom-components.md
|
|
96
|
+
The [custom component examples](./custom-components.md)
|
|
93
97
|
show both a component root and a global style tree using these APIs.
|
|
94
98
|
|
|
95
99
|
## Read the underlying references
|
|
@@ -144,7 +148,8 @@ the app that depends on Cookbook:
|
|
|
144
148
|
```md
|
|
145
149
|
Before customizing this Cookbook site, read
|
|
146
150
|
node_modules/@tenphi/cookbook/docs/customization-rules.md and follow its linked
|
|
147
|
-
Tasty and Glaze references. Inspect docs.config.ts and tasty.config.ts
|
|
151
|
+
Tasty and Glaze references. Inspect docs.config.ts (and tasty.config.ts, if
|
|
152
|
+
present) first.
|
|
148
153
|
Use Cookbook's public styling APIs, semantic palette tokens, typography
|
|
149
154
|
presets, and partial component overrides. Run the project's style lint,
|
|
150
155
|
cookbook doctor, and build commands after changes.
|
|
@@ -159,6 +164,10 @@ and extend its built-in vocabulary in `tasty.config.ts`:
|
|
|
159
164
|
export default { extends: "@tenphi/cookbook" };
|
|
160
165
|
```
|
|
161
166
|
|
|
167
|
+
To derive your theme's names automatically, use
|
|
168
|
+
[`createValidationConfig(docs.theme)`](./custom-components.md#custom-theme-names)
|
|
169
|
+
instead.
|
|
170
|
+
|
|
162
171
|
Run the configured style linter, `cookbook doctor`, and the site build. The
|
|
163
172
|
linter checks supported Tasty rules; it does not enforce every architectural
|
|
164
173
|
rule above or inspect arbitrary CSS. Review custom components at mobile and
|
package/docs/deployment.md
CHANGED
|
@@ -16,66 +16,116 @@ npm run validate
|
|
|
16
16
|
npm run preview
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
New projects include `validate`: preflight, production build,
|
|
20
|
-
checks. Existing projects can add
|
|
21
|
-
|
|
19
|
+
New projects include `validate`: type checking, preflight, production build,
|
|
20
|
+
then built-output checks. Existing projects can add
|
|
21
|
+
`"validate": "tsc --noEmit && cookbook doctor && astro build && cookbook check-build"`
|
|
22
|
+
to their `package.json` scripts. Run [`cookbook doctor`](./cli.md#validate-with-doctor)
|
|
23
|
+
alone for a faster preflight.
|
|
24
|
+
|
|
25
|
+
## Public URL and base path
|
|
26
|
+
|
|
27
|
+
Set `site.url` in `docs.config.ts` to the site's public HTTPS origin, such as
|
|
28
|
+
`https://docs.example.com`. A production build then gives every page a
|
|
29
|
+
canonical URL and creates a sitemap. Cookbook forwards the value to Astro's
|
|
30
|
+
`site`; if `astro.config.ts` also sets `site`, the two must match.
|
|
31
|
+
|
|
32
|
+
When the host serves the site below a path, such as
|
|
33
|
+
`https://owner.github.io/repository/`, set Astro's `base: "/repository/"` in
|
|
34
|
+
`astro.config.ts`. Cookbook derives its routes and assets from Astro's `base`,
|
|
35
|
+
so do not repeat the path in `docs.config.ts` routes.
|
|
36
|
+
|
|
37
|
+
Page URLs follow Astro's `trailingSlash` and `build.format`. The default
|
|
38
|
+
directory output writes `guide/index.html`, so links, canonicals, and `llms.txt`
|
|
39
|
+
use `/guide/`. `build.format: "file"` writes `guide.html` and uses `/guide`,
|
|
40
|
+
while the home remains the directory index at the base. `trailingSlash` set to
|
|
41
|
+
`"always"` or `"never"` overrides both. Either way, readers follow the URL the
|
|
42
|
+
host serves directly instead of a redirect.
|
|
22
43
|
|
|
23
44
|
## GitHub Pages
|
|
24
45
|
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
Create the project with `--deploy github-pages` to generate a GitHub Actions
|
|
47
|
+
workflow. For an app at the root of its repository, the creator writes
|
|
48
|
+
`.github/workflows/deploy.yml`. With npm, the workflow looks like this:
|
|
27
49
|
|
|
28
50
|
```yaml
|
|
51
|
+
name: Deploy documentation
|
|
52
|
+
|
|
53
|
+
on:
|
|
54
|
+
push:
|
|
55
|
+
branches: [main]
|
|
56
|
+
workflow_dispatch:
|
|
57
|
+
|
|
29
58
|
permissions:
|
|
59
|
+
actions: read
|
|
30
60
|
contents: read
|
|
31
61
|
pages: write
|
|
32
62
|
id-token: write
|
|
63
|
+
|
|
64
|
+
concurrency:
|
|
65
|
+
group: github-pages
|
|
66
|
+
cancel-in-progress: false
|
|
67
|
+
|
|
68
|
+
jobs:
|
|
69
|
+
build:
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/checkout@v7
|
|
73
|
+
- uses: actions/setup-node@v7
|
|
74
|
+
with:
|
|
75
|
+
node-version: 22
|
|
76
|
+
cache: npm
|
|
77
|
+
- run: npm ci
|
|
78
|
+
- run: npm run validate
|
|
79
|
+
- uses: actions/configure-pages@v6
|
|
80
|
+
- uses: actions/upload-pages-artifact@v5
|
|
81
|
+
with:
|
|
82
|
+
path: dist
|
|
83
|
+
|
|
84
|
+
deploy:
|
|
85
|
+
environment:
|
|
86
|
+
name: github-pages
|
|
87
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
88
|
+
runs-on: ubuntu-latest
|
|
89
|
+
needs: build
|
|
90
|
+
steps:
|
|
91
|
+
- name: Deploy to GitHub Pages
|
|
92
|
+
id: deployment
|
|
93
|
+
uses: actions/deploy-pages@v5
|
|
33
94
|
```
|
|
34
95
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
96
|
+
In the repository's Pages settings, select **GitHub Actions** as the source.
|
|
97
|
+
The `github-pages` environment keeps the deployment URL and protection rules
|
|
98
|
+
visible in the repository.
|
|
99
|
+
|
|
100
|
+
GitHub runs workflows only from the repository root's `.github/workflows/`.
|
|
101
|
+
When the app is created inside an existing Git repository, such as
|
|
102
|
+
`docs-site/` after `--source .`, the creator writes
|
|
103
|
+
`.github/workflows/deploy-docs.yml` at the repository root instead. That
|
|
104
|
+
workflow runs its commands in `docs-site`, caches dependencies from the app's
|
|
105
|
+
lockfile, and uploads `docs-site/dist`. The creator does not overwrite an
|
|
106
|
+
existing `deploy-docs.yml`; it stops before writing any files.
|
|
39
107
|
|
|
40
108
|
For an organization or user site, keep Astro's `base: "/"`. For a project site
|
|
41
109
|
served at `https://owner.github.io/repository/`, set Astro's
|
|
42
|
-
`base: "/repository/"
|
|
43
|
-
assets.
|
|
44
|
-
|
|
45
|
-
Page URLs follow Astro's `trailingSlash` and `build.format`. The default
|
|
46
|
-
directory output writes `guide/index.html`, so links, canonicals, and `llms.txt`
|
|
47
|
-
use `/guide/`. `build.format: "file"` writes `guide.html` and uses `/guide`,
|
|
48
|
-
while the home remains the directory index at the base. `trailingSlash` set to
|
|
49
|
-
`"always"` or `"never"` overrides both. Either way, readers follow the URL the
|
|
50
|
-
host serves directly instead of a redirect.
|
|
110
|
+
`base: "/repository/"`.
|
|
51
111
|
|
|
52
|
-
|
|
112
|
+
### Custom domains
|
|
53
113
|
|
|
54
|
-
Set
|
|
55
|
-
forwards it to Astro:
|
|
114
|
+
Set `site.url` to the custom HTTPS origin:
|
|
56
115
|
|
|
57
116
|
```ts
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
site: { url: "https://docs.example.com" },
|
|
63
|
-
},
|
|
64
|
-
}),
|
|
65
|
-
],
|
|
117
|
+
import { defineDocsConfig } from "@tenphi/cookbook/config";
|
|
118
|
+
|
|
119
|
+
export default defineDocsConfig({
|
|
120
|
+
site: { title: "Example", url: "https://docs.example.com" },
|
|
66
121
|
});
|
|
67
122
|
```
|
|
68
123
|
|
|
69
124
|
Configure the custom domain in the repository's Pages settings and point DNS
|
|
70
125
|
at the GitHub Pages host. For a custom Actions workflow, GitHub stores the
|
|
71
126
|
domain in the Pages settings; a `CNAME` file in the artifact is ignored and is
|
|
72
|
-
not required.
|
|
73
|
-
|
|
74
|
-
This site is deployed by the repository's Pages workflow to
|
|
75
|
-
`cookbook.tenphi.me` with HTTPS enforcement enabled.
|
|
76
|
-
The Cookbook repository deploys its own documentation only after a package
|
|
77
|
-
release. The release workflow creates a version tag and then starts the Pages
|
|
78
|
-
workflow from that tag, so the public reference matches the published code.
|
|
127
|
+
not required. A custom domain serves the site at the origin root, so keep
|
|
128
|
+
Astro's `base: "/"`.
|
|
79
129
|
|
|
80
130
|
## Other static hosts
|
|
81
131
|
|
|
@@ -90,30 +140,28 @@ gets `netlify.toml`. You can also use the host's ordinary static-site settings:
|
|
|
90
140
|
If the host serves the site below a path rather than at an origin root, set
|
|
91
141
|
Astro's `base`; Cookbook derives it automatically.
|
|
92
142
|
|
|
93
|
-
## Discovery
|
|
94
|
-
|
|
95
|
-
Set `site.url` to the public HTTPS origin before building. This enables canonical
|
|
96
|
-
page URLs and the sitemap. The build also emits `llms.txt` with links to
|
|
97
|
-
published documentation pages. At an origin root, it emits `robots.txt` pointing
|
|
98
|
-
to the sitemap. Host these files with the rest of `dist/`; custom files in
|
|
99
|
-
`public/` take precedence. For path-hosted sites, manage the origin's
|
|
100
|
-
`robots.txt` in the hosting configuration.
|
|
143
|
+
## Discovery files
|
|
101
144
|
|
|
102
|
-
|
|
103
|
-
|
|
145
|
+
The build emits `llms.txt` with links to published documentation pages and,
|
|
146
|
+
when `site.url` is set, a sitemap. At an origin root with `site.url` set, it
|
|
147
|
+
also emits `robots.txt` pointing to the sitemap. Host these files with the rest of
|
|
148
|
+
`dist/`; custom files in `public/` take precedence. For path-hosted sites,
|
|
149
|
+
manage the origin's `robots.txt` in the hosting configuration.
|
|
104
150
|
|
|
105
|
-
|
|
106
|
-
breadcrumbs, and
|
|
151
|
+
See [Publishing metadata](./publishing.md) for title templates, social images,
|
|
152
|
+
preview noindex, older-version policies, breadcrumbs, and Markdown downloads,
|
|
153
|
+
and [AI agents](./ai-agents.md) for how agents read the published site.
|
|
107
154
|
|
|
108
155
|
## Validate the published result
|
|
109
156
|
|
|
110
|
-
|
|
111
|
-
|
|
157
|
+
After the host finishes deploying, check the deployment against the same local
|
|
158
|
+
`dist/` output that was uploaded:
|
|
112
159
|
|
|
113
160
|
```sh
|
|
114
161
|
npx @tenphi/cookbook check-build --url https://docs.example.com/manual/
|
|
115
162
|
```
|
|
116
163
|
|
|
117
|
-
Use your actual deployment URL, including any base path
|
|
118
|
-
|
|
119
|
-
|
|
164
|
+
Use your actual deployment URL, including any base path. Then check the
|
|
165
|
+
deployed HTML, `sitemap-index.xml`, and `llms.txt` through their public URLs.
|
|
166
|
+
See [CLI checks](./cli.md#check-the-built-site-and-deployment) for the exact
|
|
167
|
+
coverage, warnings, JSON output, and custom output directories.
|
|
@@ -63,8 +63,6 @@ Cookbook incluye su renderizador Astro y detecta `docs.config.ts` automáticamen
|
|
|
63
63
|
|
|
64
64
|
## Configura el sitio
|
|
65
65
|
|
|
66
|
-
Empieza con las [recetas completas de marca, logotipo y fuentes](../recipes.md). Para cambios de estilo más detallados o componentes nuevos, consulta las [reglas de personalización](../customization-rules.md). Estas reglas y las referencias originales también se incluyen en el paquete instalado de Cookbook.
|
|
67
|
-
|
|
68
66
|
Crea `docs.config.ts` junto a `astro.config.ts`:
|
|
69
67
|
|
|
70
68
|
```ts
|
|
@@ -83,9 +81,11 @@ export default defineDocsConfig({
|
|
|
83
81
|
});
|
|
84
82
|
```
|
|
85
83
|
|
|
86
|
-
Cambia `theme.fonts` para usar [Google Fonts por nombre o tus propios archivos de fuentes](../fonts-and-typography.md). Usa `theme.presets` para los detalles tipográficos, `theme.styles` para los elementos integrados y `defineComponent()` con `theme.customStyles` para añadir elementos. La [guía del tema](../theme-and-components.md) es un punto de partida; la [referencia de estilos de componentes](../component-styles.md) enumera todas las partes personalizables.
|
|
84
|
+
Cambia `theme.fonts` para usar [Google Fonts por nombre o tus propios archivos de fuentes](../fonts-and-typography.md#change-font-families). Usa `theme.presets` para los detalles tipográficos, `theme.styles` para los elementos integrados y `defineComponent()` con `theme.customStyles` para añadir elementos. La [guía del tema](../theme-and-components.md) es un punto de partida; la [referencia de estilos de componentes](../component-styles.md) enumera todas las partes personalizables.
|
|
85
|
+
|
|
86
|
+
Para partir de una configuración completa, consulta las [recetas de marca, logotipo y fuentes](../recipes.md). Para cambios de estilo más detallados o componentes nuevos, consulta las [reglas de personalización](../customization-rules.md). Estas reglas y las referencias originales también se incluyen en el paquete instalado de Cookbook.
|
|
87
87
|
|
|
88
|
-
La integración y la CLI cargan la misma configuración. Se admiten `docs.config.ts`, `.mts`, `.js` y `.mjs`, en ese orden. Un objeto `config` explícito en la integración tiene prioridad; `configFile: false` desactiva la detección. Usa `cookbook({ configFile: "./config/manual.ts" })` y `cookbook doctor --config ./config/manual.ts` para una ubicación no estándar.
|
|
88
|
+
La integración y la CLI cargan la misma configuración. Se admiten `docs.config.ts`, `.mts`, `.js` y `.mjs`, en ese orden. Un objeto `config` explícito en la integración tiene prioridad; `configFile: false` desactiva la detección. Usa `cookbook({ configFile: "./config/manual.ts" })` y `cookbook doctor --config ./config/manual.ts` para una ubicación no estándar. Como `root` se resuelve desde el directorio del archivo de configuración, ese archivo necesita `root: ".."` para seguir leyendo `README.md` y `docs/` desde el directorio de la aplicación.
|
|
89
89
|
|
|
90
90
|
## Raíces de monorepositorios
|
|
91
91
|
|
|
@@ -106,4 +106,6 @@ npm run validate
|
|
|
106
106
|
npm run preview
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
`validate` comprueba los tipos del proyecto, ejecuta la verificación previa de Cookbook, compila el sitio y revisa el resultado. En un proyecto que configuraste tú mismo, añade los scripts de los [comandos de la CLI](../cli.md) o ejecuta `npx @tenphi/cookbook doctor`.
|
|
110
|
+
|
|
111
|
+
El resto de las guías se encuentra actualmente en inglés: [ejemplos](../examples.md), [componentes para redactar](../authoring.mdx), [flujo para agentes de IA](../ai-agents.md), [despliegue](../deployment.md) y [actualización entre versiones](../migration.md). Si falla la validación, consulta [solución de problemas](../troubleshooting.md).
|