From 72f56d27753b8ddb2d7206d6c857867cb57a4e5f Mon Sep 17 00:00:00 2001 From: Piotr Mlocek Date: Mon, 23 Nov 2026 14:02:18 -0800 Subject: [PATCH 01/15] feat(site): name the docset in the version picker label The picker label reads "OpenShell version" or "Go SDK version" instead of "Version", so it's clear which docset the picker switches. Signed-off-by: Piotr Mlocek --- site/src/components/VersionPicker.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/components/VersionPicker.astro b/site/src/components/VersionPicker.astro index 0fd24c9..c6bc842 100644 --- a/site/src/components/VersionPicker.astro +++ b/site/src/components/VersionPicker.astro @@ -9,7 +9,7 @@ const isLatest = picker?.options.some((o) => o.current && o.latest); {picker && (
- Version + {picker.title} version
From f0a33eec08ced34cc92871c404e96e462a384955 Mon Sep 17 00:00:00 2001 From: Piotr Mlocek Date: Mon, 23 Nov 2026 14:02:18 -0800 Subject: [PATCH 02/15] fix(site): link the GitHub icon to the ai-openshell organization The docs header linked to the docs repository. The GitHub organization covers the core repository, the SDKs, and the docs. Signed-off-by: Piotr Mlocek --- site/astro.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/astro.config.mjs b/site/astro.config.mjs index 233cabb..e36529c 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -15,7 +15,7 @@ export default defineConfig({ title: 'OpenShell', description: 'The safe, private runtime for autonomous AI agents.', favicon: '/favicon.svg', - social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/ai-openshell/docs' }], + social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/ai-openshell' }], customCss: ['./src/styles/tokens.css', './src/styles/theme.css'], head: [ { From 5703c652d4ecfee51cf1e0d5a83204910b542642 Mon Sep 17 00:00:00 2001 From: Piotr Mlocek Date: Mon, 23 Nov 2026 14:02:18 -0800 Subject: [PATCH 03/15] feat(site): add a community page written in Markdown Pages outside the docs can now be Markdown files in www/. scripts/website.mjs renders each www/.md into the landing page's header and footer at // and publishes its Markdown copy at /.md. The landing page stays hand-written HTML. The first page, /community/, links the CNCF Slack channel and the GitHub organization. The landing header links to it, and its GitHub icon now points to the organization. Signed-off-by: Piotr Mlocek --- package-lock.json | 34 +++++++++++++++++++++++++++++ package.json | 2 ++ scripts/website.mjs | 52 +++++++++++++++++++++++++++++++++++++++++---- www/community.md | 24 +++++++++++++++++++++ www/index.html | 5 +++-- www/style.css | 33 ++++++++++++++++++++++++---- 6 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 www/community.md diff --git a/package-lock.json b/package-lock.json index 599f807..23adec7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,10 +10,12 @@ "astro": "7.4.11", "github-slugger": "2.0.0", "pele": "1.13.0", + "rehype-stringify": "10.0.1", "remark-frontmatter": "5.0.0", "remark-gfm": "4.0.1", "remark-mdx": "3.1.1", "remark-parse": "11.0.0", + "remark-rehype": "11.1.2", "remark-stringify": "11.0.0", "unified": "11.0.5", "unist-util-visit": "5.2.0", @@ -5940,6 +5942,21 @@ "expressive-code": "^0.44.3" } }, + "node_modules/rehype-stringify": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-10.0.1.tgz", + "integrity": "sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-to-html": "^9.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/remark-directive": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/remark-directive/-/remark-directive-4.0.0.tgz", @@ -6020,6 +6037,23 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remark-rehype": { + "version": "11.1.2", + "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-11.1.2.tgz", + "integrity": "sha512-Dh7l57ianaEoIpzbp0PC9UKAdCSVklD8E5Rpw7ETfbTl3FqcOOgq5q2LVDhgGCkaBv7p24JXikPdvhhmHvKMsw==", + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "mdast-util-to-hast": "^13.0.0", + "unified": "^11.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/remark-stringify": { "version": "11.0.0", "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz", diff --git a/package.json b/package.json index fb74659..213feae 100644 --- a/package.json +++ b/package.json @@ -19,10 +19,12 @@ "astro": "7.4.11", "github-slugger": "2.0.0", "pele": "1.13.0", + "rehype-stringify": "10.0.1", "remark-frontmatter": "5.0.0", "remark-gfm": "4.0.1", "remark-mdx": "3.1.1", "remark-parse": "11.0.0", + "remark-rehype": "11.1.2", "remark-stringify": "11.0.0", "unified": "11.0.5", "unist-util-visit": "5.2.0", diff --git a/scripts/website.mjs b/scripts/website.mjs index 2e45dbb..4b7a3fc 100644 --- a/scripts/website.mjs +++ b/scripts/website.mjs @@ -1,15 +1,24 @@ #!/usr/bin/env node // SPDX-License-Identifier: Apache-2.0 -// Assemble the website: the files in www/ (the landing page) at / and the -// docs build at /docs/. +// Assemble the website: the files in www/ at / and the docs build at /docs/. +// www/index.html is the landing page. Each other www/.md is rendered +// into the landing page's shell (header, footer, scripts) at //, with +// its Markdown copy at /.md, like the docs pages. // The docs build must use BASE_PATH=/docs/ so its links resolve under /docs/. // Usage: node scripts/website.mjs site/dist build/website import fs from 'node:fs'; import path from 'node:path'; +import rehypeStringify from 'rehype-stringify'; +import remarkGfm from 'remark-gfm'; +import remarkParse from 'remark-parse'; +import remarkRehype from 'remark-rehype'; +import { unified } from 'unified'; +import YAML from 'yaml'; const MOUNT = 'docs'; const [docs = 'site/dist', out = 'build/website'] = process.argv.slice(2).map((p) => path.resolve(p)); const repo = path.resolve(import.meta.dirname, '..'); +const www = path.join(repo, 'www'); const { base } = JSON.parse(fs.readFileSync(path.join(docs, 'versions.json'), 'utf8')); if (base !== `/${MOUNT}/`) { @@ -18,7 +27,7 @@ if (base !== `/${MOUNT}/`) { } fs.rmSync(out, { recursive: true, force: true }); -fs.cpSync(path.join(repo, 'www'), out, { recursive: true }); +fs.cpSync(www, out, { recursive: true, filter: (f) => path.extname(f) !== '.md' }); fs.copyFileSync(path.join(repo, 'theme/tokens.css'), path.join(out, 'tokens.css')); for (const f of ['favicon.svg', 'apple-touch-icon.png', 'cncf']) fs.cpSync(path.join(repo, 'site/static', f), path.join(out, f), { recursive: true }); @@ -26,4 +35,39 @@ fs.cpSync(docs, path.join(out, MOUNT), { recursive: true }); // Hosts serve /404.html for any missing path. The docs one links its assets // absolutely (/docs/_astro/...), so it works at the root too. fs.copyFileSync(path.join(docs, '404.html'), path.join(out, '404.html')); -console.log(`website -> ${path.relative(process.cwd(), out)} (landing at /, docs at /${MOUNT}/)`); + +// Markdown pages. +const shell = fs.readFileSync(path.join(www, 'index.html'), 'utf8'); +const htmlEscape = (s) => s.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); +const swap = (html, re, to, what) => { + if (!re.test(html)) throw new Error(`www/index.html has no ${what}`); + return html.replace(re, () => to); +}; +const render = unified().use(remarkParse).use(remarkGfm).use(remarkRehype).use(rehypeStringify); +const pages = fs.readdirSync(www).filter((f) => f.endsWith('.md')); +for (const file of pages) { + const name = path.basename(file, '.md'); + const src = fs.readFileSync(path.join(www, file), 'utf8'); + const m = src.match(/^---\n([\s\S]*?)\n---\n/); + const meta = m ? YAML.parse(m[1]) : {}; + if (!meta?.title || !meta.description) + throw new Error(`www/${file} needs a title and description in its front matter`); + const body = src.slice(m[0].length).trim(); + const main = `
\n

${htmlEscape(meta.title)}

\n${String(render.processSync(body))}\n
`; + let html = swap(shell, /[^<]*<\/title>/, `<title>${htmlEscape(meta.title)} · OpenShell`, ''); + html = swap( + html, + /<meta name="description" content="[^"]*" \/>/, + `<meta name="description" content="${htmlEscape(meta.description)}" />`, + 'description meta tag', + ); + html = swap(html, /<main>[\s\S]*<\/main>/, main, '<main>'); + html = html.replace(`href="/${name}/" class="nav-link"`, `href="/${name}/" class="nav-link" aria-current="page"`); + fs.mkdirSync(path.join(out, name), { recursive: true }); + fs.writeFileSync(path.join(out, name, 'index.html'), html); + fs.writeFileSync(path.join(out, `${name}.md`), `# ${meta.title}\n\n${body}\n`); +} + +console.log( + `website -> ${path.relative(process.cwd(), out)} (landing at /, ${pages.length} Markdown pages, docs at /${MOUNT}/)`, +); diff --git a/www/community.md b/www/community.md new file mode 100644 index 0000000..454c910 --- /dev/null +++ b/www/community.md @@ -0,0 +1,24 @@ +--- +# SPDX-License-Identifier: Apache-2.0 +title: Community +description: Where to talk to the OpenShell community and how to contribute. +--- + +OpenShell is a [Cloud Native Computing Foundation](https://www.cncf.io/) +sandbox project, built in the open. Everyone is welcome to ask questions, share +what they're building, and contribute. + +## Chat + +Join the `#openshell` channel in the [CNCF Slack](https://slack.cncf.io/) to +ask questions and talk with maintainers and other users. + +## Contributing + +OpenShell, its SDKs, and this website are developed on GitHub in the +[ai-openshell](https://github.com/ai-openshell) organization. + +- Read the [contributing guide](https://github.com/ai-openshell/openshell/blob/main/CONTRIBUTING.md) + before you open a pull request. +- Report bugs and request features in + [GitHub issues](https://github.com/ai-openshell/openshell/issues). diff --git a/www/index.html b/www/index.html index 087caef..d4756cf 100644 --- a/www/index.html +++ b/www/index.html @@ -1,6 +1,6 @@ <!doctype html> <!-- SPDX-License-Identifier: Apache-2.0 --> -<!-- The landing page at /. Everything in www/ is served at the site root; scripts/website.mjs publishes it next to the docs build at /docs/. --> +<!-- The landing page at /. Everything in www/ is served at the site root; scripts/website.mjs publishes it next to the docs build at /docs/. The www/*.md pages reuse this file as their shell: everything except the title, the description, and the main element. --> <html lang="en"> <head> <meta charset="utf-8" /> @@ -43,7 +43,8 @@ </a> <nav aria-label="Site"> <a href="/docs/" class="nav-link">Docs</a> - <a href="https://github.com/ai-openshell/openshell" class="icon-link"> + <a href="/community/" class="nav-link">Community</a> + <a href="https://github.com/ai-openshell" class="icon-link"> <span class="sr-only">GitHub</span> <svg viewBox="0 0 24 24" aria-hidden="true"> <path diff --git a/www/style.css b/www/style.css index a4033aa..64a0330 100644 --- a/www/style.css +++ b/www/style.css @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: Apache-2.0 */ -/* Landing page styles (www/index.html). Colors and fonts come from theme/tokens.css (--os-*); - text, card, and code colors follow site/src/styles/theme.css so the page - matches the docs. */ +/* Styles for the pages in www/: the landing page and the Markdown pages. + Colors and fonts come from theme/tokens.css (--os-*); text, card, and code + colors follow site/src/styles/theme.css so the pages match the docs. */ :root { --text: #d3d8cc; --strong: var(--os-fg); @@ -107,7 +107,8 @@ a:hover { font-weight: 500; text-decoration: none; } -.nav-link:hover { +.nav-link:hover, +.nav-link[aria-current="page"] { color: var(--strong); } .icon-link { @@ -160,6 +161,30 @@ h2 { color: var(--os-muted); } +/* ---------- Markdown pages (www/*.md) ---------- */ +.page { + max-width: 48rem; + padding-top: 3.5rem; + padding-bottom: 3rem; +} +.page h1 { + margin: 0 0 1rem; + font-size: clamp(2rem, 4.5vw, 2.75rem); + line-height: 1.1; + letter-spacing: -0.03em; +} +.page h2 { + margin: 2.5rem 0 0.5rem; +} +.page code { + font-family: var(--os-font-mono); + font-size: 0.875em; + color: var(--strong); +} +.page li + li { + margin-top: 0.25rem; +} + /* ---------- hero ---------- */ .hero { padding: 5.5rem 0 3rem; From 1e3942507a2a24284a6eab989170ed3892b15edc Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:02:18 -0800 Subject: [PATCH 04/15] docs: describe website pages, Markdown for agents, and hosting Covers adding Markdown pages, the .md copies and llms.txt the site publishes for agents, and hosting on Netlify under the CNCF account. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 6e2ea3a..8475bda 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,40 @@ The published website serves a small landing page from [`www/`](www/) at `/` and the docs at `/docs/`. [`scripts/website.mjs`](scripts/website.mjs) combines the two after the docs build. +## Website pages + +The landing page, [`www/index.html`](www/index.html), is hand-written HTML. Other +pages outside the docs, such as `/community/`, are Markdown files in `www/` +with a `title` and `description` in their front matter. `scripts/website.mjs` +renders each `www/<name>.md` into the landing page's header and footer at +`/<name>/`. To add a page, add a Markdown file and link it from the header in +`www/index.html`. `mise run website` builds the whole website, and +`mise run serve-website` serves it. + +## Markdown for agents + +Every page has a Markdown copy at its URL plus `.md`, such as +`/docs/about/overview.md` or `/community.md`. The docs list theirs in +`/docs/llms.txt`, and each docs page links to its copy in the page actions menu +(Copy page, View as Markdown, Open in Claude or ChatGPT). + +The assembler writes the docs copies from each page's source, so they keep +the source's text rather than the rendered HTML. Source repositories can mark +content for one output only: `<llms-only>` blocks appear only in the Markdown +copy, and `<llms-ignore>` blocks only on the site. + +## Hosting + +The website is hosted on [Netlify](https://www.netlify.com/) under the CNCF's +account. [`netlify.toml`](netlify.toml) holds the build settings, which +override the Netlify UI: Netlify runs `npm run build && npm run website` with +`BASE_PATH=/docs/` and publishes `build/website`. Netlify also builds a deploy +preview for each pull request. + +The [Site workflow](.github/workflows/site.yml) also builds the docs on every +pull request and publishes them to GitHub Pages from `main`, at +`/<repository>/` and without the landing page. + ## Run it locally ```shell From 1c62a3eda8a833fe81704ae4c7c1ffe756a1797b Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:09:31 -0800 Subject: [PATCH 05/15] feat(site): share one header between the landing page and the docs The docs header now has the same site bar as the landing page: the wordmark and the Docs and Community links on the left, then search (docs only), GitHub, and a light/dark toggle. Both read their links and the GitHub URL from theme/nav.json, so a new page needs one entry. The docs toggle replaces Starlight's theme select in the header and keeps the mobile menu's select in sync. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- README.md | 5 +- scripts/website.mjs | 24 +++++++-- site/astro.config.mjs | 3 +- site/src/components/overrides/Header.astro | 34 +++++++++--- site/src/styles/theme.css | 60 +++++++++++++++++----- theme/nav.json | 4 ++ theme/nav.json.license | 1 + www/index.html | 10 ++-- www/style.css | 15 +++++- 9 files changed, 121 insertions(+), 35 deletions(-) create mode 100644 theme/nav.json create mode 100644 theme/nav.json.license diff --git a/README.md b/README.md index 8475bda..4a9aaa2 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,9 @@ The landing page, [`www/index.html`](www/index.html), is hand-written HTML. Othe pages outside the docs, such as `/community/`, are Markdown files in `www/` with a `title` and `description` in their front matter. `scripts/website.mjs` renders each `www/<name>.md` into the landing page's header and footer at -`/<name>/`. To add a page, add a Markdown file and link it from the header in -`www/index.html`. `mise run website` builds the whole website, and +`/<name>/`. To add a page, add a Markdown file and its link to +[`theme/nav.json`](theme/nav.json). The landing page and the docs share one +header, and both read their links from that file. `mise run website` builds the whole website, and `mise run serve-website` serves it. ## Markdown for agents diff --git a/scripts/website.mjs b/scripts/website.mjs index 4b7a3fc..eb12df5 100644 --- a/scripts/website.mjs +++ b/scripts/website.mjs @@ -36,13 +36,30 @@ fs.cpSync(docs, path.join(out, MOUNT), { recursive: true }); // absolutely (/docs/_astro/...), so it works at the root too. fs.copyFileSync(path.join(docs, '404.html'), path.join(out, '404.html')); -// Markdown pages. -const shell = fs.readFileSync(path.join(www, 'index.html'), 'utf8'); const htmlEscape = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); const swap = (html, re, to, what) => { if (!re.test(html)) throw new Error(`www/index.html has no ${what}`); return html.replace(re, () => to); }; + +// The header links come from theme/nav.json, which the docs header also reads. +const nav = JSON.parse(fs.readFileSync(path.join(repo, 'theme/nav.json'), 'utf8')); +const withNav = (html, current) => { + const links = nav.links + .map( + (l) => + `<a href="${htmlEscape(l.href)}" class="nav-link"${l.href === current ? ' aria-current="page"' : ''}>${htmlEscape(l.label)}</a>`, + ) + .join(''); + html = swap(html, /<!-- nav-links -->/, links, '<!-- nav-links --> placeholder'); + return swap(html, /\{\{github\}\}/, htmlEscape(nav.github), '{{github}} placeholder'); +}; + +// The landing page. +const shell = fs.readFileSync(path.join(www, 'index.html'), 'utf8'); +fs.writeFileSync(path.join(out, 'index.html'), withNav(shell, '/')); + +// Markdown pages. const render = unified().use(remarkParse).use(remarkGfm).use(remarkRehype).use(rehypeStringify); const pages = fs.readdirSync(www).filter((f) => f.endsWith('.md')); for (const file of pages) { @@ -61,8 +78,7 @@ for (const file of pages) { `<meta name="description" content="${htmlEscape(meta.description)}" />`, 'description meta tag', ); - html = swap(html, /<main>[\s\S]*<\/main>/, main, '<main>'); - html = html.replace(`href="/${name}/" class="nav-link"`, `href="/${name}/" class="nav-link" aria-current="page"`); + html = withNav(swap(html, /<main>[\s\S]*<\/main>/, main, '<main>'), `/${name}/`); fs.mkdirSync(path.join(out, name), { recursive: true }); fs.writeFileSync(path.join(out, name, 'index.html'), html); fs.writeFileSync(path.join(out, `${name}.md`), `# ${meta.title}\n\n${body}\n`); diff --git a/site/astro.config.mjs b/site/astro.config.mjs index e36529c..bd4dba3 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -4,6 +4,7 @@ import starlight from '@astrojs/starlight'; import { defineConfig } from 'astro/config'; +import siteNav from '../theme/nav.json' with { type: 'json' }; // BASE_PATH is the path the site is served under (GitHub Pages: /<repo>/). export default defineConfig({ @@ -15,7 +16,7 @@ export default defineConfig({ title: 'OpenShell', description: 'The safe, private runtime for autonomous AI agents.', favicon: '/favicon.svg', - social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/ai-openshell' }], + social: [{ icon: 'github', label: 'GitHub', href: siteNav.github }], customCss: ['./src/styles/tokens.css', './src/styles/theme.css'], head: [ { diff --git a/site/src/components/overrides/Header.astro b/site/src/components/overrides/Header.astro index 79fefe4..788a392 100644 --- a/site/src/components/overrides/Header.astro +++ b/site/src/components/overrides/Header.astro @@ -1,12 +1,14 @@ --- // SPDX-License-Identifier: Apache-2.0 -// Header: wordmark / search / theme, then topic tabs, then (in topics with an -// overview page) sub-tabs for the overview and each docset. +// Header: the site bar (wordmark, site links, search, GitHub, theme), then +// topic tabs, then (in topics with an overview page) sub-tabs for the overview +// and each docset. The site bar matches the landing page header (www/index.html); +// both take their links from theme/nav.json. // Tab and sub-tab links come from src/routeData.ts and follow the current // page's version context. +import { Icon } from '@astrojs/starlight/components'; import Search from '@astrojs/starlight/components/Search.astro'; -import SocialIcons from '@astrojs/starlight/components/SocialIcons.astro'; -import ThemeSelect from '@astrojs/starlight/components/ThemeSelect.astro'; +import siteNav from '../../../../theme/nav.json'; const os = Astro.locals.osVersion; const topics = os?.topics ?? []; @@ -30,10 +32,18 @@ const subtabs = ds <svg viewBox="14 7 72 87" aria-hidden="true" class="os-wordmark__mark"><path d="M50 9 L84 23 V51 C84 72 69 86 50 92 C31 86 16 72 16 51 V23 Z" fill="#76B900"/><g fill="none" stroke="#FFFFFF" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"><path d="M37 41 L49 50 L37 59"/><path d="M55 59 H67"/></g></svg> <span>OpenShell</span> </a> + <nav class="os-site-links print:hidden" aria-label="Site"> + {siteNav.links.map((l) => ( + <a href={l.href} class="os-site-link" aria-current={l.href === import.meta.env.BASE_URL ? 'page' : undefined}>{l.label}</a> + ))} + </nav> <div class="os-header__search print:hidden"><Search /></div> - <div class="os-header__end print:hidden"> - <div class="sl-hidden md:sl-flex os-header__social"><SocialIcons /></div> - <div class="sl-hidden md:sl-flex"><ThemeSelect /></div> + <div class="os-header__end print:hidden sl-hidden md:sl-flex"> + <a href={siteNav.github} class="os-icon-button"><span class="sr-only">GitHub</span><Icon name="github" /></a> + <button type="button" class="os-icon-button os-theme-toggle" aria-label="Toggle dark mode"> + <Icon name="sun" class="os-theme-toggle__sun" /> + <Icon name="moon" class="os-theme-toggle__moon" /> + </button> </div> </div> <nav class="os-tabs print:hidden" aria-label="Topics"> @@ -67,6 +77,16 @@ const subtabs = ds </div> <script> + // Same behavior as the landing page toggle. Starlight keeps the choice in + // localStorage (starlight-theme); the mobile menu's theme select follows it. + document.querySelector('.os-theme-toggle')?.addEventListener('click', () => { + const t = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark'; + document.documentElement.dataset.theme = t; + try { + localStorage.setItem('starlight-theme', t); + } catch {} + (window as { StarlightThemeProvider?: { updatePickers(t: string): void } }).StarlightThemeProvider?.updatePickers(t); + }); document.addEventListener('click', (e) => { for (const d of document.querySelectorAll<HTMLDetailsElement>('details.os-subtabs__menu[open]')) if (!d.contains(e.target as Node)) d.open = false; diff --git a/site/src/styles/theme.css b/site/src/styles/theme.css index 8a53b45..4a7a16e 100644 --- a/site/src/styles/theme.css +++ b/site/src/styles/theme.css @@ -221,17 +221,41 @@ body { color: var(--os-muted); } +/* Site links next to the wordmark; same as the landing page's .nav-link */ +.os-site-links { + display: flex; + align-items: center; + gap: 0.25rem; +} +.os-site-link { + padding: 0.25rem 0.625rem; + color: var(--os-muted); + font-size: 0.875rem; + font-weight: 500; + text-decoration: none; + white-space: nowrap; +} +.os-site-link:hover, +.os-site-link[aria-current="page"] { + color: var(--os-fg); +} +@media (max-width: 50em) { + .os-header__row { + gap: 0.5rem; + } + .os-site-link { + padding-inline: 0.375rem; + } +} + .os-header__search { flex: 1; display: flex; justify-content: flex-end; } @media (min-width: 50em) { - .os-header__search { - justify-content: center; - } .os-header__search button[data-open-modal] { - max-width: 24rem; + max-width: 16rem; height: 2.25rem; border-radius: var(--os-radius); background: var(--os-surface); @@ -253,22 +277,30 @@ body { } } .os-header__end { - display: flex; - align-items: center; - gap: 0.75rem; -} -.os-header__social { align-items: center; - gap: 0.75rem; + gap: 0.25rem; } -.os-header__social a { +/* GitHub link and theme toggle; same as the landing page's .icon-link */ +.os-icon-button { + display: grid; + place-items: center; + width: 2rem; + height: 2rem; + padding: 0; + border: 0; + border-radius: var(--os-radius); + background: none; color: var(--os-muted); + font-size: 1.125rem; + cursor: pointer; } -.os-header__social a:hover { +.os-icon-button:hover { color: var(--os-fg); + background: var(--os-surface); } -.os-header__end starlight-theme-select select { - font-size: 0.8125rem; +:root[data-theme="dark"] .os-theme-toggle__moon, +:root[data-theme="light"] .os-theme-toggle__sun { + display: none; } .os-tabs { diff --git a/theme/nav.json b/theme/nav.json new file mode 100644 index 0000000..19f0920 --- /dev/null +++ b/theme/nav.json @@ -0,0 +1,4 @@ +{ + "links": [{ "label": "Docs", "href": "/docs/" }, { "label": "Community", "href": "/community/" }], + "github": "https://github.com/ai-openshell" +} diff --git a/theme/nav.json.license b/theme/nav.json.license new file mode 100644 index 0000000..1abba28 --- /dev/null +++ b/theme/nav.json.license @@ -0,0 +1 @@ +SPDX-License-Identifier: Apache-2.0 diff --git a/www/index.html b/www/index.html index d4756cf..f236e78 100644 --- a/www/index.html +++ b/www/index.html @@ -41,10 +41,10 @@ </svg> <span>OpenShell</span> </a> - <nav aria-label="Site"> - <a href="/docs/" class="nav-link">Docs</a> - <a href="/community/" class="nav-link">Community</a> - <a href="https://github.com/ai-openshell" class="icon-link"> + <!-- Links and the GitHub URL come from theme/nav.json, shared with the docs header; scripts/website.mjs fills them in. --> + <nav aria-label="Site" class="site-links"><!-- nav-links --></nav> + <div class="top-end"> + <a href="{{github}}" class="icon-link"> <span class="sr-only">GitHub</span> <svg viewBox="0 0 24 24" aria-hidden="true"> <path @@ -73,7 +73,7 @@ /> </svg> </button> - </nav> + </div> </header> <main> diff --git a/www/style.css b/www/style.css index 64a0330..af58fe8 100644 --- a/www/style.css +++ b/www/style.css @@ -72,7 +72,6 @@ a:hover { z-index: 10; display: flex; align-items: center; - justify-content: space-between; height: var(--os-header-h); padding: 0 1.5rem; border-bottom: 1px solid var(--os-border); @@ -95,7 +94,16 @@ a:hover { width: auto; } -.top nav { +/* Same layout as the docs header (site/src/components/overrides/Header.astro): + wordmark and site links on the left, GitHub and theme on the right. */ +.site-links { + display: flex; + align-items: center; + gap: 0.25rem; + margin-inline-start: 1rem; + margin-inline-end: auto; +} +.top-end { display: flex; align-items: center; gap: 0.25rem; @@ -454,6 +462,9 @@ a.card:hover .arrow { .top { padding: 0 1rem; } + .site-links { + margin-inline-start: 0.5rem; + } main { padding: 0 1rem; } From ec0ff880f246346d958c8ac35370262ad819853d Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:10:02 -0800 Subject: [PATCH 06/15] docs: drop release numbers from the README The docset table listed each published release and went stale with every release. It now names each docset's dev branch; sources.yml is the list of releases. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4a9aaa2..d7e4983 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ docs of several repositories. Each repository keeps its docs next to its code and ships them with its releases. This repository holds no page content: it owns the build, the theme, and the navigation. -| Docset | Repository | Path | Versions | -| --------- | ------------------------------------------------------------------- | ----------- | --------------------------------- | -| OpenShell | [ai-openshell/openshell](https://github.com/ai-openshell/openshell) | `docs/` | dev (`main`), 0.1.9, 0.1.8, 0.1.7 | -| Go SDK | [ai-openshell/sdk-go](https://github.com/ai-openshell/sdk-go) | `docs/src/` | dev (`main`), 0.1.8, 0.1.7 | +| Docset | Repository | Path | Dev branch | +| --------- | ------------------------------------------------------------------- | ----------- | ---------- | +| OpenShell | [ai-openshell/openshell](https://github.com/ai-openshell/openshell) | `docs/` | `main` | +| Go SDK | [ai-openshell/sdk-go](https://github.com/ai-openshell/sdk-go) | `docs/src/` | `main` | ## How it works @@ -21,7 +21,7 @@ branch, reads it in its own format (Fern `index.yml`, mdBook `SUMMARY.md`, or [Starlight](https://starlight.astro.build/). The newest release of each repository is published without a version in the URL, such as `/about/overview/` or `/sdks/go/`, so links always show the current docs. Other -versions have their own path, such as `/0.1.8/about/overview/` or +versions have their own path, such as `/<version>/about/overview/` or `/sdks/go/dev/`. Broken links in fetched versions are warnings, so one repository can't block From bf5781a160df5de2b0af838dcd77ce3949a5be10 Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:13:46 -0800 Subject: [PATCH 07/15] feat(site): link the docs wordmark home and set the site links apart The OpenShell wordmark in the docs header now goes to the landing page at / instead of the docs home. The Docs and Community links use the body text color at a slightly larger size, sit after a divider further from the wordmark, and turn the accent color on hover and for the current section. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- site/src/components/overrides/Header.astro | 2 +- site/src/styles/theme.css | 21 +++++++++++++++------ www/style.css | 21 ++++++++++++++------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/site/src/components/overrides/Header.astro b/site/src/components/overrides/Header.astro index 788a392..33ae64d 100644 --- a/site/src/components/overrides/Header.astro +++ b/site/src/components/overrides/Header.astro @@ -27,7 +27,7 @@ const subtabs = ds <div class="os-header"> <div class="os-header__row"> - <a href={import.meta.env.BASE_URL} class="os-wordmark" translate="no"> + <a href="/" class="os-wordmark" translate="no"> <!-- The OpenShell shield (ai-openshell/openshell docs/brand/assets/openshell-mark.svg), cropped to the shield --> <svg viewBox="14 7 72 87" aria-hidden="true" class="os-wordmark__mark"><path d="M50 9 L84 23 V51 C84 72 69 86 50 92 C31 86 16 72 16 51 V23 Z" fill="#76B900"/><g fill="none" stroke="#FFFFFF" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"><path d="M37 41 L49 50 L37 59"/><path d="M55 59 H67"/></g></svg> <span>OpenShell</span> diff --git a/site/src/styles/theme.css b/site/src/styles/theme.css index 4a7a16e..3779b25 100644 --- a/site/src/styles/theme.css +++ b/site/src/styles/theme.css @@ -221,28 +221,37 @@ body { color: var(--os-muted); } -/* Site links next to the wordmark; same as the landing page's .nav-link */ +/* Site links next to the wordmark, set off by a divider; same as the landing + page's .site-links */ .os-site-links { display: flex; align-items: center; - gap: 0.25rem; + gap: 0.5rem; + margin-inline-start: 0.75rem; + padding-inline-start: 1rem; + border-inline-start: 1px solid var(--os-border); } .os-site-link { - padding: 0.25rem 0.625rem; - color: var(--os-muted); - font-size: 0.875rem; + padding: 0.25rem 0.5rem; + color: var(--os-fg); + font-size: 0.9375rem; font-weight: 500; text-decoration: none; white-space: nowrap; } .os-site-link:hover, .os-site-link[aria-current="page"] { - color: var(--os-fg); + color: var(--os-accent-text); } @media (max-width: 50em) { .os-header__row { gap: 0.5rem; } + .os-site-links { + gap: 0; + margin-inline-start: 0.25rem; + padding-inline-start: 0.5rem; + } .os-site-link { padding-inline: 0.375rem; } diff --git a/www/style.css b/www/style.css index af58fe8..21f0253 100644 --- a/www/style.css +++ b/www/style.css @@ -99,9 +99,11 @@ a:hover { .site-links { display: flex; align-items: center; - gap: 0.25rem; - margin-inline-start: 1rem; + gap: 0.5rem; + margin-inline-start: 1.75rem; margin-inline-end: auto; + padding-inline-start: 1rem; + border-inline-start: 1px solid var(--os-border); } .top-end { display: flex; @@ -109,15 +111,15 @@ a:hover { gap: 0.25rem; } .nav-link { - padding: 0.25rem 0.625rem; - color: var(--os-muted); - font-size: 0.875rem; + padding: 0.25rem 0.5rem; + color: var(--strong); + font-size: 0.9375rem; font-weight: 500; text-decoration: none; } .nav-link:hover, .nav-link[aria-current="page"] { - color: var(--strong); + color: var(--os-accent-text); } .icon-link { display: grid; @@ -463,7 +465,12 @@ a.card:hover .arrow { padding: 0 1rem; } .site-links { - margin-inline-start: 0.5rem; + gap: 0; + margin-inline-start: 0.75rem; + padding-inline-start: 0.5rem; + } + .nav-link { + padding-inline: 0.375rem; } main { padding: 0 1rem; From 1e120a6bafef859992bf1911f5244930d521970e Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:20:24 -0800 Subject: [PATCH 08/15] fix(site): link the #openshell-dev Slack channel The community page now links the channel directly and keeps slack.cncf.io for people without a CNCF Slack account. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- www/community.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/community.md b/www/community.md index 454c910..1dd40de 100644 --- a/www/community.md +++ b/www/community.md @@ -10,8 +10,10 @@ what they're building, and contribute. ## Chat -Join the `#openshell` channel in the [CNCF Slack](https://slack.cncf.io/) to -ask questions and talk with maintainers and other users. +Join [`#openshell-dev`](https://cloud-native.slack.com/archives/C0B6Y8WQHU1) +in the CNCF Slack to ask questions and talk with maintainers and other users. +If you don't have a CNCF Slack account yet, get an invite at +[slack.cncf.io](https://slack.cncf.io/). ## Contributing From da2acad8abb141bc92f89bad78bce1535c38b67f Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:20:24 -0800 Subject: [PATCH 09/15] feat(site): share an auto/light/dark theme toggle between the landing page and the docs theme/theme-toggle.html and theme-toggle.js hold one toggle that both headers use. Each click cycles auto, light, dark; auto follows the system setting. The choice is stored where Starlight keeps it, so it carries between the landing page and the docs and the docs mobile menu's theme select stays in sync. Both headers now show the same icons, including one for auto. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- scripts/website.mjs | 7 ++- site/astro.config.mjs | 7 +++ site/src/components/overrides/Header.astro | 21 +++------ site/src/styles/theme.css | 10 ++--- theme/theme-toggle.html | 27 ++++++++++++ theme/theme-toggle.js | 51 ++++++++++++++++++++++ www/index.html | 40 ++++------------- www/style.css | 10 ++--- 8 files changed, 114 insertions(+), 59 deletions(-) create mode 100644 theme/theme-toggle.html create mode 100644 theme/theme-toggle.js diff --git a/scripts/website.mjs b/scripts/website.mjs index eb12df5..ebc16a9 100644 --- a/scripts/website.mjs +++ b/scripts/website.mjs @@ -28,7 +28,7 @@ if (base !== `/${MOUNT}/`) { fs.rmSync(out, { recursive: true, force: true }); fs.cpSync(www, out, { recursive: true, filter: (f) => path.extname(f) !== '.md' }); -fs.copyFileSync(path.join(repo, 'theme/tokens.css'), path.join(out, 'tokens.css')); +for (const f of ['tokens.css', 'theme-toggle.js']) fs.copyFileSync(path.join(repo, 'theme', f), path.join(out, f)); for (const f of ['favicon.svg', 'apple-touch-icon.png', 'cncf']) fs.cpSync(path.join(repo, 'site/static', f), path.join(out, f), { recursive: true }); fs.cpSync(docs, path.join(out, MOUNT), { recursive: true }); @@ -43,7 +43,11 @@ const swap = (html, re, to, what) => { }; // The header links come from theme/nav.json, which the docs header also reads. +// So does the theme toggle (theme/theme-toggle.html and .js). const nav = JSON.parse(fs.readFileSync(path.join(repo, 'theme/nav.json'), 'utf8')); +const themeToggle = fs + .readFileSync(path.join(repo, 'theme/theme-toggle.html'), 'utf8') + .replace(/^<!--[\s\S]*?-->\n/gm, ''); const withNav = (html, current) => { const links = nav.links .map( @@ -52,6 +56,7 @@ const withNav = (html, current) => { ) .join(''); html = swap(html, /<!-- nav-links -->/, links, '<!-- nav-links --> placeholder'); + html = swap(html, /<!-- theme-toggle -->/, themeToggle, '<!-- theme-toggle --> placeholder'); return swap(html, /\{\{github\}\}/, htmlEscape(nav.github), '{{github}} placeholder'); }; diff --git a/site/astro.config.mjs b/site/astro.config.mjs index bd4dba3..b0c40a6 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -19,6 +19,13 @@ export default defineConfig({ social: [{ icon: 'github', label: 'GitHub', href: siteNav.github }], customCss: ['./src/styles/tokens.css', './src/styles/theme.css'], head: [ + // Mark the stored theme choice before paint so the header's theme toggle + // (theme/theme-toggle.html) shows the right icon; Starlight sets data-theme. + { + tag: 'script', + content: + "try{const t=localStorage.getItem('starlight-theme');document.documentElement.dataset.themeChoice=t==='light'||t==='dark'?t:'auto'}catch{}", + }, { tag: 'link', attrs: { rel: 'apple-touch-icon', href: `${process.env.BASE_PATH ?? '/'}apple-touch-icon.png` }, diff --git a/site/src/components/overrides/Header.astro b/site/src/components/overrides/Header.astro index 33ae64d..e30205e 100644 --- a/site/src/components/overrides/Header.astro +++ b/site/src/components/overrides/Header.astro @@ -3,12 +3,14 @@ // Header: the site bar (wordmark, site links, search, GitHub, theme), then // topic tabs, then (in topics with an overview page) sub-tabs for the overview // and each docset. The site bar matches the landing page header (www/index.html); -// both take their links from theme/nav.json. +// both take their links from theme/nav.json and the theme toggle from +// theme/theme-toggle.html and .js. // Tab and sub-tab links come from src/routeData.ts and follow the current // page's version context. import { Icon } from '@astrojs/starlight/components'; import Search from '@astrojs/starlight/components/Search.astro'; import siteNav from '../../../../theme/nav.json'; +import themeToggle from '../../../../theme/theme-toggle.html?raw'; const os = Astro.locals.osVersion; const topics = os?.topics ?? []; @@ -40,10 +42,7 @@ const subtabs = ds <div class="os-header__search print:hidden"><Search /></div> <div class="os-header__end print:hidden sl-hidden md:sl-flex"> <a href={siteNav.github} class="os-icon-button"><span class="sr-only">GitHub</span><Icon name="github" /></a> - <button type="button" class="os-icon-button os-theme-toggle" aria-label="Toggle dark mode"> - <Icon name="sun" class="os-theme-toggle__sun" /> - <Icon name="moon" class="os-theme-toggle__moon" /> - </button> + <Fragment set:html={themeToggle} /> </div> </div> <nav class="os-tabs print:hidden" aria-label="Topics"> @@ -77,16 +76,8 @@ const subtabs = ds </div> <script> - // Same behavior as the landing page toggle. Starlight keeps the choice in - // localStorage (starlight-theme); the mobile menu's theme select follows it. - document.querySelector('.os-theme-toggle')?.addEventListener('click', () => { - const t = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark'; - document.documentElement.dataset.theme = t; - try { - localStorage.setItem('starlight-theme', t); - } catch {} - (window as { StarlightThemeProvider?: { updatePickers(t: string): void } }).StarlightThemeProvider?.updatePickers(t); - }); + import '../../../../theme/theme-toggle.js'; + document.addEventListener('click', (e) => { for (const d of document.querySelectorAll<HTMLDetailsElement>('details.os-subtabs__menu[open]')) if (!d.contains(e.target as Node)) d.open = false; diff --git a/site/src/styles/theme.css b/site/src/styles/theme.css index 3779b25..2b63c6d 100644 --- a/site/src/styles/theme.css +++ b/site/src/styles/theme.css @@ -290,7 +290,8 @@ body { gap: 0.25rem; } /* GitHub link and theme toggle; same as the landing page's .icon-link */ -.os-icon-button { +.os-icon-button, +.theme-toggle { display: grid; place-items: center; width: 2rem; @@ -303,14 +304,11 @@ body { font-size: 1.125rem; cursor: pointer; } -.os-icon-button:hover { +.os-icon-button:hover, +.theme-toggle:hover { color: var(--os-fg); background: var(--os-surface); } -:root[data-theme="dark"] .os-theme-toggle__moon, -:root[data-theme="light"] .os-theme-toggle__sun { - display: none; -} .os-tabs { display: flex; diff --git a/theme/theme-toggle.html b/theme/theme-toggle.html new file mode 100644 index 0000000..82cc3d5 --- /dev/null +++ b/theme/theme-toggle.html @@ -0,0 +1,27 @@ +<!-- SPDX-License-Identifier: Apache-2.0 --> +<!-- Theme toggle shared by the landing page (scripts/website.mjs) and the docs header (Header.astro). theme-toggle.js cycles auto, light, dark and sets data-theme-choice on <html>. Each host styles the button through the .theme-toggle class. --> +<button type="button" class="theme-toggle" aria-label="Theme: auto. Switch theme" title="Theme: auto"> + <svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__auto"> + <rect x="3" y="4.5" width="18" height="12" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.75" /> + <path d="M8 20h8M12 16.5V20" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" /> + </svg> + <svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__light"> + <circle cx="12" cy="12" r="4" fill="none" stroke="currentColor" stroke-width="1.75" /> + <path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" /> + </svg> + <svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__dark"> + <path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linejoin="round" /> + </svg> +</button> +<style> + .theme-toggle svg { + width: 1.125rem; + height: 1.125rem; + } + :root:not([data-theme-choice="light"]) .theme-toggle__light, + :root:not([data-theme-choice="dark"]) .theme-toggle__dark, + :root[data-theme-choice="light"] .theme-toggle__auto, + :root[data-theme-choice="dark"] .theme-toggle__auto { + display: none; + } +</style> diff --git a/theme/theme-toggle.js b/theme/theme-toggle.js new file mode 100644 index 0000000..49b4e78 --- /dev/null +++ b/theme/theme-toggle.js @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: Apache-2.0 +// Theme toggle shared by the landing page and the docs header (markup in +// theme-toggle.html). Each click cycles auto -> light -> dark. The choice is +// stored where Starlight keeps it (localStorage starlight-theme, '' for auto), +// so it carries between the landing page and the docs, and Starlight's own +// theme select in the docs mobile menu stays in sync. +const KEY = 'starlight-theme'; +const ORDER = ['auto', 'light', 'dark']; +const light = matchMedia('(prefers-color-scheme: light)'); + +const stored = () => { + try { + const v = localStorage.getItem(KEY); + return v === 'light' || v === 'dark' ? v : 'auto'; + } catch { + return undefined; + } +}; +let choice = stored() ?? 'auto'; + +function apply() { + const root = document.documentElement; + root.dataset.themeChoice = choice; + root.dataset.theme = choice === 'auto' ? (light.matches ? 'light' : 'dark') : choice; + for (const b of document.querySelectorAll('.theme-toggle')) { + b.title = `Theme: ${choice}`; + b.setAttribute('aria-label', `Theme: ${choice}. Switch theme`); + } + window.StarlightThemeProvider?.updatePickers(choice); +} + +document.addEventListener('click', (e) => { + if (!(e.target instanceof Element) || !e.target.closest('.theme-toggle')) return; + choice = ORDER[(ORDER.indexOf(stored() ?? choice) + 1) % ORDER.length]; + try { + localStorage.setItem(KEY, choice === 'auto' ? '' : choice); + } catch {} + apply(); +}); +light.addEventListener('change', () => choice === 'auto' && apply()); +// Follow Starlight's select in the docs mobile menu, and other tabs. +const sync = () => { + choice = stored() ?? choice; + apply(); +}; +document.addEventListener( + 'change', + (e) => e.target instanceof Element && e.target.closest('starlight-theme-select') && sync(), +); +addEventListener('storage', (e) => e.key === KEY && sync()); +apply(); diff --git a/www/index.html b/www/index.html index f236e78..dc435c3 100644 --- a/www/index.html +++ b/www/index.html @@ -18,14 +18,17 @@ <link rel="stylesheet" href="/tokens.css" /> <link rel="stylesheet" href="/style.css" /> <script> - // Share the theme choice with the docs: Starlight stores it as starlight-theme. + // Apply the theme before the page paints. Starlight stores the choice as + // starlight-theme ('' for auto); theme-toggle.js handles changes. (() => { let t = ''; try { t = localStorage.getItem('starlight-theme') ?? ''; } catch {} - if (t !== 'light' && t !== 'dark') t = matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'; - document.documentElement.dataset.theme = t; + const choice = t === 'light' || t === 'dark' ? t : 'auto'; + document.documentElement.dataset.themeChoice = choice; + document.documentElement.dataset.theme = + choice === 'auto' ? (matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark') : choice; })(); </script> </head> @@ -41,7 +44,7 @@ </svg> <span>OpenShell</span> </a> - <!-- Links and the GitHub URL come from theme/nav.json, shared with the docs header; scripts/website.mjs fills them in. --> + <!-- Links and the GitHub URL come from theme/nav.json and the theme toggle from theme/theme-toggle.html, all shared with the docs header; scripts/website.mjs fills them in. --> <nav aria-label="Site" class="site-links"><!-- nav-links --></nav> <div class="top-end"> <a href="{{github}}" class="icon-link"> @@ -53,26 +56,7 @@ /> </svg> </a> - <button type="button" class="icon-link theme-toggle" aria-label="Toggle dark mode"> - <svg viewBox="0 0 24 24" aria-hidden="true" class="sun"> - <circle cx="12" cy="12" r="4" fill="none" stroke="currentColor" stroke-width="1.75" /> - <path - d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" - stroke="currentColor" - stroke-width="1.75" - stroke-linecap="round" - /> - </svg> - <svg viewBox="0 0 24 24" aria-hidden="true" class="moon"> - <path - d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z" - fill="none" - stroke="currentColor" - stroke-width="1.75" - stroke-linejoin="round" - /> - </svg> - </button> + <!-- theme-toggle --> </div> </header> @@ -223,13 +207,7 @@ <h2 id="explore-title">Explore Further</h2> setTimeout(() => delete b.dataset.copied, 1500); }); } - document.querySelector('.theme-toggle').addEventListener('click', () => { - const t = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark'; - document.documentElement.dataset.theme = t; - try { - localStorage.setItem('starlight-theme', t); - } catch {} - }); </script> + <script type="module" src="/theme-toggle.js"></script> </body> </html> diff --git a/www/style.css b/www/style.css index 21f0253..7cefff1 100644 --- a/www/style.css +++ b/www/style.css @@ -121,7 +121,8 @@ a:hover { .nav-link[aria-current="page"] { color: var(--os-accent-text); } -.icon-link { +.icon-link, +.theme-toggle { display: grid; place-items: center; width: 2rem; @@ -133,7 +134,8 @@ a:hover { color: var(--os-muted); cursor: pointer; } -.icon-link:hover { +.icon-link:hover, +.theme-toggle:hover { color: var(--strong); background: var(--os-surface); } @@ -141,10 +143,6 @@ a:hover { width: 1.125rem; height: 1.125rem; } -:root[data-theme="dark"] .theme-toggle .moon, -:root[data-theme="light"] .theme-toggle .sun { - display: none; -} /* ---------- layout ---------- */ main { From fc98fb173b79279a9d696af38f6cb1cf9aff8dfe Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:42:09 -0800 Subject: [PATCH 10/15] feat(site): separate the site bar from the docs tabs with a line Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- netlify.toml | 2 ++ package-lock.json | 1 + package.json | 1 + scripts/website.mjs | 12 +++++++++++- site/src/styles/theme.css | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 34aa6cc..0ff1871 100644 --- a/netlify.toml +++ b/netlify.toml @@ -10,3 +10,5 @@ publish = "build/website" [build.environment] BASE_PATH = "/docs/" +# Docs search also covers the website pages (pagefind-www, see scripts/website.mjs). +WEBSITE = "1" diff --git a/package-lock.json b/package-lock.json index 23adec7..1ecd91f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "@astrojs/starlight": "0.42.10", "astro": "7.4.11", "github-slugger": "2.0.0", + "pagefind": "1.6.0", "pele": "1.13.0", "rehype-stringify": "10.0.1", "remark-frontmatter": "5.0.0", diff --git a/package.json b/package.json index 213feae..c10f0ce 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@astrojs/starlight": "0.42.10", "astro": "7.4.11", "github-slugger": "2.0.0", + "pagefind": "1.6.0", "pele": "1.13.0", "rehype-stringify": "10.0.1", "remark-frontmatter": "5.0.0", diff --git a/scripts/website.mjs b/scripts/website.mjs index ebc16a9..7b053c8 100644 --- a/scripts/website.mjs +++ b/scripts/website.mjs @@ -8,6 +8,7 @@ // Usage: node scripts/website.mjs site/dist build/website import fs from 'node:fs'; import path from 'node:path'; +import * as pagefind from 'pagefind'; import rehypeStringify from 'rehype-stringify'; import remarkGfm from 'remark-gfm'; import remarkParse from 'remark-parse'; @@ -67,6 +68,7 @@ fs.writeFileSync(path.join(out, 'index.html'), withNav(shell, '/')); // Markdown pages. const render = unified().use(remarkParse).use(remarkGfm).use(remarkRehype).use(rehypeStringify); const pages = fs.readdirSync(www).filter((f) => f.endsWith('.md')); +const rendered = []; for (const file of pages) { const name = path.basename(file, '.md'); const src = fs.readFileSync(path.join(www, file), 'utf8'); @@ -75,7 +77,7 @@ for (const file of pages) { if (!meta?.title || !meta.description) throw new Error(`www/${file} needs a title and description in its front matter`); const body = src.slice(m[0].length).trim(); - const main = `<main class="page">\n<h1>${htmlEscape(meta.title)}</h1>\n${String(render.processSync(body))}\n</main>`; + const main = `<main class="page" data-pagefind-body>\n<h1>${htmlEscape(meta.title)}</h1>\n${String(render.processSync(body))}\n</main>`; let html = swap(shell, /<title>[^<]*<\/title>/, `<title>${htmlEscape(meta.title)} · OpenShell`, ''); html = swap( html, @@ -86,9 +88,17 @@ for (const file of pages) { html = withNav(swap(html, /<main>[\s\S]*<\/main>/, main, '<main>'), `/${name}/`); fs.mkdirSync(path.join(out, name), { recursive: true }); fs.writeFileSync(path.join(out, name, 'index.html'), html); + rendered.push([`/${name}/`, html]); fs.writeFileSync(path.join(out, `${name}.md`), `# ${meta.title}\n\n${body}\n`); } +// Search: index the Markdown pages into /pagefind-www/, which the docs search +// merges with its own index (pagefind.mergeIndex in site/astro.config.mjs). +const { index } = await pagefind.createIndex(); +for (const [url, content] of rendered) await index.addHTMLFile({ url, content }); +await index.writeFiles({ outputPath: path.join(out, 'pagefind-www') }); +await pagefind.close(); + console.log( `website -> ${path.relative(process.cwd(), out)} (landing at /, ${pages.length} Markdown pages, docs at /${MOUNT}/)`, ); diff --git a/site/src/styles/theme.css b/site/src/styles/theme.css index 2b63c6d..6058f01 100644 --- a/site/src/styles/theme.css +++ b/site/src/styles/theme.css @@ -92,6 +92,8 @@ body { gap: 1rem; height: var(--os-header-h); padding-inline: var(--sl-nav-pad-x); + /* Sets the site bar apart from the docs rows below it */ + border-bottom: 1px solid var(--os-border); } [data-has-sidebar] .os-header__row { padding-inline-end: calc(var(--sl-nav-pad-x) + var(--sl-menu-button-size) + 0.5rem); From 42584e59f8dea865fcd43db41d7a13672c1c8efe Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:42:09 -0800 Subject: [PATCH 11/15] feat(site): search the docs and the website pages from every page scripts/website.mjs indexes the Markdown pages with Pagefind into /pagefind-www/. The docs search merges that index when built with WEBSITE=1 (set on Netlify and by mise run website), and the landing and community pages get a search button and dialog (www/search.js) that use the docs index plus the same merged index, with Starlight's ranking. Website pages count half so a short page doesn't outrank the docs on a common term. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- README.md | 7 +++ mise.toml | 6 ++- site/astro.config.mjs | 6 +++ www/index.html | 16 +++++++ www/search.js | 63 ++++++++++++++++++++++++++ www/style.css | 102 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 www/search.js diff --git a/README.md b/README.md index d7e4983..fe4b0d3 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,13 @@ renders each `www/<name>.md` into the landing page's header and footer at header, and both read their links from that file. `mise run website` builds the whole website, and `mise run serve-website` serves it. +Search covers the docs and these pages. The docs build has its own +[Pagefind](https://pagefind.app/) index; `scripts/website.mjs` indexes the +website pages into `/pagefind-www/`, and both the docs search and the search on +the website pages ([`www/search.js`](www/search.js)) merge the two. The docs +only merge the website index when built with `WEBSITE=1`, as Netlify and +`mise run website` do, so a docs-only build keeps docs-only search. + ## Markdown for agents Every page has a Markdown copy at its URL plus `.md`, such as diff --git a/mise.toml b/mise.toml index 0551e4a..66de1da 100644 --- a/mise.toml +++ b/mise.toml @@ -22,8 +22,10 @@ run = "npm run site" [tasks.website] description = "Build the site, then add the landing page at / with the docs at /docs/" -depends = ["build"] -run = "npm run website" +depends = ["assemble"] +# WEBSITE=1 makes the docs search include the website pages, as on Netlify. +env = { BASE_PATH = "/docs/", WEBSITE = "1" } +run = ["npm run site", "npm run website"] [tasks.serve-website] description = "Serve the website at http://127.0.0.1:4410/" diff --git a/site/astro.config.mjs b/site/astro.config.mjs index b0c40a6..7d95ed4 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -68,6 +68,12 @@ export default defineConfig({ // Sidebar, pagination, topic tabs and the version picker all follow the // version context of the current page; see src/versioning.ts. routeMiddleware: './src/routeData.ts', + // On the full website (WEBSITE=1), search also covers the pages outside + // the docs, which scripts/website.mjs indexes into /pagefind-www/. Their + // weight is halved so a short page doesn't outrank the docs on a common term. + pagefind: process.env.WEBSITE + ? { mergeIndex: [{ bundlePath: '/pagefind-www/', baseUrl: '/', indexWeight: 0.5 }] } + : true, }), ], }); diff --git a/www/index.html b/www/index.html index dc435c3..59dfc24 100644 --- a/www/index.html +++ b/www/index.html @@ -47,6 +47,14 @@ <!-- Links and the GitHub URL come from theme/nav.json and the theme toggle from theme/theme-toggle.html, all shared with the docs header; scripts/website.mjs fills them in. --> <nav aria-label="Site" class="site-links"><!-- nav-links --></nav> <div class="top-end"> + <button type="button" class="search-button" data-search-open> + <svg viewBox="0 0 24 24" aria-hidden="true"> + <circle cx="11" cy="11" r="6.5" fill="none" stroke="currentColor" stroke-width="1.75" /> + <path d="m16 16 4 4" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" /> + </svg> + <span class="search-button__label">Search</span> + <kbd class="search-button__kbd">Ctrl K</kbd> + </button> <a href="{{github}}" class="icon-link"> <span class="sr-only">GitHub</span> <svg viewBox="0 0 24 24" aria-hidden="true"> @@ -59,6 +67,13 @@ <!-- theme-toggle --> </div> </header> + <!-- Site search (www/search.js): the docs' Pagefind index merged with the website pages' --> + <dialog class="search-dialog" aria-label="Search"> + <div class="search-dialog__frame"> + <button type="button" class="search-dialog__close" data-search-close>Cancel</button> + <div id="site-search"></div> + </div> + </dialog> <main> <!-- Copy comes from the ai-openshell/openshell README (intro, How It Works, @@ -209,5 +224,6 @@ <h2 id="explore-title">Explore Further</h2> } </script> <script type="module" src="/theme-toggle.js"></script> + <script type="module" src="/search.js"></script> </body> </html> diff --git a/www/search.js b/www/search.js new file mode 100644 index 0000000..2c50b68 --- /dev/null +++ b/www/search.js @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: Apache-2.0 +// Search on the pages in www/. It uses the same two Pagefind indexes as the +// docs search: the docs index (/docs/pagefind/) merged with the website pages +// (/pagefind-www/, written by scripts/website.mjs). The search UI loads on +// first open. +const dialog = document.querySelector('.search-dialog'); +const kbd = document.querySelector('.search-button__kbd'); +if (kbd && /Mac|iPhone|iPad/.test(navigator.platform)) kbd.textContent = '⌘ K'; + +let ready; +// Starlight's default ranking, applied to both indexes as the docs search does, +// so results here match it. +const ranking = { pageLength: 0.1, termFrequency: 0.1, termSaturation: 2, termSimilarity: 9, diacriticSimilarity: 0.8 }; + +const load = () => + (ready ??= new Promise((resolve, reject) => { + const css = document.createElement('link'); + css.rel = 'stylesheet'; + css.href = '/docs/pagefind/pagefind-ui.css'; + document.head.append(css); + const js = document.createElement('script'); + js.src = '/docs/pagefind/pagefind-ui.js'; + js.onload = () => { + new window.PagefindUI({ + element: '#site-search', + bundlePath: '/docs/pagefind/', + baseUrl: '/docs/', + // Website pages count half, as in site/astro.config.mjs. + mergeIndex: [{ bundlePath: '/pagefind-www/', baseUrl: '/', indexWeight: 0.5, ranking }], + showSubResults: true, + showImages: false, + // Starlight's default ranking, so results match the docs search. + ranking: { + pageLength: 0.1, + termFrequency: 0.1, + termSaturation: 2, + termSimilarity: 9, + diacriticSimilarity: 0.8, + }, + }); + resolve(); + }; + js.onerror = reject; + document.head.append(js); + })); + +async function open() { + if (dialog.open) return; + dialog.showModal(); + await load(); + dialog.querySelector('.pagefind-ui__search-input')?.focus(); +} + +for (const b of document.querySelectorAll('[data-search-open]')) b.addEventListener('click', open); +document.querySelector('[data-search-close]')?.addEventListener('click', () => dialog.close()); +// A click on the backdrop closes the dialog. +dialog.addEventListener('click', (e) => e.target === dialog && dialog.close()); +addEventListener('keydown', (e) => { + if ((e.metaKey || e.ctrlKey) && e.key === 'k') { + e.preventDefault(); + dialog.open ? dialog.close() : open(); + } +}); diff --git a/www/style.css b/www/style.css index 7cefff1..3044259 100644 --- a/www/style.css +++ b/www/style.css @@ -477,3 +477,105 @@ a.card:hover .arrow { padding-top: 3.5rem; } } + +/* ---------- search (www/search.js) ---------- */ +/* The button matches the docs header search; the dialog follows Starlight's. */ +.search-button { + display: flex; + align-items: center; + gap: 0.5rem; + width: 16rem; + height: 2.25rem; + margin-inline-end: 0.5rem; + padding: 0 0.5rem 0 0.75rem; + border: 1px solid var(--os-border); + border-radius: var(--os-radius); + background: var(--os-surface); + color: var(--os-muted); + font: inherit; + font-size: 0.875rem; + cursor: pointer; +} +.search-button:hover { + color: var(--strong); +} +.search-button svg { + width: 1rem; + height: 1rem; + flex: none; +} +.search-button__label { + margin-inline-end: auto; +} +.search-button__kbd { + padding: 0.05rem 0.35rem; + border: 1px solid var(--os-border); + border-radius: 4px; + background: var(--os-bg); + font-family: var(--os-font-sans); + font-size: 0.75rem; +} +.search-dialog { + width: min(100% - 2rem, 45rem); + max-height: calc(100% - 8rem); + margin: 4rem auto auto; + padding: 0; + border: 1px solid var(--os-border); + border-radius: var(--os-radius); + background: var(--os-bg); + color: var(--text); + box-shadow: 0 16px 48px rgb(0 0 0 / 0.25); +} +.search-dialog::backdrop { + background: rgb(0 0 0 / 0.45); + backdrop-filter: blur(2px); +} +.search-dialog__frame { + display: flex; + flex-direction: column; + gap: 0.75rem; + padding: 1rem; +} +.search-dialog__close { + align-self: flex-end; + border: 0; + background: none; + color: var(--os-accent-text); + font: inherit; + font-size: 0.875rem; + cursor: pointer; +} +#site-search { + --pagefind-ui-scale: 0.8; + --pagefind-ui-primary: var(--strong); + --pagefind-ui-text: var(--text); + --pagefind-ui-background: var(--os-bg); + --pagefind-ui-border: var(--os-border); + --pagefind-ui-tag: var(--os-surface); + --pagefind-ui-border-radius: var(--os-radius); + --pagefind-ui-font: var(--os-font-sans); +} +#site-search mark { + background: none; + color: var(--os-accent-text); + font-weight: 600; +} +@media (max-width: 50rem) { + .search-button { + width: 2rem; + height: 2rem; + margin-inline-end: 0; + padding: 0; + justify-content: center; + border: 0; + background: none; + } + .search-button svg { + width: 1.125rem; + height: 1.125rem; + } + .search-button__label, + .search-button__kbd { + display: none; + } +} From 9630aeaf6b04d8d60e69ff9c1a548e1d5e083546 Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:43:33 -0800 Subject: [PATCH 12/15] feat(site): organize the community page like OpenTelemetry's, with icons The Chat section becomes a Develop and contribute section: the contributing guide, then GitHub and the #openshell-dev Slack channel, with a pointer to the #openshell-* subproject channels and slack.cncf.io. Markdown pages can now use :name: shortcodes for icons in www/icons/; the GitHub and Slack logos come from Starlight's icon set and are excluded from the SPDX check as third-party artwork. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- .github/workflows/spdx.yml | 5 +++-- README.md | 3 ++- scripts/website.mjs | 20 +++++++++++++++++--- www/community.md | 25 ++++++++++--------------- www/icons/github.svg | 2 ++ www/icons/slack.svg | 2 ++ www/style.css | 10 +++++++++- 7 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 www/icons/github.svg create mode 100644 www/icons/slack.svg diff --git a/.github/workflows/spdx.yml b/.github/workflows/spdx.yml index 892bf46..ce3656e 100644 --- a/.github/workflows/spdx.yml +++ b/.github/workflows/spdx.yml @@ -24,5 +24,6 @@ jobs: - uses: ai-openshell/workflows/spdx-check@0b051efd25c3f7319634fed863d2e03e1bd55d7b # main with: include: "*" - # LICENSE is the license text; the CNCF logos are third-party artwork. - exclude: "LICENSE site/static/cncf/*" + # LICENSE is the license text; the CNCF, GitHub, and Slack logos are + # third-party artwork. + exclude: "LICENSE site/static/cncf/* www/icons/*" diff --git a/README.md b/README.md index fe4b0d3..c75a2ad 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,8 @@ with a `title` and `description` in their front matter. `scripts/website.mjs` renders each `www/<name>.md` into the landing page's header and footer at `/<name>/`. To add a page, add a Markdown file and its link to [`theme/nav.json`](theme/nav.json). The landing page and the docs share one -header, and both read their links from that file. `mise run website` builds the whole website, and +header, and both read their links from that file. `:name:` in a page, such as +`:github:`, inserts the icon `www/icons/<name>.svg`. `mise run website` builds the whole website, and `mise run serve-website` serves it. Search covers the docs and these pages. The docs build has its own diff --git a/scripts/website.mjs b/scripts/website.mjs index 7b053c8..9f044c8 100644 --- a/scripts/website.mjs +++ b/scripts/website.mjs @@ -28,7 +28,10 @@ if (base !== `/${MOUNT}/`) { } fs.rmSync(out, { recursive: true, force: true }); -fs.cpSync(www, out, { recursive: true, filter: (f) => path.extname(f) !== '.md' }); +fs.cpSync(www, out, { + recursive: true, + filter: (f) => path.extname(f) !== '.md' && !f.startsWith(path.join(www, 'icons')), +}); for (const f of ['tokens.css', 'theme-toggle.js']) fs.copyFileSync(path.join(repo, 'theme', f), path.join(out, f)); for (const f of ['favicon.svg', 'apple-touch-icon.png', 'cncf']) fs.cpSync(path.join(repo, 'site/static', f), path.join(out, f), { recursive: true }); @@ -67,6 +70,17 @@ fs.writeFileSync(path.join(out, 'index.html'), withNav(shell, '/')); // Markdown pages. const render = unified().use(remarkParse).use(remarkGfm).use(remarkRehype).use(rehypeStringify); +// Icon shortcodes: :name: in a www/*.md page becomes www/icons/<name>.svg in +// the HTML, and is dropped from the Markdown copy. +const ICON = /:([a-z][a-z0-9-]*):/g; +const icon = (name) => { + const f = path.join(www, 'icons', `${name}.svg`); + if (!fs.existsSync(f)) throw new Error(`no icon www/icons/${name}.svg for :${name}:`); + return fs + .readFileSync(f, 'utf8') + .replace(/<!--[\s\S]*?-->\s*/g, '') + .trim(); +}; const pages = fs.readdirSync(www).filter((f) => f.endsWith('.md')); const rendered = []; for (const file of pages) { @@ -77,7 +91,7 @@ for (const file of pages) { if (!meta?.title || !meta.description) throw new Error(`www/${file} needs a title and description in its front matter`); const body = src.slice(m[0].length).trim(); - const main = `<main class="page" data-pagefind-body>\n<h1>${htmlEscape(meta.title)}</h1>\n${String(render.processSync(body))}\n</main>`; + const main = `<main class="page" data-pagefind-body>\n<h1>${htmlEscape(meta.title)}</h1>\n${String(render.processSync(body)).replace(ICON, (_, n) => icon(n))}\n</main>`; let html = swap(shell, /<title>[^<]*<\/title>/, `<title>${htmlEscape(meta.title)} · OpenShell`, ''); html = swap( html, @@ -89,7 +103,7 @@ for (const file of pages) { fs.mkdirSync(path.join(out, name), { recursive: true }); fs.writeFileSync(path.join(out, name, 'index.html'), html); rendered.push([`/${name}/`, html]); - fs.writeFileSync(path.join(out, `${name}.md`), `# ${meta.title}\n\n${body}\n`); + fs.writeFileSync(path.join(out, `${name}.md`), `# ${meta.title}\n\n${body.replace(/:[a-z][a-z0-9-]*: /g, '')}\n`); } // Search: index the Markdown pages into /pagefind-www/, which the docs search diff --git a/www/community.md b/www/community.md index 1dd40de..71591c6 100644 --- a/www/community.md +++ b/www/community.md @@ -1,26 +1,21 @@ --- # SPDX-License-Identifier: Apache-2.0 title: Community -description: Where to talk to the OpenShell community and how to contribute. +description: Where to find the OpenShell community and how to contribute. --- OpenShell is a [Cloud Native Computing Foundation](https://www.cncf.io/) sandbox project, built in the open. Everyone is welcome to ask questions, share what they're building, and contribute. -## Chat +## Develop and contribute -Join [`#openshell-dev`](https://cloud-native.slack.com/archives/C0B6Y8WQHU1) -in the CNCF Slack to ask questions and talk with maintainers and other users. -If you don't have a CNCF Slack account yet, get an invite at -[slack.cncf.io](https://slack.cncf.io/). +To learn how to contribute to OpenShell, see the +[contributing guide](https://github.com/ai-openshell/openshell/blob/main/CONTRIBUTING.md). +Other useful links: -## Contributing - -OpenShell, its SDKs, and this website are developed on GitHub in the -[ai-openshell](https://github.com/ai-openshell) organization. - -- Read the [contributing guide](https://github.com/ai-openshell/openshell/blob/main/CONTRIBUTING.md) - before you open a pull request. -- Report bugs and request features in - [GitHub issues](https://github.com/ai-openshell/openshell/issues). +- :github: [GitHub](https://github.com/ai-openshell): Find us on GitHub. +- :slack: [Slack #openshell-dev](https://cloud-native.slack.com/archives/C0B6Y8WQHU1): + Follow project-wide developments. To chat about a specific subproject, check + out the other channels starting with `#openshell-`. Sign up via + [slack.cncf.io](https://slack.cncf.io/). diff --git a/www/icons/github.svg b/www/icons/github.svg new file mode 100644 index 0000000..48ce3a5 --- /dev/null +++ b/www/icons/github.svg @@ -0,0 +1,2 @@ +<!-- GitHub logo from Starlight's icon set (@astrojs/starlight, MIT). Used by :github: in www/*.md. --> +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="icon"><path d="M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3Z"/></svg> diff --git a/www/icons/slack.svg b/www/icons/slack.svg new file mode 100644 index 0000000..c69bc8d --- /dev/null +++ b/www/icons/slack.svg @@ -0,0 +1,2 @@ +<!-- Slack logo from Starlight's icon set (@astrojs/starlight, MIT). Used by :slack: in www/*.md. --> +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" class="icon"><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52Zm1.271 0a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313ZM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834Zm0 1.271a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312Zm10.122 2.521a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834Zm-1.268 0a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312Zm-2.523 10.122a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52Zm0-1.268a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313Z"/></svg> diff --git a/www/style.css b/www/style.css index 3044259..e2fa44d 100644 --- a/www/style.css +++ b/www/style.css @@ -190,7 +190,15 @@ h2 { color: var(--strong); } .page li + li { - margin-top: 0.25rem; + margin-top: 0.5rem; +} +/* Icons from :name: shortcodes (www/icons/) */ +.page .icon { + width: 1em; + height: 1em; + margin-inline-end: 0.15em; + vertical-align: -0.125em; + color: var(--strong); } /* ---------- hero ---------- */ From e13d949d0b7bc952b63d1aa1f03b52b5dae678db Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:47:43 -0800 Subject: [PATCH 13/15] fix(site): keep the header from shifting between the landing page and the docs The docs header's site bar shrank by a fraction of a pixel to fit Starlight's header border, so the wordmark sat slightly higher than on the landing page. It now keeps its full height. The landing header also uses the docs' side padding, link spacing, and search breakpoints, so the wordmark, links, and search stay in place at every width. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- site/src/styles/theme.css | 4 ++++ www/style.css | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/site/src/styles/theme.css b/site/src/styles/theme.css index 6058f01..94e2e78 100644 --- a/site/src/styles/theme.css +++ b/site/src/styles/theme.css @@ -94,6 +94,10 @@ body { padding-inline: var(--sl-nav-pad-x); /* Sets the site bar apart from the docs rows below it */ border-bottom: 1px solid var(--os-border); + /* Keep the full bar height (as on the landing page, www/style.css) so the + wordmark doesn't shift between pages; the tabs row absorbs Starlight's + header border. */ + flex-shrink: 0; } [data-has-sidebar] .os-header__row { padding-inline-end: calc(var(--sl-nav-pad-x) + var(--sl-menu-button-size) + 0.5rem); diff --git a/www/style.css b/www/style.css index e2fa44d..0e8f2ed 100644 --- a/www/style.css +++ b/www/style.css @@ -466,10 +466,15 @@ a.card:hover .arrow { display: block; } -@media (max-width: 40rem) { +/* Same side padding and link spacing as the docs header, at the same + breakpoints (site/src/styles/theme.css), so the bar doesn't shift between + the landing page and the docs. */ +@media (width < 50rem) { .top { - padding: 0 1rem; + padding: 0 1.25rem; } +} +@media (max-width: 50rem) { .site-links { gap: 0; margin-inline-start: 0.75rem; @@ -478,6 +483,8 @@ a.card:hover .arrow { .nav-link { padding-inline: 0.375rem; } +} +@media (max-width: 40rem) { main { padding: 0 1rem; } @@ -568,7 +575,7 @@ a.card:hover .arrow { color: var(--os-accent-text); font-weight: 600; } -@media (max-width: 50rem) { +@media (width < 50rem) { .search-button { width: 2rem; height: 2rem; From a920e1d43d13543b64f66bd8704e5eb92d59f5dc Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 14:47:54 -0800 Subject: [PATCH 14/15] feat(site): drop the arrow from the landing page's Documentation button Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- www/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/index.html b/www/index.html index 59dfc24..5f12fb8 100644 --- a/www/index.html +++ b/www/index.html @@ -87,7 +87,7 @@ <h1>The safe, private runtime for <span class="accent">autonomous AI agents</spa declare what each agent can touch in a policy, and OpenShell enforces it. </p> <div class="actions"> - <a class="button primary" href="/docs/">Documentation <span aria-hidden="true">→</span></a> + <a class="button primary" href="/docs/">Documentation</a> <a class="button" href="https://github.com/ai-openshell/openshell">GitHub</a> </div> </section> From 2e739203914b9e6a7bb69eb6403e042d3c9c99da Mon Sep 17 00:00:00 2001 From: Piotr Mlocek <pmlocek@nvidia.com> Date: Mon, 23 Nov 2026 15:33:58 -0800 Subject: [PATCH 15/15] feat(site): share one site bar and search between the docs and the website theme/site-bar.mjs renders the site bar (wordmark, site links, search, GitHub, theme toggle) and the search dialog for every page, with one stylesheet (theme/site-bar.css) and one search script (theme/search.js). The docs header and scripts/website.mjs both use it, so the bar can no longer drift between the docs and the landing and community pages. The docs now use this search instead of Starlight's search box; Starlight still builds the Pagefind index. Search changes: - Whole result rows are clickable, with one row per page and per section, all the same width. - Each result shows where it comes from (Core, Go SDK, SDKs, Community), from Pagefind metadata set on every page. - Page icons, tighter spacing, arrow-key navigation, a link-style Clear, and an X that closes the dialog (Esc too). - The dialog uses the site's type scale: a regular-weight query, semibold titles, and 14px excerpts. The community page title now matches docs page titles. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --- .gitignore | 1 + README.md | 33 +- scripts/website.mjs | 32 +- site/astro.config.mjs | 13 +- site/scripts/sync.mjs | 5 +- site/src/components/overrides/Header.astro | 41 +- site/src/components/overrides/PageTitle.astro | 5 + site/src/styles/theme.css | 137 +------ theme/search.js | 84 ++++ theme/site-bar.css | 358 ++++++++++++++++++ theme/site-bar.mjs | 56 +++ theme/theme-toggle.html | 27 -- theme/theme-toggle.js | 7 +- www/index.html | 44 +-- www/search.js | 63 --- www/style.css | 203 +--------- 16 files changed, 587 insertions(+), 522 deletions(-) create mode 100644 theme/search.js create mode 100644 theme/site-bar.css create mode 100644 theme/site-bar.mjs delete mode 100644 theme/theme-toggle.html delete mode 100644 www/search.js diff --git a/.gitignore b/.gitignore index 9647aa3..44d654c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ site/src/content/docs/ site/src/generated/ site/public/ site/src/styles/tokens.css +site/src/styles/site-bar.css diff --git a/README.md b/README.md index c75a2ad..5249808 100644 --- a/README.md +++ b/README.md @@ -38,22 +38,23 @@ combines the two after the docs build. ## Website pages -The landing page, [`www/index.html`](www/index.html), is hand-written HTML. Other -pages outside the docs, such as `/community/`, are Markdown files in `www/` -with a `title` and `description` in their front matter. `scripts/website.mjs` -renders each `www/<name>.md` into the landing page's header and footer at -`/<name>/`. To add a page, add a Markdown file and its link to -[`theme/nav.json`](theme/nav.json). The landing page and the docs share one -header, and both read their links from that file. `:name:` in a page, such as -`:github:`, inserts the icon `www/icons/<name>.svg`. `mise run website` builds the whole website, and -`mise run serve-website` serves it. - -Search covers the docs and these pages. The docs build has its own -[Pagefind](https://pagefind.app/) index; `scripts/website.mjs` indexes the -website pages into `/pagefind-www/`, and both the docs search and the search on -the website pages ([`www/search.js`](www/search.js)) merge the two. The docs -only merge the website index when built with `WEBSITE=1`, as Netlify and -`mise run website` do, so a docs-only build keeps docs-only search. +The landing page, [`www/index.html`](www/index.html), is hand-written HTML. +Other pages outside the docs, such as `/community/`, are Markdown files in +`www/` with a `title` and `description` in their front matter. +`scripts/website.mjs` renders each `www/<name>.md` into the landing page's +header and footer at `/<name>/`. To add a page, add a Markdown file and its link +to [`theme/nav.json`](theme/nav.json), which the site bar reads. `:name:` in a +page, such as `:github:`, inserts the icon `www/icons/<name>.svg`. `mise run +website` builds the whole website, and `mise run serve-website` serves it. + +Every page, docs included, renders the same site bar from +[`theme/site-bar.mjs`](theme/site-bar.mjs): wordmark, site links, search, +GitHub, and theme toggle, with one stylesheet (`theme/site-bar.css`) and +script (`theme/search.js`). Search uses the docs build's +[Pagefind](https://pagefind.app/) index, and `scripts/website.mjs` indexes the +website pages into `/pagefind-www/`; on the full website (`WEBSITE=1`, as +Netlify and `mise run website` set it) search merges the two. A docs-only +build searches the docs only. ## Markdown for agents diff --git a/scripts/website.mjs b/scripts/website.mjs index 9f044c8..1817773 100644 --- a/scripts/website.mjs +++ b/scripts/website.mjs @@ -15,6 +15,7 @@ import remarkParse from 'remark-parse'; import remarkRehype from 'remark-rehype'; import { unified } from 'unified'; import YAML from 'yaml'; +import { siteBar } from '../theme/site-bar.mjs'; const MOUNT = 'docs'; const [docs = 'site/dist', out = 'build/website'] = process.argv.slice(2).map((p) => path.resolve(p)); @@ -32,7 +33,8 @@ fs.cpSync(www, out, { recursive: true, filter: (f) => path.extname(f) !== '.md' && !f.startsWith(path.join(www, 'icons')), }); -for (const f of ['tokens.css', 'theme-toggle.js']) fs.copyFileSync(path.join(repo, 'theme', f), path.join(out, f)); +for (const f of ['tokens.css', 'site-bar.css', 'search.js', 'theme-toggle.js']) + fs.copyFileSync(path.join(repo, 'theme', f), path.join(out, f)); for (const f of ['favicon.svg', 'apple-touch-icon.png', 'cncf']) fs.cpSync(path.join(repo, 'site/static', f), path.join(out, f), { recursive: true }); fs.cpSync(docs, path.join(out, MOUNT), { recursive: true }); @@ -46,23 +48,15 @@ const swap = (html, re, to, what) => { return html.replace(re, () => to); }; -// The header links come from theme/nav.json, which the docs header also reads. -// So does the theme toggle (theme/theme-toggle.html and .js). -const nav = JSON.parse(fs.readFileSync(path.join(repo, 'theme/nav.json'), 'utf8')); -const themeToggle = fs - .readFileSync(path.join(repo, 'theme/theme-toggle.html'), 'utf8') - .replace(/^<!--[\s\S]*?-->\n/gm, ''); -const withNav = (html, current) => { - const links = nav.links - .map( - (l) => - `<a href="${htmlEscape(l.href)}" class="nav-link"${l.href === current ? ' aria-current="page"' : ''}>${htmlEscape(l.label)}</a>`, - ) - .join(''); - html = swap(html, /<!-- nav-links -->/, links, '<!-- nav-links --> placeholder'); - html = swap(html, /<!-- theme-toggle -->/, themeToggle, '<!-- theme-toggle --> placeholder'); - return swap(html, /\{\{github\}\}/, htmlEscape(nav.github), '{{github}} placeholder'); -}; +// The site bar (theme/site-bar.mjs), the same one the docs header renders. +// Search covers the docs index and the website pages' index written below. +const withNav = (html, current) => + swap( + html, + /<!-- site-bar -->/, + siteBar({ current, search: { bundlePath: `/${MOUNT}/pagefind/`, baseUrl: `/${MOUNT}/`, merge: '/pagefind-www/' } }), + '<!-- site-bar --> placeholder', + ); // The landing page. const shell = fs.readFileSync(path.join(www, 'index.html'), 'utf8'); @@ -91,7 +85,7 @@ for (const file of pages) { if (!meta?.title || !meta.description) throw new Error(`www/${file} needs a title and description in its front matter`); const body = src.slice(m[0].length).trim(); - const main = `<main class="page" data-pagefind-body>\n<h1>${htmlEscape(meta.title)}</h1>\n${String(render.processSync(body)).replace(ICON, (_, n) => icon(n))}\n</main>`; + const main = `<main class="page" data-pagefind-body data-pagefind-meta="section:${htmlEscape(meta.title)}">\n<h1>${htmlEscape(meta.title)}</h1>\n${String(render.processSync(body)).replace(ICON, (_, n) => icon(n))}\n</main>`; let html = swap(shell, /<title>[^<]*<\/title>/, `<title>${htmlEscape(meta.title)} · OpenShell`, ''); html = swap( html, diff --git a/site/astro.config.mjs b/site/astro.config.mjs index 7d95ed4..841f53e 100644 --- a/site/astro.config.mjs +++ b/site/astro.config.mjs @@ -17,10 +17,10 @@ export default defineConfig({ description: 'The safe, private runtime for autonomous AI agents.', favicon: '/favicon.svg', social: [{ icon: 'github', label: 'GitHub', href: siteNav.github }], - customCss: ['./src/styles/tokens.css', './src/styles/theme.css'], + customCss: ['./src/styles/tokens.css', './src/styles/site-bar.css', './src/styles/theme.css'], head: [ // Mark the stored theme choice before paint so the header's theme toggle - // (theme/theme-toggle.html) shows the right icon; Starlight sets data-theme. + // (theme/site-bar.mjs) shows the right icon; Starlight sets data-theme. { tag: 'script', content: @@ -68,12 +68,9 @@ export default defineConfig({ // Sidebar, pagination, topic tabs and the version picker all follow the // version context of the current page; see src/versioning.ts. routeMiddleware: './src/routeData.ts', - // On the full website (WEBSITE=1), search also covers the pages outside - // the docs, which scripts/website.mjs indexes into /pagefind-www/. Their - // weight is halved so a short page doesn't outrank the docs on a common term. - pagefind: process.env.WEBSITE - ? { mergeIndex: [{ bundlePath: '/pagefind-www/', baseUrl: '/', indexWeight: 0.5 }] } - : true, + // Starlight builds the Pagefind index; the site bar's search + // (theme/search.js) shows it instead of Starlight's search box. + pagefind: true, }), ], }); diff --git a/site/scripts/sync.mjs b/site/scripts/sync.mjs index 7c83af6..20ee4d6 100644 --- a/site/scripts/sync.mjs +++ b/site/scripts/sync.mjs @@ -4,7 +4,7 @@ // build/assembled/content -> site/src/content/docs (MDX pages get one import line for the components) // build/assembled/{nav,pages}.json -> site/src/generated/ (read by src/versioning.ts) // site/static + build/assembled/public -> site/public (assets, <slug>.md, llms.txt, versions.json) -// theme/tokens.css -> site/src/styles/tokens.css +// theme/tokens.css, theme/site-bar.css -> site/src/styles/ // Per page it also sets: // slug explicit, so version segments like "0.1.8" keep their dots // banner on dev and older versions, linking to the same page in the latest release @@ -99,6 +99,7 @@ fs.rmSync(pub, { recursive: true, force: true }); fs.cpSync(path.join(site, 'static'), pub, { recursive: true, filter: (src) => !src.endsWith('.license') }); fs.cpSync(path.join(assembled, 'public'), pub, { recursive: true }); -fs.copyFileSync(path.join(themeDir, 'tokens.css'), path.join(site, 'src/styles/tokens.css')); +for (const f of ['tokens.css', 'site-bar.css']) + fs.copyFileSync(path.join(themeDir, f), path.join(site, 'src/styles', f)); for (const f of failed) console.warn(`warning: diagram left as code: ${f}`); console.log(`synced ${pages.length} pages, ${diagrams} diagrams and ${names.length} components (base ${nav.base})`); diff --git a/site/src/components/overrides/Header.astro b/site/src/components/overrides/Header.astro index e30205e..62593ca 100644 --- a/site/src/components/overrides/Header.astro +++ b/site/src/components/overrides/Header.astro @@ -1,16 +1,20 @@ --- // SPDX-License-Identifier: Apache-2.0 -// Header: the site bar (wordmark, site links, search, GitHub, theme), then -// topic tabs, then (in topics with an overview page) sub-tabs for the overview -// and each docset. The site bar matches the landing page header (www/index.html); -// both take their links from theme/nav.json and the theme toggle from -// theme/theme-toggle.html and .js. +// Header: the site bar, then topic tabs, then (in topics with an overview page) +// sub-tabs for the overview and each docset. The site bar (wordmark, site +// links, search, GitHub, theme) is theme/site-bar.mjs, shared with the website +// pages, so it is the same markup, styles, and scripts everywhere. // Tab and sub-tab links come from src/routeData.ts and follow the current // page's version context. -import { Icon } from '@astrojs/starlight/components'; -import Search from '@astrojs/starlight/components/Search.astro'; -import siteNav from '../../../../theme/nav.json'; -import themeToggle from '../../../../theme/theme-toggle.html?raw'; +import { siteBar } from '../../../../theme/site-bar.mjs'; + +const base = import.meta.env.BASE_URL; +// Search this build's Pagefind index; on the full website (WEBSITE=1), merge in +// the website pages' index too. +const bar = siteBar({ + current: base, + search: { bundlePath: `${base}pagefind/`, baseUrl: base, merge: process.env.WEBSITE ? '/pagefind-www/' : undefined }, +}); const os = Astro.locals.osVersion; const topics = os?.topics ?? []; @@ -28,23 +32,7 @@ const subtabs = ds --- <div class="os-header"> - <div class="os-header__row"> - <a href="/" class="os-wordmark" translate="no"> - <!-- The OpenShell shield (ai-openshell/openshell docs/brand/assets/openshell-mark.svg), cropped to the shield --> - <svg viewBox="14 7 72 87" aria-hidden="true" class="os-wordmark__mark"><path d="M50 9 L84 23 V51 C84 72 69 86 50 92 C31 86 16 72 16 51 V23 Z" fill="#76B900"/><g fill="none" stroke="#FFFFFF" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"><path d="M37 41 L49 50 L37 59"/><path d="M55 59 H67"/></g></svg> - <span>OpenShell</span> - </a> - <nav class="os-site-links print:hidden" aria-label="Site"> - {siteNav.links.map((l) => ( - <a href={l.href} class="os-site-link" aria-current={l.href === import.meta.env.BASE_URL ? 'page' : undefined}>{l.label}</a> - ))} - </nav> - <div class="os-header__search print:hidden"><Search /></div> - <div class="os-header__end print:hidden sl-hidden md:sl-flex"> - <a href={siteNav.github} class="os-icon-button"><span class="sr-only">GitHub</span><Icon name="github" /></a> - <Fragment set:html={themeToggle} /> - </div> - </div> + <Fragment set:html={bar} /> <nav class="os-tabs print:hidden" aria-label="Topics"> {topics.map((t) => ( <a href={t.href} class="os-tab" aria-current={t.isCurrent ? 'true' : undefined}>{t.label}</a> @@ -76,6 +64,7 @@ const subtabs = ds </div> <script> + import '../../../../theme/search.js'; import '../../../../theme/theme-toggle.js'; document.addEventListener('click', (e) => { diff --git a/site/src/components/overrides/PageTitle.astro b/site/src/components/overrides/PageTitle.astro index af3dd8b..6d5e2c0 100644 --- a/site/src/components/overrides/PageTitle.astro +++ b/site/src/components/overrides/PageTitle.astro @@ -5,8 +5,13 @@ import Default from '@astrojs/starlight/components/PageTitle.astro'; import PageActions from '../PageActions.astro'; const { description } = Astro.locals.starlightRoute.entry.data; +// Where the page sits, for search results: the docset in a topic with several +// (Go SDK), else the topic (Core, SDKs). +const ds = Astro.locals.osVersion?.docsets; +const section = ds && ((ds.topic.landing && ds.items.find((d) => d.current)?.title) || ds.topic.label); --- +{section && <span hidden data-pagefind-meta={`section:${section}`} />} <div class="os-title"> <Default /> <PageActions /> diff --git a/site/src/styles/theme.css b/site/src/styles/theme.css index 94e2e78..00b0fd1 100644 --- a/site/src/styles/theme.css +++ b/site/src/styles/theme.css @@ -86,43 +86,23 @@ body { flex-direction: column; height: 100%; } -.os-header__row { - display: flex; - align-items: center; - gap: 1rem; - height: var(--os-header-h); - padding-inline: var(--sl-nav-pad-x); - /* Sets the site bar apart from the docs rows below it */ - border-bottom: 1px solid var(--os-border); - /* Keep the full bar height (as on the landing page, www/style.css) so the - wordmark doesn't shift between pages; the tabs row absorbs Starlight's - header border. */ +/* The site bar itself (wordmark, links, search, GitHub, theme) is shared with + the website pages: theme/site-bar.css. Here it only sits in Starlight's + header, above the topic tabs. */ +.os-header .site-bar { + /* Keep the full bar height so the wordmark sits where it does on the website + pages; the tabs row absorbs Starlight's header border. */ flex-shrink: 0; } -[data-has-sidebar] .os-header__row { - padding-inline-end: calc(var(--sl-nav-pad-x) + var(--sl-menu-button-size) + 0.5rem); -} -@media (min-width: 50em) { - [data-has-sidebar] .os-header__row { - padding-inline-end: var(--sl-nav-pad-x); +/* Narrow screens: room for Starlight's menu button, which holds GitHub and the + theme select, so the bar's own are hidden */ +@media (width < 50em) { + [data-has-sidebar] .os-header .site-bar { + padding-inline-end: calc(var(--sl-nav-pad-x) + var(--sl-menu-button-size) + 0.5rem); + } + .os-header .site-bar__end { + display: none; } -} - -.os-wordmark { - display: flex; - align-items: center; - gap: 0.55rem; - color: var(--os-fg); - text-decoration: none; - font-weight: 600; - font-size: 1rem; - letter-spacing: -0.01em; - white-space: nowrap; -} -.os-wordmark__mark { - width: auto; - height: 1.625rem; - flex: none; } /* ---------- version picker (top of the sidebar) ---------- */ @@ -227,95 +207,6 @@ body { color: var(--os-muted); } -/* Site links next to the wordmark, set off by a divider; same as the landing - page's .site-links */ -.os-site-links { - display: flex; - align-items: center; - gap: 0.5rem; - margin-inline-start: 0.75rem; - padding-inline-start: 1rem; - border-inline-start: 1px solid var(--os-border); -} -.os-site-link { - padding: 0.25rem 0.5rem; - color: var(--os-fg); - font-size: 0.9375rem; - font-weight: 500; - text-decoration: none; - white-space: nowrap; -} -.os-site-link:hover, -.os-site-link[aria-current="page"] { - color: var(--os-accent-text); -} -@media (max-width: 50em) { - .os-header__row { - gap: 0.5rem; - } - .os-site-links { - gap: 0; - margin-inline-start: 0.25rem; - padding-inline-start: 0.5rem; - } - .os-site-link { - padding-inline: 0.375rem; - } -} - -.os-header__search { - flex: 1; - display: flex; - justify-content: flex-end; -} -@media (min-width: 50em) { - .os-header__search button[data-open-modal] { - max-width: 16rem; - height: 2.25rem; - border-radius: var(--os-radius); - background: var(--os-surface); - border-color: var(--os-border); - color: var(--os-muted); - } - .os-header__search button[data-open-modal]:hover { - border-color: var(--sl-color-gray-4); - color: var(--os-fg); - } - .os-header__search button[data-open-modal] > kbd { - background: var(--os-bg); - border: 1px solid var(--os-border); - } - .os-header__search button[data-open-modal] > kbd kbd { - background: none; - border: 0; - padding: 0; - } -} -.os-header__end { - align-items: center; - gap: 0.25rem; -} -/* GitHub link and theme toggle; same as the landing page's .icon-link */ -.os-icon-button, -.theme-toggle { - display: grid; - place-items: center; - width: 2rem; - height: 2rem; - padding: 0; - border: 0; - border-radius: var(--os-radius); - background: none; - color: var(--os-muted); - font-size: 1.125rem; - cursor: pointer; -} -.os-icon-button:hover, -.theme-toggle:hover { - color: var(--os-fg); - background: var(--os-surface); -} - .os-tabs { display: flex; gap: 1.5rem; diff --git a/theme/search.js b/theme/search.js new file mode 100644 index 0000000..9e857b2 --- /dev/null +++ b/theme/search.js @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: Apache-2.0 +// Search for the site bar (site-bar.mjs), on every page. The dialog's data +// attributes say which Pagefind index to search (data-bundle, data-base-url) +// and, on the full website, which index to merge (data-merge: the website +// pages in /pagefind-www/). The Pagefind UI loads on first open. +const dialog = document.querySelector('.search-dialog'); +const container = dialog?.querySelector('#site-search'); +const kbd = document.querySelector('.search-button__kbd'); +if (kbd && /Mac|iPhone|iPad/.test(navigator.platform)) kbd.textContent = '⌘ K'; + +// Starlight's default ranking, so results rank as they did with its search. +const ranking = { pageLength: 0.1, termFrequency: 0.1, termSaturation: 2, termSimilarity: 9, diacriticSimilarity: 0.8 }; + +let ready; +const load = () => + (ready ??= new Promise((resolve, reject) => { + const { bundle, baseUrl, merge } = dialog.dataset; + const css = document.createElement('link'); + css.rel = 'stylesheet'; + css.href = `${bundle}pagefind-ui.css`; + document.head.append(css); + const js = document.createElement('script'); + js.src = `${bundle}pagefind-ui.js`; + js.onload = () => { + new window.PagefindUI({ + element: '#site-search', + bundlePath: bundle, + baseUrl, + // Website pages count half, so a short page doesn't outrank the docs. + mergeIndex: merge ? [{ bundlePath: merge, baseUrl: '/', indexWeight: 0.5, ranking }] : [], + showSubResults: true, + showImages: false, + ranking, + }); + resolve(); + }; + js.onerror = reject; + document.head.append(js); + })); + +// Pagefind lists extra metadata as "Section: Go SDK" tags; show just the value, +// as a label next to the result title. +if (container) + new MutationObserver(() => { + for (const tag of container.querySelectorAll('.pagefind-ui__result-tag[data-pagefind-ui-meta="section"]')) { + const value = tag.textContent.replace(/^Section:\s*/, ''); + if (tag.textContent !== value) tag.textContent = value; + } + }).observe(container, { childList: true, subtree: true, characterData: true }); + +async function open() { + if (dialog.open) return; + dialog.showModal(); + await load(); + dialog.querySelector('.pagefind-ui__search-input')?.focus(); +} + +if (dialog) { + // Arrow keys move between the search field and the results (pages, their + // sections, and the "Load more" button); Enter opens the focused result. + dialog.addEventListener('keydown', (e) => { + if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return; + const input = dialog.querySelector('.pagefind-ui__search-input'); + const items = [...dialog.querySelectorAll('.pagefind-ui__result-link, .pagefind-ui__button')]; + if (!items.length) return; + const i = items.indexOf(document.activeElement); + const next = e.key === 'ArrowDown' ? items[Math.min(i + 1, items.length - 1)] : i <= 0 ? input : items[i - 1]; + e.preventDefault(); + next.focus(); + next + .closest('.pagefind-ui__result-nested, .pagefind-ui__result-inner, .pagefind-ui__button') + ?.scrollIntoView({ block: 'nearest' }); + }); + for (const b of document.querySelectorAll('[data-search-open]')) b.addEventListener('click', open); + dialog.querySelector('[data-search-close]')?.addEventListener('click', () => dialog.close()); + // A click on the backdrop closes the dialog; Esc closes it natively. + dialog.addEventListener('click', (e) => e.target === dialog && dialog.close()); + addEventListener('keydown', (e) => { + if ((e.metaKey || e.ctrlKey) && e.key === 'k') { + e.preventDefault(); + dialog.open ? dialog.close() : open(); + } + }); +} diff --git a/theme/site-bar.css b/theme/site-bar.css new file mode 100644 index 0000000..5af4d70 --- /dev/null +++ b/theme/site-bar.css @@ -0,0 +1,358 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +/* The site bar (site-bar.mjs) and its search dialog (search.js), shared by the + docs and the website pages. Colors and fonts come from tokens.css (--os-*). + The page around the bar only places it: the docs header stacks the topic + tabs below it, and the website pages make it sticky. */ +:root { + --site-text: color-mix(in srgb, var(--os-fg) 88%, var(--os-bg)); +} + +.site-bar { + display: flex; + align-items: center; + gap: 1rem; + height: var(--os-header-h); + padding-inline: 1.25rem; + border-bottom: 1px solid var(--os-border); + font-family: var(--os-font-sans); + line-height: 1.5; +} +@media (min-width: 50rem) { + .site-bar { + padding-inline: 1.5rem; + } +} +@media print { + .site-bar { + display: none; + } +} +.site-bar .sr-only { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; +} + +.site-bar__wordmark { + display: flex; + flex: none; + align-items: center; + gap: 0.55rem; + color: var(--os-fg); + font-size: 1rem; + font-weight: 600; + letter-spacing: -0.01em; + text-decoration: none; + white-space: nowrap; +} +.site-bar__wordmark svg { + width: auto; + height: 1.625rem; +} + +/* Site links, set off from the wordmark by a divider */ +.site-bar__links { + display: flex; + align-items: center; + gap: 0.5rem; + margin-inline-start: 0.75rem; + margin-inline-end: auto; + padding-inline-start: 1rem; + border-inline-start: 1px solid var(--os-border); +} +.site-bar__link { + padding: 0.25rem 0.5rem; + color: var(--os-fg); + font-size: 0.9375rem; + font-weight: 500; + text-decoration: none; + white-space: nowrap; +} +.site-bar__link:hover, +.site-bar__link[aria-current="page"] { + color: var(--os-accent-text); +} +@media (width < 50rem) { + .site-bar { + gap: 0.5rem; + } + .site-bar__links { + gap: 0; + margin-inline-start: 0.25rem; + padding-inline-start: 0.5rem; + } + .site-bar__link { + padding-inline: 0.375rem; + } +} + +.site-bar__end { + display: flex; + align-items: center; + gap: 0.25rem; +} +/* GitHub link and theme toggle */ +.icon-button { + display: grid; + place-items: center; + width: 2rem; + height: 2rem; + padding: 0; + border: 0; + border-radius: var(--os-radius); + background: none; + color: var(--os-muted); + cursor: pointer; +} +.icon-button:hover { + color: var(--os-fg); + background: var(--os-surface); +} +.icon-button svg { + width: 1.125rem; + height: 1.125rem; +} +/* theme-toggle.js sets data-theme-choice: auto, light, or dark */ +:root:not([data-theme-choice="light"]) .theme-toggle__light, +:root:not([data-theme-choice="dark"]) .theme-toggle__dark, +:root[data-theme-choice="light"] .theme-toggle__auto, +:root[data-theme-choice="dark"] .theme-toggle__auto { + display: none; +} + +/* ---------- search ---------- */ +.search-button { + display: flex; + flex: none; + align-items: center; + gap: 0.5rem; + width: 16rem; + height: 2.25rem; + padding: 0 0.5rem 0 0.75rem; + border: 1px solid var(--os-border); + border-radius: var(--os-radius); + background: var(--os-surface); + color: var(--os-muted); + font: inherit; + font-size: 0.875rem; + cursor: pointer; +} +.search-button:hover { + color: var(--os-fg); +} +.search-button svg { + width: 1rem; + height: 1rem; + flex: none; +} +.search-button__label { + margin-inline-end: auto; +} +.search-button__kbd { + padding: 0.05rem 0.35rem; + border: 1px solid var(--os-border); + border-radius: 4px; + background: var(--os-bg); + font-family: var(--os-font-sans); + font-size: 0.75rem; +} +.search-dialog { + width: min(100% - 2rem, 45rem); + max-height: calc(100% - 8rem); + margin: 4rem auto auto; + padding: 0; + border: 1px solid var(--os-border); + border-radius: var(--os-radius); + background: var(--os-bg); + color: var(--site-text); + box-shadow: 0 16px 48px rgb(0 0 0 / 0.25); +} +.search-dialog::backdrop { + background: rgb(0 0 0 / 0.45); + backdrop-filter: blur(2px); +} +.search-dialog__frame { + position: relative; + padding: 1rem; +} +/* The close button sits at the end of the search field's row */ +.search-dialog__close { + position: absolute; + top: calc(1rem + (64px * 0.8 - 2rem) / 2); + right: 1rem; + /* Above the search form, which spans the full width */ + z-index: 10; + display: grid; + place-items: center; + width: 2rem; + height: 2rem; + padding: 0; + border: 0; + border-radius: var(--os-radius); + background: none; + color: var(--os-muted); + cursor: pointer; +} +.search-dialog__close:hover { + color: var(--os-fg); + background: var(--os-surface); +} +.search-dialog__close svg { + width: 1.25rem; + height: 1.25rem; +} +/* Room for the close button next to the field (the results stay full width) */ +#site-search .pagefind-ui__search-input { + width: calc(100% - 2.5rem); +} +/* Clear reads as a link */ +#site-search .pagefind-ui__search-clear { + right: calc(2.5rem + 1px); + padding: 0 0.75rem; + color: var(--os-accent-text); + font-size: 0.875rem; + font-weight: 500; +} +#site-search .pagefind-ui__search-clear:hover { + text-decoration: underline; + text-underline-offset: 0.2em; +} +#site-search { + --pagefind-ui-scale: 0.8; + --pagefind-ui-primary: var(--os-fg); + --pagefind-ui-text: var(--site-text); + --pagefind-ui-background: var(--os-bg); + --pagefind-ui-border: var(--os-border); + --pagefind-ui-tag: var(--os-surface); + --pagefind-ui-border-radius: var(--os-radius); + --pagefind-ui-font: var(--os-font-sans); +} +/* Whole result rows are clickable: each result title link stretches over its + row (the page row, or one section row nested under it). */ +#site-search .pagefind-ui__result-inner, +#site-search .pagefind-ui__result-nested { + position: relative; + border-radius: var(--os-radius); +} +/* Tighter results; each page gets a page icon before its title */ +#site-search .pagefind-ui__result { + padding: 0.35rem 0; +} +#site-search .pagefind-ui__result-inner { + padding: 0.5rem 0.75rem; +} +#site-search .pagefind-ui__result-inner > .pagefind-ui__result-title { + display: flex; + align-items: center; + gap: 0.5rem; +} +#site-search .pagefind-ui__result-inner > .pagefind-ui__result-title::before { + content: ""; + flex: none; + width: 1.125rem; + height: 1.125rem; + background: var(--os-muted); + mask: + url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h6'/%3E%3C/svg%3E") + center / contain no-repeat; +} +/* Excerpts and sections line up with the title text, after the icon */ +#site-search .pagefind-ui__result-inner > .pagefind-ui__result-excerpt { + margin-inline-start: 1.625rem; +} +#site-search .pagefind-ui__result-nested { + /* Full row width, not the width of the text (Pagefind lays rows out with + align-items: flex-start) */ + align-self: stretch; + z-index: 1; + /* Cancel the page row's side padding so both highlights are equally wide */ + margin-inline: -0.75rem; + padding: 0.35rem 0.75rem 0.35rem calc(0.75rem + 1.625rem); +} +/* Pagefind positions section links (for the arrow), which would limit their + overlay to the link text; keep the arrow inline instead. */ +#site-search .pagefind-ui__result-nested .pagefind-ui__result-link, +#site-search .pagefind-ui__result-nested .pagefind-ui__result-link::before { + position: static; +} +#site-search .pagefind-ui__result-link::after { + content: ""; + position: absolute; + inset: 0; + border-radius: inherit; +} +#site-search .pagefind-ui__result-inner:hover:not(:has(.pagefind-ui__result-nested:hover)), +#site-search .pagefind-ui__result-nested:hover, +#site-search .pagefind-ui__result-inner:has(> .pagefind-ui__result-title .pagefind-ui__result-link:focus-visible), +#site-search .pagefind-ui__result-nested:has(.pagefind-ui__result-link:focus-visible) { + background: var(--os-surface); +} +#site-search .pagefind-ui__result-link:focus-visible { + outline: none; +} +/* Keyboard focus: the row's highlight plus an accent bar on its left edge */ +#site-search .pagefind-ui__result-link:focus-visible::after { + box-shadow: inset 3px 0 0 var(--os-accent); +} +/* Where a result comes from (Core, Go SDK, Community), top right of its row */ +#site-search .pagefind-ui__result-tags { + position: absolute; + top: 0.6rem; + right: 0.75rem; + margin: 0; +} +#site-search .pagefind-ui__result-tag { + padding: 0.05rem 0.5rem; + border-radius: 999px; + background: color-mix(in srgb, var(--os-accent) 14%, transparent); + color: var(--os-accent-text); + font-size: 0.75rem; + font-weight: 500; +} +#site-search .pagefind-ui__result-title { + padding-inline-end: 6rem; +} +/* Type scale of the rest of the site: semibold titles, a regular-weight query, + and excerpts at the docs' small-text size (Pagefind defaults to bold and + 12.8px at this scale) */ +#site-search .pagefind-ui__search-input { + font-weight: 400; +} +#site-search .pagefind-ui__result-title { + font-weight: 600; +} +#site-search .pagefind-ui__result-excerpt { + font-size: 0.875rem; + line-height: 1.5; +} +#site-search .pagefind-ui__message, +#site-search .pagefind-ui__button { + font-weight: 600; +} +#site-search mark { + background: none; + color: var(--os-accent-text); + font-weight: 600; +} +@media (width < 50rem) { + .search-button { + width: 2rem; + height: 2rem; + padding: 0; + justify-content: center; + border: 0; + background: none; + } + .search-button svg { + width: 1.125rem; + height: 1.125rem; + } + .search-button__label, + .search-button__kbd { + display: none; + } +} diff --git a/theme/site-bar.mjs b/theme/site-bar.mjs new file mode 100644 index 0000000..dcc0656 --- /dev/null +++ b/theme/site-bar.mjs @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: Apache-2.0 +// The site bar shared by every page: wordmark, site links, search, GitHub, and +// the theme toggle, plus the search dialog. The docs header +// (site/src/components/overrides/Header.astro) and the website pages +// (scripts/website.mjs) both render it from here, with the same styles +// (site-bar.css) and scripts (search.js, theme-toggle.js), so the bar can't +// differ between them. +import nav from './nav.json' with { type: 'json' }; + +const esc = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); + +const WORDMARK = `<svg viewBox="14 7 72 87" aria-hidden="true"><path d="M50 9 L84 23 V51 C84 72 69 86 50 92 C31 86 16 72 16 51 V23 Z" fill="#76B900"/><g fill="none" stroke="#FFFFFF" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"><path d="M37 41 L49 50 L37 59"/><path d="M55 59 H67"/></g></svg>`; +const SEARCH = `<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="6.5" fill="none" stroke="currentColor" stroke-width="1.75"/><path d="m16 16 4 4" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"/></svg>`; +const GITHUB = `<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.07 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.6-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"/></svg>`; +// Cycled by theme-toggle.js: auto (system), light, dark. +const THEME = `<button type="button" class="icon-button theme-toggle" aria-label="Theme: auto. Switch theme" title="Theme: auto"><svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__auto"><rect x="3" y="4.5" width="18" height="12" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.75"/><path d="M8 20h8M12 16.5V20" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"/></svg><svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__light"><circle cx="12" cy="12" r="4" fill="none" stroke="currentColor" stroke-width="1.75"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"/></svg><svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__dark"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linejoin="round"/></svg></button>`; +const CLOSE = `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"/></svg>`; + +/** + * @param {object} opts + * @param {string} [opts.current] href of the current site link (e.g. '/docs/'), marked as the current page + * @param {{ bundlePath: string, baseUrl: string, merge?: string }} opts.search + * the Pagefind index to search, and optionally a second index to merge + * (the website pages' /pagefind-www/) + */ +export function siteBar({ current, search }) { + const links = nav.links + .map( + (l) => + `<a href="${esc(l.href)}" class="site-bar__link"${l.href === current ? ' aria-current="page"' : ''}>${esc(l.label)}</a>`, + ) + .join(''); + const data = [ + ['bundle', search.bundlePath], + ['base-url', search.baseUrl], + ['merge', search.merge], + ] + .filter(([, v]) => v) + .map(([k, v]) => ` data-${k}="${esc(v)}"`) + .join(''); + return `<div class="site-bar"> +<a href="/" class="site-bar__wordmark" translate="no">${WORDMARK}<span>OpenShell</span></a> +<nav class="site-bar__links" aria-label="Site">${links}</nav> +<button type="button" class="search-button" data-search-open>${SEARCH}<span class="search-button__label">Search</span><kbd class="search-button__kbd">Ctrl K</kbd></button> +<div class="site-bar__end"> +<a href="${esc(nav.github)}" class="icon-button"><span class="sr-only">GitHub</span>${GITHUB}</a> +${THEME} +</div> +</div> +<dialog class="search-dialog" aria-label="Search"${data}> +<div class="search-dialog__frame"> +<button type="button" class="search-dialog__close" data-search-close aria-label="Close search">${CLOSE}</button> +<div id="site-search"></div> +</div> +</dialog>`; +} diff --git a/theme/theme-toggle.html b/theme/theme-toggle.html deleted file mode 100644 index 82cc3d5..0000000 --- a/theme/theme-toggle.html +++ /dev/null @@ -1,27 +0,0 @@ -<!-- SPDX-License-Identifier: Apache-2.0 --> -<!-- Theme toggle shared by the landing page (scripts/website.mjs) and the docs header (Header.astro). theme-toggle.js cycles auto, light, dark and sets data-theme-choice on <html>. Each host styles the button through the .theme-toggle class. --> -<button type="button" class="theme-toggle" aria-label="Theme: auto. Switch theme" title="Theme: auto"> - <svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__auto"> - <rect x="3" y="4.5" width="18" height="12" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.75" /> - <path d="M8 20h8M12 16.5V20" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" /> - </svg> - <svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__light"> - <circle cx="12" cy="12" r="4" fill="none" stroke="currentColor" stroke-width="1.75" /> - <path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" /> - </svg> - <svg viewBox="0 0 24 24" aria-hidden="true" class="theme-toggle__dark"> - <path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linejoin="round" /> - </svg> -</button> -<style> - .theme-toggle svg { - width: 1.125rem; - height: 1.125rem; - } - :root:not([data-theme-choice="light"]) .theme-toggle__light, - :root:not([data-theme-choice="dark"]) .theme-toggle__dark, - :root[data-theme-choice="light"] .theme-toggle__auto, - :root[data-theme-choice="dark"] .theme-toggle__auto { - display: none; - } -</style> diff --git a/theme/theme-toggle.js b/theme/theme-toggle.js index 49b4e78..05cd6a0 100644 --- a/theme/theme-toggle.js +++ b/theme/theme-toggle.js @@ -1,8 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 -// Theme toggle shared by the landing page and the docs header (markup in -// theme-toggle.html). Each click cycles auto -> light -> dark. The choice is -// stored where Starlight keeps it (localStorage starlight-theme, '' for auto), -// so it carries between the landing page and the docs, and Starlight's own +// Theme toggle in the site bar (markup in site-bar.mjs). Each click cycles +// auto -> light -> dark. The choice is stored where Starlight keeps it +// (localStorage starlight-theme, '' for auto), so it carries between the landing page and the docs, and Starlight's own // theme select in the docs mobile menu stays in sync. const KEY = 'starlight-theme'; const ORDER = ['auto', 'light', 'dark']; diff --git a/www/index.html b/www/index.html index 5f12fb8..ac38d82 100644 --- a/www/index.html +++ b/www/index.html @@ -16,6 +16,7 @@ href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap" /> <link rel="stylesheet" href="/tokens.css" /> + <link rel="stylesheet" href="/site-bar.css" /> <link rel="stylesheet" href="/style.css" /> <script> // Apply the theme before the page paints. Starlight stores the choice as @@ -33,47 +34,8 @@ </script> </head> <body> - <header class="top"> - <a href="/" class="wordmark" translate="no"> - <svg viewBox="14 7 72 87" aria-hidden="true"> - <path d="M50 9 L84 23 V51 C84 72 69 86 50 92 C31 86 16 72 16 51 V23 Z" fill="#76B900" /> - <g fill="none" stroke="#FFFFFF" stroke-width="6" stroke-linecap="round" stroke-linejoin="round"> - <path d="M37 41 L49 50 L37 59" /> - <path d="M55 59 H67" /> - </g> - </svg> - <span>OpenShell</span> - </a> - <!-- Links and the GitHub URL come from theme/nav.json and the theme toggle from theme/theme-toggle.html, all shared with the docs header; scripts/website.mjs fills them in. --> - <nav aria-label="Site" class="site-links"><!-- nav-links --></nav> - <div class="top-end"> - <button type="button" class="search-button" data-search-open> - <svg viewBox="0 0 24 24" aria-hidden="true"> - <circle cx="11" cy="11" r="6.5" fill="none" stroke="currentColor" stroke-width="1.75" /> - <path d="m16 16 4 4" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" /> - </svg> - <span class="search-button__label">Search</span> - <kbd class="search-button__kbd">Ctrl K</kbd> - </button> - <a href="{{github}}" class="icon-link"> - <span class="sr-only">GitHub</span> - <svg viewBox="0 0 24 24" aria-hidden="true"> - <path - fill="currentColor" - d="M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.07 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.6-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3" - /> - </svg> - </a> - <!-- theme-toggle --> - </div> - </header> - <!-- Site search (www/search.js): the docs' Pagefind index merged with the website pages' --> - <dialog class="search-dialog" aria-label="Search"> - <div class="search-dialog__frame"> - <button type="button" class="search-dialog__close" data-search-close>Cancel</button> - <div id="site-search"></div> - </div> - </dialog> + <!-- The site bar (theme/site-bar.mjs), shared with the docs; scripts/website.mjs fills it in. --> + <header class="top"><!-- site-bar --></header> <main> <!-- Copy comes from the ai-openshell/openshell README (intro, How It Works, diff --git a/www/search.js b/www/search.js deleted file mode 100644 index 2c50b68..0000000 --- a/www/search.js +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Search on the pages in www/. It uses the same two Pagefind indexes as the -// docs search: the docs index (/docs/pagefind/) merged with the website pages -// (/pagefind-www/, written by scripts/website.mjs). The search UI loads on -// first open. -const dialog = document.querySelector('.search-dialog'); -const kbd = document.querySelector('.search-button__kbd'); -if (kbd && /Mac|iPhone|iPad/.test(navigator.platform)) kbd.textContent = '⌘ K'; - -let ready; -// Starlight's default ranking, applied to both indexes as the docs search does, -// so results here match it. -const ranking = { pageLength: 0.1, termFrequency: 0.1, termSaturation: 2, termSimilarity: 9, diacriticSimilarity: 0.8 }; - -const load = () => - (ready ??= new Promise((resolve, reject) => { - const css = document.createElement('link'); - css.rel = 'stylesheet'; - css.href = '/docs/pagefind/pagefind-ui.css'; - document.head.append(css); - const js = document.createElement('script'); - js.src = '/docs/pagefind/pagefind-ui.js'; - js.onload = () => { - new window.PagefindUI({ - element: '#site-search', - bundlePath: '/docs/pagefind/', - baseUrl: '/docs/', - // Website pages count half, as in site/astro.config.mjs. - mergeIndex: [{ bundlePath: '/pagefind-www/', baseUrl: '/', indexWeight: 0.5, ranking }], - showSubResults: true, - showImages: false, - // Starlight's default ranking, so results match the docs search. - ranking: { - pageLength: 0.1, - termFrequency: 0.1, - termSaturation: 2, - termSimilarity: 9, - diacriticSimilarity: 0.8, - }, - }); - resolve(); - }; - js.onerror = reject; - document.head.append(js); - })); - -async function open() { - if (dialog.open) return; - dialog.showModal(); - await load(); - dialog.querySelector('.pagefind-ui__search-input')?.focus(); -} - -for (const b of document.querySelectorAll('[data-search-open]')) b.addEventListener('click', open); -document.querySelector('[data-search-close]')?.addEventListener('click', () => dialog.close()); -// A click on the backdrop closes the dialog. -dialog.addEventListener('click', (e) => e.target === dialog && dialog.close()); -addEventListener('keydown', (e) => { - if ((e.metaKey || e.ctrlKey) && e.key === 'k') { - e.preventDefault(); - dialog.open ? dialog.close() : open(); - } -}); diff --git a/www/style.css b/www/style.css index 0e8f2ed..b264a2d 100644 --- a/www/style.css +++ b/www/style.css @@ -66,84 +66,15 @@ a:hover { } /* ---------- header ---------- */ +/* The bar itself is theme/site-bar.css; here it only sticks to the top. */ .top { position: sticky; top: 0; z-index: 10; - display: flex; - align-items: center; - height: var(--os-header-h); - padding: 0 1.5rem; - border-bottom: 1px solid var(--os-border); background: color-mix(in srgb, var(--os-bg) 85%, transparent); backdrop-filter: blur(8px); } -.wordmark { - display: flex; - align-items: center; - gap: 0.55rem; - color: var(--strong); - font-weight: 600; - font-size: 1rem; - letter-spacing: -0.01em; - text-decoration: none; -} -.wordmark svg { - height: 1.625rem; - width: auto; -} - -/* Same layout as the docs header (site/src/components/overrides/Header.astro): - wordmark and site links on the left, GitHub and theme on the right. */ -.site-links { - display: flex; - align-items: center; - gap: 0.5rem; - margin-inline-start: 1.75rem; - margin-inline-end: auto; - padding-inline-start: 1rem; - border-inline-start: 1px solid var(--os-border); -} -.top-end { - display: flex; - align-items: center; - gap: 0.25rem; -} -.nav-link { - padding: 0.25rem 0.5rem; - color: var(--strong); - font-size: 0.9375rem; - font-weight: 500; - text-decoration: none; -} -.nav-link:hover, -.nav-link[aria-current="page"] { - color: var(--os-accent-text); -} -.icon-link, -.theme-toggle { - display: grid; - place-items: center; - width: 2rem; - height: 2rem; - padding: 0; - border: 0; - border-radius: var(--os-radius); - background: none; - color: var(--os-muted); - cursor: pointer; -} -.icon-link:hover, -.theme-toggle:hover { - color: var(--strong); - background: var(--os-surface); -} -.icon-link svg { - width: 1.125rem; - height: 1.125rem; -} - /* ---------- layout ---------- */ main { max-width: 64rem; @@ -176,10 +107,16 @@ h2 { padding-bottom: 3rem; } .page h1 { + /* Same as a docs page title (Starlight's --sl-text-h1 in site/src/styles/theme.css) */ margin: 0 0 1rem; - font-size: clamp(2rem, 4.5vw, 2.75rem); - line-height: 1.1; - letter-spacing: -0.03em; + font-size: 2rem; + line-height: 1.2; + letter-spacing: -0.025em; +} +@media (min-width: 50rem) { + .page h1 { + font-size: 2.125rem; + } } .page h2 { margin: 2.5rem 0 0.5rem; @@ -466,24 +403,6 @@ a.card:hover .arrow { display: block; } -/* Same side padding and link spacing as the docs header, at the same - breakpoints (site/src/styles/theme.css), so the bar doesn't shift between - the landing page and the docs. */ -@media (width < 50rem) { - .top { - padding: 0 1.25rem; - } -} -@media (max-width: 50rem) { - .site-links { - gap: 0; - margin-inline-start: 0.75rem; - padding-inline-start: 0.5rem; - } - .nav-link { - padding-inline: 0.375rem; - } -} @media (max-width: 40rem) { main { padding: 0 1rem; @@ -492,105 +411,3 @@ a.card:hover .arrow { padding-top: 3.5rem; } } - -/* ---------- search (www/search.js) ---------- */ -/* The button matches the docs header search; the dialog follows Starlight's. */ -.search-button { - display: flex; - align-items: center; - gap: 0.5rem; - width: 16rem; - height: 2.25rem; - margin-inline-end: 0.5rem; - padding: 0 0.5rem 0 0.75rem; - border: 1px solid var(--os-border); - border-radius: var(--os-radius); - background: var(--os-surface); - color: var(--os-muted); - font: inherit; - font-size: 0.875rem; - cursor: pointer; -} -.search-button:hover { - color: var(--strong); -} -.search-button svg { - width: 1rem; - height: 1rem; - flex: none; -} -.search-button__label { - margin-inline-end: auto; -} -.search-button__kbd { - padding: 0.05rem 0.35rem; - border: 1px solid var(--os-border); - border-radius: 4px; - background: var(--os-bg); - font-family: var(--os-font-sans); - font-size: 0.75rem; -} -.search-dialog { - width: min(100% - 2rem, 45rem); - max-height: calc(100% - 8rem); - margin: 4rem auto auto; - padding: 0; - border: 1px solid var(--os-border); - border-radius: var(--os-radius); - background: var(--os-bg); - color: var(--text); - box-shadow: 0 16px 48px rgb(0 0 0 / 0.25); -} -.search-dialog::backdrop { - background: rgb(0 0 0 / 0.45); - backdrop-filter: blur(2px); -} -.search-dialog__frame { - display: flex; - flex-direction: column; - gap: 0.75rem; - padding: 1rem; -} -.search-dialog__close { - align-self: flex-end; - border: 0; - background: none; - color: var(--os-accent-text); - font: inherit; - font-size: 0.875rem; - cursor: pointer; -} -#site-search { - --pagefind-ui-scale: 0.8; - --pagefind-ui-primary: var(--strong); - --pagefind-ui-text: var(--text); - --pagefind-ui-background: var(--os-bg); - --pagefind-ui-border: var(--os-border); - --pagefind-ui-tag: var(--os-surface); - --pagefind-ui-border-radius: var(--os-radius); - --pagefind-ui-font: var(--os-font-sans); -} -#site-search mark { - background: none; - color: var(--os-accent-text); - font-weight: 600; -} -@media (width < 50rem) { - .search-button { - width: 2rem; - height: 2rem; - margin-inline-end: 0; - padding: 0; - justify-content: center; - border: 0; - background: none; - } - .search-button svg { - width: 1.125rem; - height: 1.125rem; - } - .search-button__label, - .search-button__kbd { - display: none; - } -}