@chassis-ui/docs 0.5.0 → 0.6.0-next.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 ADDED
@@ -0,0 +1,256 @@
1
+ # @chassis-ui/docs
2
+
3
+ ## 0.6.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **Breaking.** The package no longer imports `@libs/config`, `@libs/content`, `@libs/data`, `@libs/path`, `@libs/clipboard` or `@scss/docs.scss` from the site. A site adds the integration instead. [UPGRADING.md](https://github.com/chassis-ui/website/blob/main/packages/docs/UPGRADING.md) has the steps.
8
+ - **Breaking.** The keys of `config.yml` are camelCase: `currentVersion`, `githubOrg`, `figmaHandle`, `xUsername` and `analytics.googleId`. An old name fails the build with a message that names the new one. The `docsDir` key is removed: the site root is the Astro root.
9
+ - **Breaking.** Three more keys are camelCase: `iconColor` in `data/sidebar.yml`, and `added.showBadge` and `extraJs` in the frontmatter of docs pages. An old name fails the build.
10
+ - **Breaking.** The schema of `config.yml` is strict. An unknown key fails the build. It was dropped silently.
11
+ - **Breaking.** `exports` lists the supported import paths only: the root entry, `integration`, `schema`, `site`, the four layouts and six components by name, `shortcodes/*`, `js/*`, `scss/main` and `scss/vars`. These no longer resolve: `libs/*`, the other partials under `scss/`, the folders under `layouts/`, and `components/shortcodes/*`. Import a shortcode as `@chassis-ui/docs/shortcodes/Icon.astro`.
12
+ - **Breaking.** `chassisAutoImport()` takes `{ root, dir, include, exclude }` and returns `{ imports, typeDefinitions, plugin }`. It finds the package's shortcodes from the package's own location, and the type declarations go to `.astro/`, not to `src/types/auto-import.d.ts`. Its `docsPath` and `modulesPath` options and its `integration()` are removed.
13
+ - **Breaking.** `getSourceFsPath()`, `getSourceUrl()` and `getSiteFileUrl()` moved from `libs/source` to `@chassis-ui/docs/site`.
14
+ - Add the `chassisDocs()` integration, at `@chassis-ui/docs/integration`. It reads `config.yml` and `data/sidebar.yml`, sets `site` and `markdown`, imports the shortcodes into MDX files and checks `[[docsref:]]` links. It finds every file from the Astro root, so the working directory of the build does not matter.
15
+ - `@chassis-ui/docs/schema` exports the schemas of `config.yml`, the sidebar and the `docs` and `callouts` collections, with their types. A site extends `configSchema` for keys of its own.
16
+ - `@chassis-ui/docs/site` exports what pages read from the site: `getConfig()`, `getSidebar()`, `getDocsPath()`, `getDocsPages()`, `getCallout()`, the path and URL helpers, `getPackageFilePath()` and `createDataLoader()`.
17
+ - The root entry exports `loadConfig()`, `loadData()`, `loadSidebar()`, the remark plugins `remarkCxConfig` and `remarkCxDocsref`, and one implementation of `getChassisTokensFsPath()`, `getChassisAssetsFsPath()`, `getChassisCSSFsPath()` and `getChassisIconsFsPath()`.
18
+ - The integration puts the default `chassis-tokens` of `@chassis-ui/css`, in its `scss/vendor` folder, on the Sass load path, after the site's own load paths. A site can delete the load path it set for it. A site with tokens of its own keeps the folder of its `_chassis-tokens.scss` in its config.
19
+ - Add `include` and `exclude` options for the shortcodes. A shortcode of the site replaces the package's shortcode of the same name.
20
+ - Add `js/clipboard.ts`, which every site carried a copy of.
21
+ - `githubOrg`, `figmaHandle`, `xUsername` and `analytics.googleId` are optional. The header links, the X meta tags and Google Analytics are left out when their key is not set.
22
+ - `anchors`, `toc`, `siteBranch` and `sourceDir` have defaults.
23
+ - Add a versioning policy to the README, and make `scss/vars` a public partial.
24
+
25
+ ### Patch Changes
26
+
27
+ - The scripts of the package and of the site share one copy of `@chassis-ui/css`. In the dev server of a site that installed the package, `example-mode.js` was pre-bundled with a copy of its own, which registered every listener twice: a dialog opened and closed at once. The integration keeps both packages out of pre-bundling and dedupes `@chassis-ui/css`, so a site needs no alias for it.
28
+ - `<ScssDocs>`, `<ScssDocsSimple>` and `<JsDocs>` stop at the end marker of the part they show. A part whose name starts another name, such as `make-col` and `make-col-auto`, ran on to the end of the longer one.
29
+ - A table of contents whose first heading is deeper than a later one, such as an `<h3>` before the first `<h2>`, nested the `<h2>` under the `<h3>`.
30
+ - Packages whose types the shipped source imports are dependencies, not development dependencies.
31
+ - The README links a starter site, `packages/docs/starter` in the repository, to copy as the start of a new Chassis docs site.
32
+
33
+ Up to 0.5.1, this repository kept one changelog for the package and the website, headed by the versions of the package. The entries below are that changelog. Changesets writes the entries of later versions.
34
+
35
+ ## [0.5.1] - 2026-09-29
36
+
37
+ ### Added
38
+
39
+ - `packages/docs`: four optional `config.yml` keys say where files live when a site is not built from the root of its repository: `sourceDir`, `sourcePath`, `sitePath` and `siteBranch`. A site that sets none behaves as before. See the package README.
40
+ - `packages/docs`: the README lists what a site must provide: the `@libs/*` modules, the `config.yml` keys and the `docs` content collection.
41
+ - `packages/docs`: the package ships its `LICENSE` and declares Astro's Node requirement in `engines`.
42
+
43
+ ### Fixed
44
+
45
+ - `packages/docs`: `<ScssDocs>`, `<ScssDocsSimple>`, `<JsDocs>` and `<Code filePath>` read and link source files relative to `sourceDir` and `sourcePath`, so they work for a site in `packages/site` ([#2](https://github.com/chassis-ui/website/issues/2)).
46
+ - `packages/docs`: "View on GitHub" links to the page's own source file. It linked to `<repo>/blob/<id>.mdx`, which never existed ([#1](https://github.com/chassis-ui/website/issues/1)).
47
+ - `packages/docs`: the README named example imports that do not exist and an outdated `@chassis-ui/css` peer range.
48
+
49
+ ### Changed
50
+
51
+ - Website: moved to `@chassis-ui/css` 0.5.2 and `@chassis-ui/tokens` 0.5.3, which changes colours, border radii and dark-mode backgrounds.
52
+ - Updated dependencies within their ranges, including Astro 7.3.5. This clears every `pnpm audit` advisory, including a critical one in Astro.
53
+ - The production build uses the `vendor/assets` commit pinned in this repository instead of the latest `app/docs`.
54
+ - CI builds the site and validates its HTML. The Lighthouse run works again.
55
+
56
+ ### Removed
57
+
58
+ - Stale files: `PROJECT_REVIEW.md`, the multi-platform sync tooling under `build/`, and committed build output under `examples/`.
59
+
60
+ ## [0.5.0] - 2026-09-19
61
+
62
+ ### Changed
63
+
64
+ - Reworked breakpoint and sizing utility classes/tokens across `packages/docs` and `packages/website` to use the shorthand naming from the updated Chassis CSS (e.g. `large:px-xsmall` → `lg:px-xs`, `medium` → `md`), spanning layouts, components, shortcodes, SCSS partials, and page templates
65
+ - Bumped `@chassis-ui/css` and `@chassis-ui/tokens` peer dependencies to `^0.5.0`
66
+
67
+ ## [0.4.0] - 2026-09-15
68
+
69
+ ### Changed
70
+
71
+ - Bumped `@chassis-ui/css` and `@chassis-ui/tokens` to `^0.4.0`
72
+ - `packages/docs/src/scss/_sidebar.scss`: reworked subgroup label styling (uppercase, `--cx-font-size-xsmall`, `--cx-primary-fg-main` color, adjusted spacing) and the `::before` connector line selectors to correctly handle first-child/only-child/subgroup combinations
73
+ - `packages/docs/src/scss/_search.scss`: adjusted the search dialog's large-breakpoint offset from `13rem` to `11rem` (both LTR and RTL)
74
+ - `ThemeToggler.astro` and header nav links (`Navigation.astro`): replaced `px-0 large:px-small` with `px-0 large:px-xsmall`; `ThemeToggler` also gained a `caret` class
75
+ - `SearchDialog.astro`: renamed the search icon wrapper class from `input-help` to `input-adorn`
76
+
77
+ ## [0.3.10] - 2026-07-21
78
+
79
+ ### Added
80
+
81
+ - Blog link to the navbar
82
+
83
+ ## [0.3.9] - 2026-07-19
84
+
85
+ ### Added
86
+
87
+ - `packages/docs`: new `zoom.js` script — initialises `medium-zoom` on any element tagged `[data-zoomable]`; `medium-zoom` added as a dependency
88
+ - `packages/docs/src/libs/image.ts`: new `getRemoteImageSize()` helper that fetches a remote image at build time and returns its pixel dimensions; used by `Social.astro` for CDN-hosted thumbnails
89
+ - `packages/docs/src/layouts/head/Social.astro`: `<meta property="og:site_name">` tag
90
+
91
+ ### Changed
92
+
93
+ - `packages/docs/src/layouts/head/Social.astro`: supports remote thumbnail URLs — when `thumbnail` starts with `http(s)://` it uses `getRemoteImageSize()` instead of reading a local file
94
+ - `packages/docs/src/components/ResponsiveImage.astro`: forwards extra props (`...rest`) to the rendered `<img>` element
95
+ - `packages/docs/package.json`: bumped `@chassis-ui/css` peer dependency to `>=0.3.4`
96
+
97
+ ## [0.3.8] - 2026-07-14
98
+
99
+ ### Added
100
+
101
+ - `<link rel="preconnect">` hints for Google Fonts (`fonts.googleapis.com`, `fonts.gstatic.com`) in `Head.astro`, and for the jsDelivr CDN (Swiper) on the homepage
102
+
103
+ ### Fixed
104
+
105
+ - `packages/docs/src/scss/main.scss`: corrected an invalid `margin--block-start` property to `margin-block-start`
106
+
107
+ ## [0.3.7] - 2026-07-13
108
+
109
+ ### Fixed
110
+
111
+ - `api/contact.ts`: the contact form handler now checks the `error` returned from `resend.emails.send()`'s response and returns a 500 instead of silently reporting success; previously only request-level failures (network errors, etc.) were caught, not API-level errors returned in the response body
112
+ - Support form (`SupportSection.astro`) success/error states now use the `notification` component.
113
+ - `packages/website/config.yml`: `repo` was pointing at the `chassis-ui/docs` repository; corrected to `chassis-ui/website`
114
+
115
+ ### Changed
116
+
117
+ - Renamed the `x` site config key to `x_username`, changed `github_org` to hold a bare org slug instead of a full URL, and added a new `figma_handle` key (config schema updated to match)
118
+ - Docs header navigation: replaced the X/Twitter link with a new link to the Chassis Figma Community profile, alongside GitHub
119
+ - CI: bumped `pnpm/action-setup` to v6 and `softprops/action-gh-release` to v3 in `publish-packages.yml`, and renamed the docs npm publish token secret to `NPM_CHASSIS_UI`
120
+ - Bumped `@chassis-ui/css` to `^0.3.3` in `packages/docs` peerDependencies
121
+ - Bumped `@chassis-ui/icons` to `^0.3.1` in `packages/website`
122
+
123
+ ## [0.3.6] - 2026-07-06
124
+
125
+ ### Fixed
126
+
127
+ - Multi-site search no longer breaks entirely when a sibling Chassis site's Pagefind index is unreachable (bad deploy, rollout still in progress across the separate repos). Previously `mergeIndex` was passed up front and a single failed merge threw and corrupted the shared instance for every future search, including the current site's own results. Now the current site's own index loads first, and each sibling is probed — both its `pagefind-entry.json` and the language-specific `pagefind.<hash>.pf_meta` chunk `init()` actually requests — before `mergeIndex` is attempted, so an unreachable sibling is skipped instead of taking down search
128
+ - The site filter dropdown (`cxd-search-filter`) is now always rendered instead of only when other sites were successfully merged in at load time
129
+ - Search result item icons now reference the shared icon sprite (`/static/icons/chassis-icons.svg#…`) instead of a bare `#id` fragment, which resolved against the current page instead of the sprite
130
+ - Removed the unused `vite` devDependency from `@chassis-ui/docs`; it only backed the `chassisBundlePlugin` removed in 0.3.4 and had no remaining imports
131
+ - `@pagefind/component-ui` is no longer marked `optional` in `peerDependenciesMeta` — every docs layout unconditionally renders the search dialog and imports it, and every consuming site already installs it directly, so it was never actually optional
132
+ - `README.md`: corrected the peer dependencies list (was just `astro: ^5.0.0`; now matches the full, actual `package.json` peer set) and the `@chassis-ui/docs` exports table, which was missing `highlight`, `markdown`, `placeholder`, `shortcodes`, `site` and listed a nonexistent `chassis` module
133
+
134
+ ### Changed
135
+
136
+ - Refactored `search.js`: renamed the `renderItem` params `title`/`excerpt` to `titleHtml`/`excerptHtml` to make explicit that callers must pass pre-escaped/pre-marked HTML, and extracted `renderResultsList` and `addListeners` helpers to remove repeated markup and bind/track/remove boilerplate across the custom elements
137
+
138
+ ## [0.3.5] - 2026-07-06
139
+
140
+ ### Added
141
+
142
+ - Multi-site Pagefind search: the docs search dialog now merges every Chassis project's index (`website`, `tokens`, `css`, `assets`, `icons`, `figma`) into one site-filterable search with a new site filter dropdown (`cxd-search-filter`) to scope results to a single project or "Everywhere"
143
+
144
+ ### Changed
145
+
146
+ - `_search.scss` rules moved into `@layer custom` to fix cascade ordering against `@chassis-ui/css`
147
+ - `pagefind.yml`: added `root_selector: "main"` so indexing skips shared chrome (nav, footer) and only picks up page content
148
+
149
+ ### Fixed
150
+
151
+ - `packages/website/src/scss/home.scss`: removed unused `docs`/`@chassis-ui/css/scss/config` imports and a leftover `background-image` override on `.module-item`, and dropped an unnecessary `#{calc(...)}` interpolation
152
+ - `HeroSection.astro`: added missing whitespace between the two `<h1>` text segments
153
+
154
+ ## [0.3.4] - 2026-07-05
155
+
156
+ ### Fixed
157
+
158
+ - Removed the dev-mode virtual-module Vite plugin (`chassisBundlePlugin`) that resolved `@chassis-ui/css` to a fake module in `Scripts.astro`. Vite's `optimizeDeps` pre-bundling of `@chassis-ui/docs/js/example-mode.js` ran before the plugin's `resolveId`/`load` hooks could apply, inlining a second, un-deduped copy of every `@chassis-ui/css` component — duplicate `document`-level `data-cx-toggle`/`data-cx-dismiss` click handlers, causing modal/drawer/etc. to double-toggle in consumers' dev servers
159
+ - `Scripts.astro` now loads Chassis JS with a plain `import '@chassis-ui/css'` instead of a hand-computed dev/prod `<script is:inline>` src. Consumers who install `@chassis-ui/css` as a real dependency (e.g. `packages/website`) need no special config — the import resolves normally and Vite's own dependency optimizer dedupes it. Consumers who self-host `@chassis-ui/css` (i.e. _are_ that package) need to alias it to their own build output in dev themselves — see chassis-css's own `site/src/libs/astro.ts` for the pattern
160
+ - `packages/website/src/libs/astro.ts`: removed a call to the now-removed `chassisBundlePlugin`
161
+ - `packages/website/astro.config.ts`: removed a dead `rollupOptions.external`/`output.paths` pair that never applied — Astro 7.0.6's client build config only reads the `output` sub-key of `rolldownOptions`, never `external`, so `@chassis-ui/css` was never actually externalized despite the config implying it was
162
+ - Worked around a `@chassis-ui/css` bug (fixed upstream in `@chassis-ui/css@0.3.2`) where a missing `sideEffects` entry for its package entry point let bundlers tree-shake away components nobody imported by name (`Dialog`, `Drawer`, `Accordion`, etc.), breaking modal/drawer in `packages/website`'s production build
163
+
164
+ ## [0.3.3] - 2026-07-05
165
+
166
+ ### Fixed
167
+
168
+ - Corrected an incorrect `@chassis-ui/css` peer dependency version on `@chassis-ui/docs`
169
+
170
+ ## [0.3.2] - 2026-07-05
171
+
172
+ ### Fixed
173
+
174
+ - `<ScssDocs>` no longer drops rules when a compiled snippet mixes plain declarations with directives that emit their own selectors (e.g. `@each`); sentinel unwrapping now walks brace depth instead of matching a single block
175
+ - `<ScssDocs>` Sass compilation now resolves bare npm specifiers (e.g. `@chassis-ui/tokens/...`) by adding `node_modules` to `loadPaths`
176
+ - `change-version` script no longer bumps the root `package.json` version, which was unused and unrelated to the published `@chassis-ui/docs` version
177
+
178
+ ## [0.3.1] - 2026-07-05
179
+
180
+ ### Fixed
181
+
182
+ - Moved `@chassis-ui/docs`'s runtime-only dependencies (`image-size`, `github-slugger`, `remark`, `remark-html`, `mdast-util-from-markdown`, `mdast-util-to-string`, `unist-util-visit`) from `devDependencies` to `dependencies`, since consumers couldn't resolve them under `devDependencies`
183
+ - Bumped the `htmlparser2` and `sass` peer dependency ranges on `@chassis-ui/docs` to match the versions consumers actually install
184
+
185
+ ## [0.3.0] - 2026-07-04
186
+
187
+ ### Added
188
+
189
+ - Pagefind-powered site search, replacing the Algolia search integration
190
+ - New `Icon` component for docs/website, replacing ad-hoc icon markup across shortcodes and pages, with accessibility improvements (proper SVG titles, ARIA handling)
191
+ - New `Code`, `Example`, `ResizableExample`, and `ScssDocs` shortcode components, and a `clipboard.ts` utility for copy-to-clipboard in code blocks
192
+
193
+ ### Changed
194
+
195
+ - Large-scale Chassis CSS update and SCSS variable reorganization across the docs and website packages
196
+ - Upgraded dependencies and refreshed the lockfile
197
+ - Reworked Astro config, shortcode registration, and homepage section components to match the updated design system
198
+ - Moved `example-mode.js` from the website package into docs.
199
+ - Removed the old `icon-loader.js`, `Icon` component uses path to SVG sprite
200
+ - Replaced Prism-based syntax highlighting with Shiki
201
+ - Removed the Algolia search plugin
202
+ - Rewrote reference docs to reflect the current setup
203
+ - Cleaned up code and removed unused website dependencies
204
+
205
+ ### Fixed
206
+
207
+ - Astro type-check errors across docs/website pages
208
+ - `sync-submodules` build script
209
+
210
+ ## [0.2.0] - 2026-05-03
211
+
212
+ ### Added
213
+
214
+ - Updated test pages and containers/responsive utilities
215
+
216
+ ### Changed
217
+
218
+ - Updated Chassis CSS
219
+
220
+ ### Fixed
221
+
222
+ - CI workflow fixes and linting issues
223
+ - `placeholder.ts` fix
224
+
225
+ ## [0.1.10] - 2026-04-28
226
+
227
+ ### Added
228
+
229
+ - Staging branch deployment support
230
+ - Coming soon page for the main branch
231
+ - Docs test page and sitemap filter updates
232
+
233
+ ### Changed
234
+
235
+ - Improved blog and updated layouts
236
+ - Bumped docs package version
237
+
238
+ ### Fixed
239
+
240
+ - Vercel deployment configuration
241
+ - vnu (HTML validator) errors and path ignoring in `vnu-jar.js`
242
+ - Linting errors
243
+
244
+ ## [0.1.0] - 2025-08-24
245
+
246
+ ### Added
247
+
248
+ - Initial project setup: Astro-based website, docs package, and Chassis UI vendor submodule
249
+ - Build-time icon integration, submodule configuration, and initial CI workflows
250
+
251
+ [0.3.2]: https://github.com/chassis-ui/website/compare/v0.3.1...v0.3.2
252
+ [0.3.1]: https://github.com/chassis-ui/website/compare/v0.3.0...v0.3.1
253
+ [0.3.0]: https://github.com/chassis-ui/website/compare/v0.2.0...v0.3.0
254
+ [0.2.0]: https://github.com/chassis-ui/website/compare/v0.1.10...v0.2.0
255
+ [0.1.10]: https://github.com/chassis-ui/website/compare/v0.1.0...v0.1.10
256
+ [0.1.0]: https://github.com/chassis-ui/website/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ozgur Gunes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,32 +2,28 @@
2
2
 
3
3
  > Shared Astro layouts, components, and utilities for Chassis documentation sites.
4
4
 
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Version: 0.5.0](https://img.shields.io/badge/Version-0.5.0-blue.svg)](https://www.npmjs.com/package/@chassis-ui/docs) [![npm](https://img.shields.io/npm/v/@chassis-ui/docs.svg)](https://www.npmjs.com/package/@chassis-ui/docs)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![npm](https://img.shields.io/npm/v/@chassis-ui/docs.svg)](https://www.npmjs.com/package/@chassis-ui/docs)
6
6
 
7
7
  ## Overview
8
8
 
9
- `@chassis-ui/docs` powers every documentation site in the Chassis ecosystem — the main `chassis-ui.com` website and the per-package docs for `chassis-css`, `chassis-tokens`, `chassis-icons`, `chassis-figma`, and `chassis-assets`. It ships pre-built layouts, navigation components, content-processing utilities, and SCSS helpers so each site stays consistent without duplicating code.
9
+ `@chassis-ui/docs` powers every documentation site in the Chassis ecosystem: the main `chassis-ui.com` website and the docs of `chassis-css`, `chassis-tokens`, `chassis-icons`, `chassis-figma`, `chassis-assets` and `chassis-react`. It ships layouts, navigation components, shortcodes for MDX, content-processing utilities and SCSS, so each site stays consistent without copying code.
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 0.5? See [UPGRADING.md](UPGRADING.md).
14
+
13
15
  ## Installation
14
16
 
15
17
  ```sh
16
18
  pnpm add @chassis-ui/docs
17
19
  ```
18
20
 
19
- or:
20
-
21
- ```sh
22
- npm install @chassis-ui/docs
23
- ```
24
-
25
21
  ### Peer Dependencies
26
22
 
27
23
  ```json
28
24
  {
29
25
  "@astrojs/markdown-remark": "^7.0.0",
30
- "@chassis-ui/css": ">=0.3.2",
26
+ "@chassis-ui/css": "^0.5.0-0",
31
27
  "@pagefind/component-ui": "^1.0.0",
32
28
  "@shikijs/transformers": "^4.3.1",
33
29
  "astro": "^7.0.0",
@@ -38,49 +34,255 @@ npm install @chassis-ui/docs
38
34
  }
39
35
  ```
40
36
 
41
- In practice, sites also install the rest of the Chassis stack — `@chassis-ui/tokens`, `@chassis-ui/icons` — to render the layouts and styles correctly.
37
+ A site also installs `@astrojs/mdx` and the rest of the Chassis stack, `@chassis-ui/tokens` and `@chassis-ui/icons`.
38
+
39
+ ## Setup
40
+
41
+ A site needs four things before it can use the layouts: the integration, a `config.yml`, two content collections and the static files that the layouts link to.
42
+
43
+ The [starter site](starter/) has all four. Copy it to start a new site, and follow its README. CI builds it from the packed package on every push, so it works with the version of the package next to it.
44
+
45
+ ### 1. Add the integration
46
+
47
+ ```ts
48
+ // astro.config.ts
49
+ import { defineConfig } from 'astro/config'
50
+ import mdx from '@astrojs/mdx'
51
+ import { chassisDocs } from '@chassis-ui/docs/integration'
52
+
53
+ export default defineConfig({
54
+ integrations: [chassisDocs(), mdx()]
55
+ })
56
+ ```
57
+
58
+ The integration:
59
+
60
+ - reads and validates `config.yml` and `data/sidebar.yml`, and gives them to the layouts and components
61
+ - sets `site` from `baseURL`, unless the Astro config sets `site` itself
62
+ - sets `markdown`: heading anchors, Shiki themes, and the `[[config:key]]` and `[[docsref:/path]]` replacements
63
+ - imports the shortcodes into every MDX file
64
+ - fails the build when a `[[docsref:]]` link points to a page that was not built
65
+ - makes the scripts of the package and of the site share one copy of `@chassis-ui/css`, so that no listener is registered twice
66
+ - puts the default design tokens of `@chassis-ui/css` on the Sass load path, which the styles need
42
67
 
43
- ## Usage
68
+ It finds every file from the Astro root, the directory that holds `astro.config.ts`. The working directory of the build does not matter.
69
+
70
+ | Option | Default | Meaning |
71
+ | ---------------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------- |
72
+ | `config` | none | The config, when the site has loaded it itself with `loadConfig()` |
73
+ | `configFile` | `'config.yml'` | Path of the config file, from the site's root |
74
+ | `configSchema` | `configSchema` | Schema of the config file. See [keys of your own](#keys-of-your-own) |
75
+ | `sidebarFile` | `'data/sidebar.yml'`, when it exists | Path of the sidebar data, or `false` for no sidebar |
76
+ | `styles` | `['src/scss/docs.scss']`, when it exists | Stylesheets that every page loads. Without one, the package's own styles are loaded |
77
+ | `shortcodes` | all | `{ dir, include, exclude }`. See [shortcodes](#shortcodes) |
78
+ | `markdown` | none | `{ remarkPlugins, rehypePlugins, remarkRehype }` of the site. They run after the package's plugins |
79
+ | `brokenDocsrefs` | `'error'` | `'error'`, `'warn'` or `'ignore'` |
80
+
81
+ #### Tokens of your own
82
+
83
+ The styles of `@chassis-ui/css` load the design tokens as `chassis-tokens`. The integration adds the folder with the default one, `scss/vendor` of `@chassis-ui/css`, as the last Sass load path. A site with tokens of its own adds the folder of its `_chassis-tokens.scss` in its Astro config, which comes first:
84
+
85
+ ```ts
86
+ // astro.config.ts
87
+ export default defineConfig({
88
+ vite: {
89
+ css: { preprocessorOptions: { scss: { loadPaths: ['src/scss/tokens'] } } }
90
+ }
91
+ })
92
+ ```
93
+
94
+ ### 2. Write `config.yml`
95
+
96
+ ```yaml
97
+ title: 'Chassis - CSS'
98
+ subtitle: 'A Tokenized CSS Framework'
99
+ description: 'An open-source, tokenized CSS framework.'
100
+ authors: 'Ozgur Gunes'
101
+ baseURL: 'https://chassis-ui.com/css'
102
+ docsPath: '/css/docs'
103
+ repo: 'https://github.com/chassis-ui/css'
104
+ currentVersion: '0.5.2'
105
+ ```
106
+
107
+ | Key | Required | Meaning |
108
+ | --------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------- |
109
+ | `title`, `subtitle`, `description`, `authors` | yes | Used in the page title and the meta tags |
110
+ | `baseURL` | yes | Canonical URL of the site |
111
+ | `docsPath` | yes | URL path of the docs pages. Starts with `/` |
112
+ | `repo` | yes | URL of the repository |
113
+ | `currentVersion` | yes | Version that the site documents. Links to source files use the tag `v<currentVersion>` |
114
+ | `githubOrg` | no | GitHub organisation name, not a URL. The header links to it |
115
+ | `figmaHandle` | no | Figma Community handle. The header links to it |
116
+ | `xUsername` | no | X handle. Used in the social meta tags |
117
+ | `analytics.googleId` | no | Google Analytics ID. Loaded in production builds only |
118
+ | `anchors.min`, `anchors.max` | no | Heading levels that get an anchor link. Default 2 to 5 |
119
+ | `toc.min`, `toc.max` | no | Heading levels in the table of contents. Default 2 to 6 |
120
+ | `sourceDir` | no | Directory that `file` props are relative to, from the site's root, e.g. `"../css"`. Default `"."` |
121
+ | `sourcePath` | no | The same directory from the root of the repository, e.g. `"packages/css"` |
122
+ | `sitePath` | no | The site's root from the root of the repository, e.g. `"packages/site"` |
123
+ | `siteBranch` | no | The branch that "View on GitHub" links to. Default `main` |
124
+
125
+ `file` props are those of `<ScssDocs>`, `<ScssDocsSimple>`, `<JsDocs>` and `<Code filePath>`.
126
+
127
+ The schema is strict. A key that it does not know fails the build, so a typing error cannot go unnoticed.
128
+
129
+ #### Keys of your own
130
+
131
+ Extend the schema and pass it to the integration. Use the `z` that the package exports, so that the site and the package share one copy of Zod.
132
+
133
+ ```ts
134
+ // src/libs/config.ts
135
+ import { configSchema, z } from '@chassis-ui/docs/schema'
136
+
137
+ export const siteConfigSchema = configSchema.extend({
138
+ download: z.object({ dist: z.url(), source: z.url() })
139
+ })
140
+
141
+ export type SiteConfig = z.infer<typeof siteConfigSchema>
142
+ ```
143
+
144
+ ```ts
145
+ // astro.config.ts
146
+ integrations: [chassisDocs({ configSchema: siteConfigSchema })]
147
+ ```
44
148
 
45
149
  ```astro
46
150
  ---
47
- import BaseLayout from '@chassis-ui/docs/layouts/BaseLayout.astro'
48
- import DocsLayout from '@chassis-ui/docs/layouts/DocsLayout.astro'
49
- import SingleLayout from '@chassis-ui/docs/layouts/SingleLayout.astro'
151
+ import { getConfig } from '@chassis-ui/docs/site'
152
+ import type { SiteConfig } from '@libs/config'
153
+
154
+ const { download } = getConfig<SiteConfig>()
155
+ ---
156
+ ```
157
+
158
+ ### 3. Define the content collections
159
+
160
+ The layouts read the `docs` collection, and `<Callout name>` reads the `callouts` collection.
161
+
162
+ ```ts
163
+ // src/content.config.ts
164
+ import { defineCollection } from 'astro:content'
165
+ import { glob } from 'astro/loaders'
166
+ import { calloutsSchema, docsSchema } from '@chassis-ui/docs/schema'
167
+
168
+ export const collections = {
169
+ docs: defineCollection({
170
+ loader: glob({ pattern: '**/*.{md,mdx}', base: './content/docs' }),
171
+ schema: docsSchema
172
+ }),
173
+ callouts: defineCollection({
174
+ loader: glob({ pattern: '**/*.md', base: './content/callouts' }),
175
+ schema: calloutsSchema
176
+ })
177
+ }
178
+ ```
179
+
180
+ ### 4. Provide the static files
50
181
 
51
- import TableOfContents from '@chassis-ui/docs/components/TableOfContents.astro'
52
- import ThemeToggler from '@chassis-ui/docs/components/ThemeToggler.astro'
182
+ The layouts link to files under `/static/`, which the site puts into its `public` directory:
53
183
 
54
- import { generateTOC, processImage } from '@chassis-ui/docs'
184
+ | URL | From |
185
+ | -------------------------------------------------------------------- | ----------------------------------------- |
186
+ | `/static/css/chassis.css`, `/static/css/chassis.min.css` | the `dist` folder of `@chassis-ui/css` |
187
+ | `/static/icons/chassis-icons.svg`, `/static/icons/chassis-icons.css` | the `icons` folder of `@chassis-ui/icons` |
188
+ | `/static/images/*`: logo, favicons, social image | the docs build of `chassis-assets` |
189
+
190
+ 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 }`.
191
+
192
+ A site that type-checks with `astro check` declares the `@chassis-ui/css` module, which has no types: `declare module '@chassis-ui/css'`.
193
+
194
+ ### 5. Use the layouts
195
+
196
+ ```astro
197
+ ---
198
+ import SingleLayout from '@chassis-ui/docs/layouts/SingleLayout.astro'
55
199
  ---
56
200
 
57
- <SingleLayout title="About" description="…">
58
- <slot />
201
+ <SingleLayout title="About" description="What Chassis is and who makes it.">
202
+ <p>Page content.</p>
59
203
  </SingleLayout>
60
204
  ```
61
205
 
206
+ ## Shortcodes
207
+
208
+ Every component in `@chassis-ui/docs/shortcodes/` is available in MDX files without an import. So is every component in the site's `src/components/shortcodes/`. A component of the site replaces the package's component of the same name.
209
+
210
+ ```ts
211
+ chassisDocs({
212
+ shortcodes: {
213
+ // Leave out shortcodes whose names the site uses for something else
214
+ exclude: ['Icon']
215
+ }
216
+ })
217
+ ```
218
+
219
+ ## What pages read from the site
220
+
221
+ `@chassis-ui/docs/site` is for pages and components. It does not work in `astro.config.ts` or in the browser.
222
+
223
+ | Function | Returns |
224
+ | -------------------------------------------------- | ------------------------------------------------------------------- |
225
+ | `getConfig()` | The parsed `config.yml` |
226
+ | `getSidebar()` | The parsed `data/sidebar.yml` |
227
+ | `getDocsPath(path)` | URL path of a docs page |
228
+ | `getDocsPages()` | The entries of the `docs` collection |
229
+ | `getCallout(name)` | An entry of the `callouts` collection |
230
+ | `getSiteRoot()`, `getSiteFsPath(file)` | Absolute path of the site's root, or of a file in it |
231
+ | `getPublicFsPath(file)` | Absolute path of a file in the `public` directory |
232
+ | `getSourceFsPath(file)` | Absolute path of a file that a `file` prop names |
233
+ | `getSourceUrl(file)` | URL of a source file on GitHub, at the tag of the current version |
234
+ | `getSiteFileUrl(filePath)` | URL of a file of the site on GitHub, on the site's branch |
235
+ | `getPackageFilePath(file)` | Absolute path of a file of this package, e.g. `'js/color-modes.js'` |
236
+ | `resolveConfigRefs(text)`, `resolveDocsrefs(text)` | `text` with `[[config:]]` or `[[docsref:]]` replaced |
237
+ | `createDataLoader(definitions)` | A `getData(name)` function for the site's own YAML files in `data/` |
238
+
239
+ Code that runs while Astro loads its configuration uses the library functions of the root entry instead: `loadConfig()`, `loadData()`, `loadSidebar()` and the path helpers.
240
+
62
241
  ## Exports
63
242
 
64
- | Subpath | Contents |
65
- | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
66
- | `@chassis-ui/docs` | Library functions: `highlight`, `image`, `layout`, `markdown`, `placeholder`, `rehype`, `shortcodes`, `site`, `toc`, `utils` |
67
- | `@chassis-ui/docs/layouts/*` | `BaseLayout`, `DocsLayout`, `RedirectLayout`, `SingleLayout` |
68
- | `@chassis-ui/docs/components/*` | `DocsSidebar`, `FeatureCard`, `NavLink`, `ResponsiveImage`, `TableOfContents`, `ThemeToggler` |
69
- | `@chassis-ui/docs/shortcodes/*` | MDX shortcode components |
70
- | `@chassis-ui/docs/libs/*` | Direct access to individual library modules |
71
- | `@chassis-ui/docs/js/*` | Client-side scripts |
72
- | `@chassis-ui/docs/scss/*` | SCSS utilities and partials |
243
+ These import paths are the public API.
73
244
 
74
- ### Source Layout
245
+ | Path | Contents |
246
+ | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
247
+ | `@chassis-ui/docs` | Library functions that work anywhere: config and data loaders, path helpers, `getSiteUrl`, `getDocsMarkdownConfig`, the remark and rehype plugins, `chassisAutoImport`, `generateToc`, `highlightCode`, image and string utilities |
248
+ | `@chassis-ui/docs/integration` | `chassisDocs()` and the type of its options |
249
+ | `@chassis-ui/docs/schema` | `z`, `configSchema`, `sidebarSchema`, `docsSchema`, `calloutsSchema`, the version validators, and the types `ChassisConfig`, `Sidebar`, `SidebarItem`, `DocsFrontmatter`, `DocsPage` |
250
+ | `@chassis-ui/docs/site` | What pages read from the site. See above |
251
+ | `@chassis-ui/docs/layouts/*` | `BaseLayout.astro`, `DocsLayout.astro`, `RedirectLayout.astro`, `SingleLayout.astro` |
252
+ | `@chassis-ui/docs/components/*` | `DocsSidebar.astro`, `FeatureCard.astro`, `NavLink.astro`, `ResponsiveImage.astro`, `TableOfContents.astro`, `ThemeToggler.astro` |
253
+ | `@chassis-ui/docs/shortcodes/*` | The MDX shortcodes |
254
+ | `@chassis-ui/docs/js/*` | Client-side scripts: `example-mode.js`, `clipboard.ts`, `color-modes.js` and others |
255
+ | `@chassis-ui/docs/scss/main` | The styles of the package. The integration loads them when the site has no stylesheet of its own |
256
+ | `@chassis-ui/docs/scss/vars` | The Sass variables and custom properties of the docs, for a site's own stylesheets |
75
257
 
76
- ```
77
- src/
78
- ├── components/ # Astro components (+ shortcodes/)
79
- ├── layouts/ # Page layouts (+ head/, header/, footer/)
80
- ├── libs/ # Utility libraries
81
- ├── js/ # Client-side scripts
82
- └── scss/ # Styling utilities
83
- ```
258
+ No other path resolves: `exports` in `package.json` lists these and nothing else. The layouts and components are listed by name, so the folders inside `layouts/` and `components/` are not reachable.
259
+
260
+ The integration provides four modules: `virtual:chassis-docs/config`, `virtual:chassis-docs/sidebar`, `virtual:chassis-docs/paths` and `virtual:chassis-docs/styles`. Use the functions of `@chassis-ui/docs/site` instead of importing them.
261
+
262
+ ## Versioning
263
+
264
+ The package follows [Semantic Versioning](https://semver.org/). Before 1.0 that means:
265
+
266
+ - A minor release, 0.x.0, may contain breaking changes. Each one is listed in [CHANGELOG.md](CHANGELOG.md) and has a step in [UPGRADING.md](UPGRADING.md).
267
+ - A patch release, 0.x.y, contains none.
268
+
269
+ A change is breaking when it changes something that this README documents:
270
+
271
+ - the import paths listed under [Exports](#exports), and what they export
272
+ - the options of the integration
273
+ - the keys of `config.yml`, and the schemas of the sidebar and the content collections
274
+ - the props and slots of the layouts, components and shortcodes
275
+ - the `[[config:]]` and `[[docsref:]]` syntax
276
+ - the URLs under `/static/` that the layouts link to
277
+ - the supported versions of Node, Astro and `@chassis-ui/css`
278
+
279
+ Everything else may change in a patch release: the rendered HTML, class names, the content of the styles, and every file that is not reachable through a documented import path.
280
+
281
+ 1.0 is released when all three hold:
282
+
283
+ 1. Every Chassis site uses the integration and carries no copy of code that the package provides.
284
+ 2. Unit tests and builds of a fixture site run before every release.
285
+ 3. Releases are automated and published with provenance.
84
286
 
85
287
  ## Chassis Ecosystem
86
288
 
@@ -94,6 +296,7 @@ This package is part of the Chassis Design System's multi-repository architectur
94
296
  | [chassis-icons](https://github.com/chassis-ui/icons) | Icon library and build toolkit |
95
297
  | [chassis-assets](https://github.com/chassis-ui/assets) | Multi-platform asset management |
96
298
  | [chassis-figma](https://github.com/chassis-ui/figma) | Figma component documentation |
299
+ | [chassis-react](https://github.com/chassis-ui/react) | React component library |
97
300
 
98
301
  All documentation sites in the ecosystem share this package for consistent layouts, components, and styling.
99
302