@chassis-ui/docs 0.7.0 → 0.8.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/CHANGELOG.md +7 -0
- package/README.md +48 -6
- package/UPGRADING.md +76 -0
- package/package.json +2 -2
- package/src/cli/assets.js +57 -9
- package/src/cli/main.js +32 -5
- package/src/components/DocsSidebar.astro +100 -102
- package/src/components/FeatureCard.astro +5 -7
- package/src/components/TableOfContents.astro +10 -12
- package/src/components/ThemeToggler.astro +5 -2
- package/src/components/shortcodes/Blockquote.astro +11 -13
- package/src/components/shortcodes/CSSOnly.astro +3 -3
- package/src/components/shortcodes/Code.astro +104 -108
- package/src/components/shortcodes/DeprecatedIn.astro +1 -3
- package/src/components/shortcodes/Example.astro +29 -33
- package/src/components/shortcodes/Icon.astro +19 -21
- package/src/components/shortcodes/InFigma.astro +3 -3
- package/src/components/shortcodes/Placeholder.astro +14 -16
- package/src/components/shortcodes/ResizableExample.astro +3 -5
- package/src/layouts/BaseLayout.astro +14 -20
- package/src/layouts/DocsLayout.astro +51 -52
- package/src/layouts/footer/Consent.astro +18 -20
- package/src/layouts/footer/Footer.astro +57 -21
- package/src/layouts/head/Head.astro +7 -10
- package/src/layouts/header/Navigation.astro +71 -60
- package/src/layouts/header/SearchDialog.astro +10 -4
- package/src/layouts/header/SearchTrigger.astro +2 -4
- package/src/layouts/header/Skippy.astro +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @chassis-ui/docs
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **Breaking.** The pages load their fonts from the site's own static files, no longer from Google Fonts. `Head.astro` links `fonts/text.css`, `fonts/display.css` and `fonts/code.css` under the static path, `/static/` by default, in place of the Google Fonts stylesheet and the `preconnect` links to `fonts.googleapis.com` and `fonts.gstatic.com`. The three stylesheets and the font files they load are in the docs build of `chassis-assets`, which a site copies into `static/` already. A site moves its `vendor/assets` submodule to `acb5d2e` of `app/docs` or later, with `pnpm sync-submodules`: there the stylesheets declare Inter, Archivo Narrow and Fira Code as variable fonts, with every weight the styles use. With a commit before `77912ed` they declare four weights of each family. The Inter of the assets has an optical size axis, which the font of Google Fonts had not, and a browser follows it: text above 14 pixels is narrower, 7% at 57 pixels. A site keeps the look it had by building the assets with `--subset` of `chassis-docs vendor`, which fixes the axis at 14 from `acb5d2e` on, or by setting `font-optical-sizing: none` in its styles. A site that does not copy the docs build provides the three stylesheets itself.
|
|
8
|
+
- `chassis-docs vendor` and `chassis-docs sync-submodules` take `--subset <range>`, repeatable, and `--split` or `--no-split` with it. With `--subset` the fonts of the docs build of `chassis-assets` are written with the characters of the ranges only, such as `--subset latin --subset latin-ext`, and the optical size axis of Inter is fixed at 14, as `chassis-assets` sets it for the `chassis` brand. With `--split` each font is also written in a file per range, and its stylesheet names them with a `unicode-range`, so a page loads a range only when it has a character of it; without `--split` and `--no-split` the setting of `chassis-assets` decides, which is one file. With the two ranges and the split, a page in English loads `text-latin.woff2`, 69 KB, where the whole `text.woff2` is 349 KB, and `code-latin.woff2`, 43 KB, where `code.woff2` is 109 KB. A character outside the ranges is drawn with the next font of the font stack. With `--subset` the commands run `pnpm install --filter ./packages/assets --prod` in the submodule, in place of `pnpm install --ignore-workspace`, since the build loads a package to subset a font. The options need `vendor/assets` at `acb5d2e` of `app/docs` or later. Without them nothing changes.
|
|
9
|
+
|
|
3
10
|
## 0.7.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
> [!NOTE] This package is developed inside the [`chassis-website`](https://github.com/chassis-ui/website) monorepo at `packages/docs/` and published to npm. Source, issues, and pull requests live in that repository.
|
|
12
12
|
|
|
13
|
-
Coming from
|
|
13
|
+
Coming from an earlier version? See [UPGRADING.md](UPGRADING.md).
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -184,18 +184,43 @@ export const collections = {
|
|
|
184
184
|
|
|
185
185
|
The layouts link to files under `/static/`, which the site puts into `static/` of its `public` directory:
|
|
186
186
|
|
|
187
|
-
| URL
|
|
188
|
-
|
|
|
189
|
-
| `/static/css/chassis.css`, `/static/css/chassis.min.css`
|
|
190
|
-
| `/static/icons/chassis-icons.svg`, `/static/icons/chassis-icons.css`
|
|
191
|
-
| `/static/images
|
|
187
|
+
| URL | From |
|
|
188
|
+
| ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
|
|
189
|
+
| `/static/css/chassis.css`, `/static/css/chassis.min.css` | the `dist` folder of `@chassis-ui/css` |
|
|
190
|
+
| `/static/icons/chassis-icons.svg`, `/static/icons/chassis-icons.css` | the `icons` folder of `@chassis-ui/icons` |
|
|
191
|
+
| `/static/images/site-logo.svg`, the logo of the navigation bar and the footer | the docs build of `chassis-assets` |
|
|
192
|
+
| `/static/images/favicon.png`, `favicon-16x16.png`, `favicon-32x32.png` and `apple-touch-icon.png` | the docs build of `chassis-assets` |
|
|
193
|
+
| `/static/images/social-image.png`, the image of a page without a `thumbnail`. The build reads its size, and fails without the file | the docs build of `chassis-assets` |
|
|
194
|
+
| `/static/fonts/text.css`, `/static/fonts/display.css`, `/static/fonts/code.css`, and the font files they load | the docs build of `chassis-assets` |
|
|
195
|
+
| `/static/images/manifest.json`, the web app manifest | the site itself. The starter has one in `static/images/` |
|
|
192
196
|
|
|
193
197
|
`chassis-docs vendor` builds the docs build of `chassis-assets` in the `vendor/assets` submodule. See [Commands](#commands).
|
|
194
198
|
|
|
199
|
+
Nothing else of the docs build is read by the package. A site copies the whole build into `static/`, and its own pages may read more of it.
|
|
200
|
+
|
|
195
201
|
These helpers find the folders, whether `node_modules` is in the site's root or in the root of the repository: `getChassisCSSFsPath()`, `getChassisIconsFsPath()`, `getChassisAssetsFsPath()` and `getChassisTokensFsPath()`. Each takes `{ root, dir }`.
|
|
196
202
|
|
|
197
203
|
A site that type-checks with `astro check` declares the `@chassis-ui/css` module, which has no types: `declare module '@chassis-ui/css'`.
|
|
198
204
|
|
|
205
|
+
#### What the Chassis sites read from the docs build
|
|
206
|
+
|
|
207
|
+
The sites of the Chassis projects read these files besides, by name, from the docs build of the `chassis` brand:
|
|
208
|
+
|
|
209
|
+
| File of the docs build | Read by |
|
|
210
|
+
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
|
|
211
|
+
| `icons/cx-sprite.svg` | The home page of each of the seven sites, which imports it. The build fails without it |
|
|
212
|
+
| `images/apple-touch-icon.png`, `images/favicon.png` | Each of the seven sites, which copies them to `/apple-touch-icon.png` and `/favicon.ico` |
|
|
213
|
+
| `images/android-chrome-192x192.png`, `images/android-chrome-512x512.png` | The `manifest.json` of each of the seven sites |
|
|
214
|
+
| `images/home/` | The home page of the website. The home page of chassis-tokens reads `comp-gallery-*` of it |
|
|
215
|
+
| `images/logo/chassis-{logo,icon}-{brand,white}-banner.svg` | The about page of the website |
|
|
216
|
+
| `images/social-image.png` | The blog of the website, for a post without an image |
|
|
217
|
+
| `images/site-logo.svg` | The examples of the navbar page of chassis-css. The README of `@chassis-ui/react`, by its URL on chassis-ui.com |
|
|
218
|
+
| `images/figma/components/` | The component pages of chassis-figma |
|
|
219
|
+
|
|
220
|
+
The vanilla HTML example, in the `vanilla-example` repository, builds the assets itself from a `vendor/assets` submodule of its own, for the brand of each of its sites, and takes `fonts/text.css`, `fonts/display.css` and `fonts/code.css`, the font files they load, the license of each font and `images/logo/chassis-icon-brand.svg`.
|
|
221
|
+
|
|
222
|
+
`contracts` in `chassis.checks.json` of `chassis-assets` names the files that a site reads, with the code that reads each, and `pnpm assets:contract` there checks a build against it.
|
|
223
|
+
|
|
199
224
|
#### A site under a prefix
|
|
200
225
|
|
|
201
226
|
A site that is served under a path of another host, such as `chassis-ui.com/css`, cannot use `/static/` there: that path belongs to the host's own site. It loads its static files under a path of its own instead:
|
|
@@ -292,6 +317,22 @@ The package installs a `chassis-docs` command with the build steps that every Ch
|
|
|
292
317
|
|
|
293
318
|
`vendor` and `sync-submodules` work from any folder of the repository. They need Git, Git LFS and pnpm. `sync-submodules --branch <name>`, or the `SUBMODULE_BRANCH` variable, follows another branch.
|
|
294
319
|
|
|
320
|
+
Both take `--subset <range>`, which writes the fonts of the build with the characters of the range only, so that a page downloads smaller font files. A range is a name that `chassis-assets` knows, such as `latin` or `latin-ext`, or a range written as `U+0370-03FF`, and the option is repeatable:
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
{
|
|
324
|
+
"scripts": {
|
|
325
|
+
"vendor": "chassis-docs vendor --subset latin --subset latin-ext --split"
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
A character outside the ranges is drawn with the next font of the font stack. With the option, the commands install the package of the build in the submodule, `pnpm install --filter ./packages/assets --prod`, in place of `pnpm install --ignore-workspace`: it holds the package that subsets a font.
|
|
331
|
+
|
|
332
|
+
`--subset` also fixes the axes of a variable font that `chassis-assets` names for the brand: the optical size of Inter at 14, so that text has the width it had with Google Fonts. A site that builds without `--subset` sets `font-optical-sizing: none` in its styles for the same look.
|
|
333
|
+
|
|
334
|
+
`--split`, with `--subset`, writes each font in a file per range as well, such as `text-latin.woff2` and `text-latin-ext.woff2`, and the stylesheets name them with a `unicode-range`: a page loads the file of a range only when it has a character of it. `--no-split` writes one file per font. Without either, the setting of `chassis-assets` decides, which is one file.
|
|
335
|
+
|
|
295
336
|
Each command exits with 1 when it fails, so a script or CI job stops there.
|
|
296
337
|
|
|
297
338
|
### Validating HTML
|
|
@@ -376,6 +417,7 @@ The integration provides five modules: `virtual:chassis-docs/config`, `virtual:c
|
|
|
376
417
|
|
|
377
418
|
| `@chassis-ui/docs` | Requires Astro | Requires `@chassis-ui/css` | Requires Node | Built with |
|
|
378
419
|
| ------------------ | -------------------------- | -------------------------- | ------------- | ------------------------------------ |
|
|
420
|
+
| 0.8.0 | `^7.0.0` | `>=0.6.0` | `>=22.12.0` | Astro 7.3.5, css 0.7.1, tokens 0.7.0 |
|
|
379
421
|
| 0.7.0 | `^7.0.0` | `>=0.6.0` | `>=22.12.0` | Astro 7.3.5, css 0.6.0, tokens 0.6.0 |
|
|
380
422
|
| 0.6.3 | `^7.0.0` | `^0.5.0-0` | `>=22.12.0` | Astro 7.3.5, css 0.5.2, tokens 0.6.0 |
|
|
381
423
|
| 0.6.2 | `^7.0.0` | `^0.5.0-0` | `>=22.12.0` | Astro 7.3.5, css 0.5.2, tokens 0.6.0 |
|
package/UPGRADING.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
1
|
# Upgrading @chassis-ui/docs
|
|
2
2
|
|
|
3
|
+
## From 0.7 to 0.8
|
|
4
|
+
|
|
5
|
+
0.8.0 loads the fonts from the site's own static files, no longer from Google Fonts. The
|
|
6
|
+
head of every page links `fonts/text.css`, `fonts/display.css` and `fonts/code.css` under
|
|
7
|
+
the static path, `/static/` by default. The three stylesheets and the font files they load
|
|
8
|
+
are in the docs build of `chassis-assets`, which a site copies into `static/` already.
|
|
9
|
+
|
|
10
|
+
### 1. Update the dependency
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pnpm add -D @chassis-ui/docs@^0.8.0
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 2. Move the `vendor/assets` submodule
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm sync-submodules
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The pages need `vendor/assets` at `acb5d2e` of `app/docs` or later: there the stylesheets
|
|
23
|
+
declare Inter, Archivo Narrow and Fira Code as variable fonts, with every weight the styles
|
|
24
|
+
use. With a commit before `77912ed` they declare four weights of each family. Commit the
|
|
25
|
+
new pointer.
|
|
26
|
+
|
|
27
|
+
A site that does not copy the docs build provides the three stylesheets itself, at the
|
|
28
|
+
same paths.
|
|
29
|
+
|
|
30
|
+
### 3. Subset the fonts
|
|
31
|
+
|
|
32
|
+
Add `--subset` and `--split` to the `vendor` and `sync-submodules` scripts:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"scripts": {
|
|
37
|
+
"vendor": "chassis-docs vendor --subset latin --subset latin-ext --split",
|
|
38
|
+
"sync-submodules": "chassis-docs sync-submodules --subset latin --subset latin-ext --split"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The step is optional, and it does two things:
|
|
44
|
+
|
|
45
|
+
- The fonts hold the characters of the ranges only, each range in a file of its own that a
|
|
46
|
+
page loads when it has a character of it. A page in English loads `text-latin.woff2`,
|
|
47
|
+
69 KB, where the whole `text.woff2` is 349 KB. A character outside the ranges is drawn
|
|
48
|
+
with the next font of the font stack, so name the range of every script your pages use:
|
|
49
|
+
a name that `chassis-assets` knows, or a range written as `U+0370-03FF`. See
|
|
50
|
+
[Commands](README.md#commands) in the README.
|
|
51
|
+
- The optical size axis of Inter is fixed at 14. See "What changes on the pages" below.
|
|
52
|
+
|
|
53
|
+
With `--subset` the commands install the package of the build in the submodule, which
|
|
54
|
+
holds the package that subsets a font.
|
|
55
|
+
|
|
56
|
+
### 4. Remove Google Fonts from your policy and your privacy page
|
|
57
|
+
|
|
58
|
+
No page requests `fonts.googleapis.com` or `fonts.gstatic.com` any more. Remove the two
|
|
59
|
+
hosts from a content security policy of your own, and a sentence about Google Fonts from a
|
|
60
|
+
privacy page. The sites under chassis-ui.com have the policy of the website, which no
|
|
61
|
+
longer allows the two hosts.
|
|
62
|
+
|
|
63
|
+
### What changes on the pages
|
|
64
|
+
|
|
65
|
+
- **Inter follows its optical size axis.** The Inter of the assets has the axis, which the
|
|
66
|
+
font of Google Fonts had not, and a browser follows it: text above 14 pixels is narrower,
|
|
67
|
+
7% at 57 pixels. Step 3 fixes the axis at 14, so text has the width it had. A site that
|
|
68
|
+
builds without `--subset` sets `font-optical-sizing: none` in its styles for the same
|
|
69
|
+
look.
|
|
70
|
+
- **Inter has an italic file.** Italic text was drawn by slanting the upright font.
|
|
71
|
+
- **The head has no `preconnect` links** to the two hosts of Google Fonts.
|
|
72
|
+
|
|
73
|
+
### Check the result
|
|
74
|
+
|
|
75
|
+
Build the site before and after the upgrade and compare the pages in a browser. With
|
|
76
|
+
step 3 the text keeps its width, so nothing moves. Check in the network panel that no
|
|
77
|
+
request goes to `fonts.googleapis.com` or `fonts.gstatic.com`.
|
|
78
|
+
|
|
3
79
|
## From 0.6 to 0.7
|
|
4
80
|
|
|
5
81
|
0.7.0 needs `@chassis-ui/css` 0.6.0 or later. The layouts use the CSS grid of that version,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chassis-ui/docs",
|
|
3
3
|
"description": "Shared Astro components and layouts for Chassis documentation sites.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@astrojs/markdown-remark": "^7.3.1",
|
|
110
|
-
"@chassis-ui/css": "^0.
|
|
110
|
+
"@chassis-ui/css": "^0.7.1",
|
|
111
111
|
"@pagefind/component-ui": "^1.5.2",
|
|
112
112
|
"@shikijs/transformers": "^4.5.0",
|
|
113
113
|
"astro": "^7.3.5",
|
package/src/cli/assets.js
CHANGED
|
@@ -11,6 +11,9 @@ export const ASSETS_OUTPUT = 'dist/web/docs/chassis'
|
|
|
11
11
|
/** The branch of chassis-assets that the docs sites follow. */
|
|
12
12
|
export const DEFAULT_BRANCH = 'app/docs'
|
|
13
13
|
|
|
14
|
+
/** The package of the build inside the submodule, which names the packages its options load. */
|
|
15
|
+
export const ASSETS_PACKAGE = './packages/assets'
|
|
16
|
+
|
|
14
17
|
/**
|
|
15
18
|
* The root of the repository that contains the working directory, so that the commands
|
|
16
19
|
* work from a site's folder too.
|
|
@@ -22,24 +25,34 @@ function repositoryRoot(run) {
|
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* Checks out `vendor/assets` at the commit that the repository pins, and builds it.
|
|
25
|
-
* @param {{ root?: string, run?: typeof defaultRun }} [options]
|
|
28
|
+
* @param {{ root?: string, subset?: string[], split?: boolean, run?: typeof defaultRun }} [options]
|
|
26
29
|
*/
|
|
27
|
-
export function buildAssets({
|
|
30
|
+
export function buildAssets({
|
|
31
|
+
run = defaultRun,
|
|
32
|
+
root = repositoryRoot(run),
|
|
33
|
+
subset = [],
|
|
34
|
+
split
|
|
35
|
+
} = {}) {
|
|
36
|
+
const fonts = fontOptions(subset, split)
|
|
37
|
+
|
|
28
38
|
log(`Building ${ASSETS_PATH} at the pinned commit`)
|
|
29
39
|
run('git', ['submodule', 'update', '--init', ASSETS_PATH], { cwd: root })
|
|
30
|
-
buildCheckout(root, run)
|
|
40
|
+
buildCheckout(root, run, fonts)
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
/**
|
|
34
44
|
* Moves `vendor/assets` to the latest commit of `branch`, and builds it. The repository
|
|
35
45
|
* then has a changed submodule pointer to commit.
|
|
36
|
-
* @param {{ root?: string, branch?: string, run?: typeof defaultRun }} [options]
|
|
46
|
+
* @param {{ root?: string, branch?: string, subset?: string[], split?: boolean, run?: typeof defaultRun }} [options]
|
|
37
47
|
*/
|
|
38
48
|
export function syncAssets({
|
|
39
49
|
run = defaultRun,
|
|
40
50
|
root = repositoryRoot(run),
|
|
41
|
-
branch = DEFAULT_BRANCH
|
|
51
|
+
branch = DEFAULT_BRANCH,
|
|
52
|
+
subset = [],
|
|
53
|
+
split
|
|
42
54
|
} = {}) {
|
|
55
|
+
const fonts = fontOptions(subset, split)
|
|
43
56
|
const dir = path.join(root, ASSETS_PATH)
|
|
44
57
|
const git = (args, quiet = true) => run('git', args, { cwd: dir, quiet })
|
|
45
58
|
|
|
@@ -68,7 +81,7 @@ export function syncAssets({
|
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
git(['pull', '--ff-only', 'origin', branch])
|
|
71
|
-
buildCheckout(root, run)
|
|
84
|
+
buildCheckout(root, run, fonts)
|
|
72
85
|
|
|
73
86
|
const commit = git(['rev-parse', '--short', 'HEAD']).trim()
|
|
74
87
|
const moved = run('git', ['status', '--porcelain', '--', ASSETS_PATH], {
|
|
@@ -92,14 +105,49 @@ function hasLocalBranch(git, branch) {
|
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
/**
|
|
109
|
+
* The options of the build for the fonts: the ranges of `--subset`, then `--split` or
|
|
110
|
+
* `--no-split` when the site decides it, and nothing when the fonts stay whole. Without
|
|
111
|
+
* either of the two, the build takes `split` of `chassis.subset` of chassis-assets.
|
|
112
|
+
* @param {string[]} subset
|
|
113
|
+
* @param {boolean} [split]
|
|
114
|
+
* @returns {string[]}
|
|
115
|
+
*/
|
|
116
|
+
function fontOptions(subset, split) {
|
|
117
|
+
if (subset.length === 0) {
|
|
118
|
+
if (split !== undefined) {
|
|
119
|
+
throw new CommandError('--split and --no-split need --subset: a font is split by its ranges.')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return []
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const decided = split === undefined ? [] : [split ? '--split' : '--no-split']
|
|
126
|
+
|
|
127
|
+
return ['--subset', ...subset, ...decided]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function buildCheckout(root, run, fonts = []) {
|
|
96
131
|
const dir = path.join(root, ASSETS_PATH)
|
|
97
132
|
|
|
98
133
|
// The images are stored with Git LFS. Without it they are pointer files.
|
|
99
134
|
run('git', ['lfs', 'install', '--local'], { cwd: dir, quiet: true })
|
|
100
135
|
run('git', ['lfs', 'pull'], { cwd: dir })
|
|
101
|
-
|
|
102
|
-
|
|
136
|
+
|
|
137
|
+
if (fonts.length > 0) {
|
|
138
|
+
// The subsetter is a package that the build loads, so the package of the build is
|
|
139
|
+
// installed, without the tools of its tests. Where an install without the workspace
|
|
140
|
+
// ran before, pnpm removes its modules first, and would ask.
|
|
141
|
+
run(
|
|
142
|
+
'pnpm',
|
|
143
|
+
['install', '--filter', ASSETS_PACKAGE, '--prod', '--config.confirmModulesPurge=false'],
|
|
144
|
+
{ cwd: dir }
|
|
145
|
+
)
|
|
146
|
+
run('pnpm', ['assets:site', ...fonts], { cwd: dir })
|
|
147
|
+
} else {
|
|
148
|
+
run('pnpm', ['install', '--ignore-workspace'], { cwd: dir })
|
|
149
|
+
run('pnpm', ['assets:site'], { cwd: dir })
|
|
150
|
+
}
|
|
103
151
|
|
|
104
152
|
const output = path.join(dir, ASSETS_OUTPUT)
|
|
105
153
|
|
package/src/cli/main.js
CHANGED
|
@@ -14,6 +14,14 @@ Commands:
|
|
|
14
14
|
vendor Build vendor/assets at the commit that the repository pins
|
|
15
15
|
sync-submodules Move vendor/assets to the latest commit of a branch, and build it
|
|
16
16
|
--branch <name> The branch of chassis-assets (default: $SUBMODULE_BRANCH or ${DEFAULT_BRANCH})
|
|
17
|
+
|
|
18
|
+
Both builds:
|
|
19
|
+
--subset <range> Write the web fonts with the characters of a range only, such as
|
|
20
|
+
latin or U+0370-03FF. Repeatable
|
|
21
|
+
--split With --subset, write a font in a file per range, which a page
|
|
22
|
+
loads when it has a character of the range
|
|
23
|
+
--no-split With --subset, write a font in one file (default: the setting
|
|
24
|
+
of chassis-assets)
|
|
17
25
|
html-validate [paths] Validate the HTML files in paths (default: _site) with html-validate
|
|
18
26
|
--config <file> A JSON config of html-validate, added to the defaults
|
|
19
27
|
vnu [paths] Validate paths (default: _site) with the Nu Html Checker. Needs Java
|
|
@@ -27,6 +35,21 @@ Commands:
|
|
|
27
35
|
|
|
28
36
|
html-validate and vnu need the html-validate and vnu-jar packages in the site's devDependencies.`
|
|
29
37
|
|
|
38
|
+
const fontOptions = {
|
|
39
|
+
subset: { type: 'string', multiple: true },
|
|
40
|
+
split: { type: 'boolean' },
|
|
41
|
+
'no-split': { type: 'boolean' }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// `--split` is true and `--no-split` is false. Neither leaves the decision to chassis-assets.
|
|
45
|
+
function splitOf(values) {
|
|
46
|
+
if (values.split && values['no-split']) {
|
|
47
|
+
throw new CommandError('Give --split or --no-split, not both.')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return values.split ? true : values['no-split'] ? false : undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
30
53
|
const ignoreOptions = {
|
|
31
54
|
ignore: { type: 'string', multiple: true },
|
|
32
55
|
'no-default-ignore': { type: 'boolean' }
|
|
@@ -39,16 +62,20 @@ function ignoresOf(values, paths) {
|
|
|
39
62
|
|
|
40
63
|
const commands = {
|
|
41
64
|
vendor: {
|
|
42
|
-
options: {},
|
|
43
|
-
run: () => {
|
|
44
|
-
buildAssets()
|
|
65
|
+
options: { ...fontOptions },
|
|
66
|
+
run: ({ values }) => {
|
|
67
|
+
buildAssets({ subset: values.subset, split: splitOf(values) })
|
|
45
68
|
return 0
|
|
46
69
|
}
|
|
47
70
|
},
|
|
48
71
|
'sync-submodules': {
|
|
49
|
-
options: { branch: { type: 'string' } },
|
|
72
|
+
options: { branch: { type: 'string' }, ...fontOptions },
|
|
50
73
|
run: ({ values }) => {
|
|
51
|
-
syncAssets({
|
|
74
|
+
syncAssets({
|
|
75
|
+
branch: values.branch ?? process.env.SUBMODULE_BRANCH ?? DEFAULT_BRANCH,
|
|
76
|
+
subset: values.subset,
|
|
77
|
+
split: splitOf(values)
|
|
78
|
+
})
|
|
52
79
|
return 0
|
|
53
80
|
}
|
|
54
81
|
},
|
|
@@ -16,120 +16,118 @@ const docsPages = await getDocsPages()
|
|
|
16
16
|
|
|
17
17
|
<nav class="cxd-links w-100" id="cxd-docs-nav" aria-label="Docs navigation">
|
|
18
18
|
<menu class="p-0 m-0">
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
const groupSlug = getSlug(group.title)
|
|
19
|
+
{sidebar.map((group) => {
|
|
20
|
+
const groupSlug = getSlug(group.title)
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const url = getDocsPath(unversionedPageSlug)
|
|
52
|
-
const active = Astro.params.slug === unversionedPageSlug
|
|
22
|
+
if (group.pages) {
|
|
23
|
+
return (
|
|
24
|
+
<li
|
|
25
|
+
class:list={[
|
|
26
|
+
'cxd-links-group',
|
|
27
|
+
groupSlug === Astro.params.slug?.split('/')[0] ? 'active' : undefined
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
<strong class="cxd-links-heading">
|
|
31
|
+
{group.icon && (
|
|
32
|
+
<Icon
|
|
33
|
+
name={group.icon}
|
|
34
|
+
style={group.iconColor && `color: var(--cx-${group.iconColor});`}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
{group.title}
|
|
38
|
+
</strong>
|
|
39
|
+
<ul class="nav flex-column cxd-links-nav">
|
|
40
|
+
{group.pages?.map((item: SidebarItem) => {
|
|
41
|
+
// Handle sub-groups
|
|
42
|
+
if (item.group && item.pages) {
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<li class="cxd-links-subgroup">{item.group}</li>
|
|
46
|
+
{item.pages.map((page: SidebarSubItem) => {
|
|
47
|
+
const docSlug = getSlug(page.title)
|
|
48
|
+
const unversionedPageSlug = `${groupSlug}/${docSlug}`
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
50
|
+
const url = getDocsPath(unversionedPageSlug)
|
|
51
|
+
const active = Astro.params.slug === unversionedPageSlug
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`The page '${page.title}' referenced in 'data/sidebar.yml' does not exist at '${url}'.`
|
|
62
|
-
)
|
|
63
|
-
}
|
|
53
|
+
const generatedPage = docsPages.find(
|
|
54
|
+
(page) => page.id === unversionedPageSlug
|
|
55
|
+
)
|
|
64
56
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
class:list={['cxd-links-link', { active }]}
|
|
70
|
-
aria-current={active ? 'page' : undefined}
|
|
71
|
-
>
|
|
72
|
-
{page.title}
|
|
73
|
-
</a>
|
|
74
|
-
</li>
|
|
57
|
+
// This test should not be necessary, see comments for `getSlug()` in `src/libs/utils.ts`.
|
|
58
|
+
if (!generatedPage) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`The page '${page.title}' referenced in 'data/sidebar.yml' does not exist at '${url}'.`
|
|
75
61
|
)
|
|
76
|
-
}
|
|
77
|
-
</>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
62
|
+
}
|
|
80
63
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
64
|
+
return (
|
|
65
|
+
<li>
|
|
66
|
+
<a
|
|
67
|
+
href={url}
|
|
68
|
+
class:list={['cxd-links-link', { active }]}
|
|
69
|
+
aria-current={active ? 'page' : undefined}
|
|
70
|
+
>
|
|
71
|
+
{page.title}
|
|
72
|
+
</a>
|
|
73
|
+
</li>
|
|
74
|
+
)
|
|
75
|
+
})}
|
|
76
|
+
</>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
// Handle regular pages
|
|
81
|
+
if (!item.title) {
|
|
82
|
+
return null
|
|
83
|
+
}
|
|
88
84
|
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
const docSlug = getSlug(item.title)
|
|
86
|
+
const unversionedPageSlug = `${groupSlug}/${docSlug}`
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
const url = getDocsPath(unversionedPageSlug)
|
|
89
|
+
const active = Astro.params.slug === unversionedPageSlug
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
if (!generatedPage) {
|
|
96
|
-
throw new Error(
|
|
97
|
-
`The page '${item.title}' referenced in 'data/sidebar.yml' does not exist at '${url}'.`
|
|
98
|
-
)
|
|
99
|
-
}
|
|
91
|
+
const generatedPage = docsPages.find((page) => page.id === unversionedPageSlug)
|
|
100
92
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
class:list={['cxd-links-link', { active }]}
|
|
106
|
-
aria-current={active ? 'page' : undefined}
|
|
107
|
-
>
|
|
108
|
-
{item.title}
|
|
109
|
-
</a>
|
|
110
|
-
</li>
|
|
93
|
+
// This test should not be necessary, see comments for `getSlug()` in `src/libs/utils.ts`.
|
|
94
|
+
if (!generatedPage) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`The page '${item.title}' referenced in 'data/sidebar.yml' does not exist at '${url}'.`
|
|
111
97
|
)
|
|
112
|
-
}
|
|
113
|
-
</ul>
|
|
114
|
-
</li>
|
|
115
|
-
)
|
|
116
|
-
} else {
|
|
117
|
-
const active = Astro.params.slug === groupSlug
|
|
98
|
+
}
|
|
118
99
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
100
|
+
return (
|
|
101
|
+
<li>
|
|
102
|
+
<a
|
|
103
|
+
href={url}
|
|
104
|
+
class:list={['cxd-links-link', { active }]}
|
|
105
|
+
aria-current={active ? 'page' : undefined}
|
|
106
|
+
>
|
|
107
|
+
{item.title}
|
|
108
|
+
</a>
|
|
109
|
+
</li>
|
|
110
|
+
)
|
|
111
|
+
})}
|
|
112
|
+
</ul>
|
|
113
|
+
</li>
|
|
114
|
+
)
|
|
115
|
+
} else {
|
|
116
|
+
const active = Astro.params.slug === groupSlug
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<li class="cxd-links-span-all mt-2xs mb-md mx-lg border-top" />
|
|
121
|
+
<a
|
|
122
|
+
href={getDocsPath(`${groupSlug}/`)}
|
|
123
|
+
class:list={['cxd-links-link cxd-links-span-all', { active }]}
|
|
124
|
+
aria-current={active ? 'page' : undefined}
|
|
125
|
+
>
|
|
126
|
+
{group.title}
|
|
127
|
+
</a>
|
|
128
|
+
</>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
})}
|
|
134
132
|
</menu>
|
|
135
133
|
</nav>
|
|
@@ -44,13 +44,11 @@ const headerClasses = [
|
|
|
44
44
|
|
|
45
45
|
<div class={cardClasses}>
|
|
46
46
|
<div class={headerClasses}>
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
53
|
-
}
|
|
47
|
+
{icon && (
|
|
48
|
+
<div class="feature-thumb">
|
|
49
|
+
<Icon name={icon} class="feature-icon icon-3xl md:icon-4xl" sprite="" />
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
54
52
|
<div>
|
|
55
53
|
<h3 class="feature-title font-lg md:font-xl mb-3xs md:mb-2xs">
|
|
56
54
|
<slot name="title" />
|
|
@@ -27,16 +27,14 @@ let entryLevel = level ? level + 1 : 1
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
29
|
<ul>
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
}
|
|
30
|
+
{toc.map(({ children, slug, text }) => {
|
|
31
|
+
return (
|
|
32
|
+
<li>
|
|
33
|
+
<a href={`#${slug}`} class={`level-${entryLevel}`}>
|
|
34
|
+
{text}
|
|
35
|
+
</a>
|
|
36
|
+
{children.length > 0 && <Astro.self entries={children} level={entryLevel} />}
|
|
37
|
+
</li>
|
|
38
|
+
)
|
|
39
|
+
})}
|
|
42
40
|
</ul>
|