@icebreakers/monorepo-templates 2.0.7 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/assets/.agents/skills/repoctl/SKILL.md +4 -2
- package/assets/.agents/skills/repoctl/references/commands.md +224 -13
- package/assets/.agents/skills/repoctl/references/config.md +70 -6
- package/assets/.agents/skills/repoctl/references/dependencies.md +37 -0
- package/assets/.agents/skills/repoctl/references/knip.md +34 -0
- package/assets/.agents/skills/repoctl/references/templates.md +26 -2
- package/assets/.github/workflows/ci.yml +10 -14
- package/assets/package.json +8 -16
- package/assets/pnpm-workspace.yaml +4 -1
- package/assets/repoctl.config.ts +1 -1
- package/assets/turbo.json +12 -4
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +281 -1
- package/dist/index.mjs +1138 -75
- package/dist/{prepare-BapI8ioj.mjs → prepare-BYNSxvoB.mjs} +96 -4
- package/package.json +2 -1
- package/template-data.mjs +32 -0
- package/templates/client/package.json +2 -2
- package/templates/next/README.md +31 -0
- package/templates/next/eslint.config.js +5 -0
- package/templates/next/gitignore +7 -0
- package/templates/next/next.config.ts +5 -0
- package/templates/next/package.json +36 -0
- package/templates/next/src/app/api/health/route.ts +5 -0
- package/templates/next/src/app/counter.tsx +19 -0
- package/templates/next/src/app/favicon.ico +0 -0
- package/templates/next/src/app/globals.css +109 -0
- package/templates/next/src/app/layout.tsx +17 -0
- package/templates/next/src/app/page.tsx +16 -0
- package/templates/next/stylelint.config.js +3 -0
- package/templates/next/test/counter.test.tsx +22 -0
- package/templates/next/tsconfig.json +40 -0
- package/templates/next/turbo.json +24 -0
- package/templates/next/vitest.config.js +9 -0
- package/templates/nimbus/AGENTS.md +12 -0
- package/templates/nimbus/LICENSE +21 -0
- package/templates/nimbus/README.md +17 -0
- package/templates/nimbus/UPSTREAM.md +16 -0
- package/templates/nimbus/astro.config.ts +28 -0
- package/templates/nimbus/eslint.config.js +25 -0
- package/templates/nimbus/gitignore +5 -0
- package/templates/nimbus/nimbus.json +4 -0
- package/templates/nimbus/package.json +34 -0
- package/templates/nimbus/public/favicon.svg +1 -0
- package/templates/nimbus/scripts/check-locales.mjs +11 -0
- package/templates/nimbus/src/components/aside.astro +9 -0
- package/templates/nimbus/src/components/head.astro +43 -0
- package/templates/nimbus/src/components/search/client.ts +62 -0
- package/templates/nimbus/src/components/search/index.astro +26 -0
- package/templates/nimbus/src/components/sidebar.astro +26 -0
- package/templates/nimbus/src/components.ts +3 -0
- package/templates/nimbus/src/content/docs/get-started.mdx +36 -0
- package/templates/nimbus/src/content/docs/index.mdx +16 -0
- package/templates/nimbus/src/content/docs/writing.mdx +35 -0
- package/templates/nimbus/src/content/docs/zh/get-started.mdx +36 -0
- package/templates/nimbus/src/content/docs/zh/index.mdx +16 -0
- package/templates/nimbus/src/content/docs/zh/writing.mdx +35 -0
- package/templates/nimbus/src/content.config.ts +6 -0
- package/templates/nimbus/src/env.d.ts +6 -0
- package/templates/nimbus/src/layouts/docs.astro +70 -0
- package/templates/nimbus/src/lib/locale.ts +50 -0
- package/templates/nimbus/src/pages/[...slug]/index.md.ts +4 -0
- package/templates/nimbus/src/pages/[...slug]/index.mdx.ts +4 -0
- package/templates/nimbus/src/pages/[...slug].astro +36 -0
- package/templates/nimbus/src/pages/[section]/llms.txt.ts +4 -0
- package/templates/nimbus/src/pages/llms-full.txt.ts +4 -0
- package/templates/nimbus/src/pages/llms.txt.ts +4 -0
- package/templates/nimbus/src/pages/robots.txt.ts +18 -0
- package/templates/nimbus/src/styles/base.css +121 -0
- package/templates/nimbus/src/styles/site.css +186 -0
- package/templates/nimbus/stylelint.config.js +3 -0
- package/templates/nimbus/tsconfig.json +10 -0
- package/templates/react-lib/LICENSE +21 -0
- package/templates/react-lib/README.md +52 -0
- package/templates/react-lib/eslint.config.js +5 -0
- package/templates/react-lib/gitignore +4 -0
- package/templates/react-lib/package.json +48 -0
- package/templates/react-lib/src/counter.tsx +28 -0
- package/templates/react-lib/src/index.ts +2 -0
- package/templates/react-lib/src/style.css +36 -0
- package/templates/react-lib/stylelint.config.js +3 -0
- package/templates/react-lib/test/counter.test.tsx +28 -0
- package/templates/react-lib/test-d/index.test-d.ts +11 -0
- package/templates/react-lib/tsconfig.app.json +15 -0
- package/templates/react-lib/tsconfig.build.json +12 -0
- package/templates/react-lib/tsconfig.json +4 -0
- package/templates/react-lib/tsconfig.node.json +11 -0
- package/templates/react-lib/vite.config.ts +22 -0
- package/templates/react-lib/vitest.config.ts +5 -0
- package/templates/react-vite/README.md +27 -0
- package/templates/react-vite/eslint.config.js +5 -0
- package/templates/react-vite/gitignore +6 -0
- package/templates/react-vite/index.html +13 -0
- package/templates/react-vite/package.json +36 -0
- package/templates/react-vite/src/app.tsx +22 -0
- package/templates/react-vite/src/main.tsx +15 -0
- package/templates/react-vite/src/style.css +95 -0
- package/templates/react-vite/stylelint.config.js +3 -0
- package/templates/react-vite/test/app.test.tsx +22 -0
- package/templates/react-vite/tsconfig.app.json +26 -0
- package/templates/react-vite/tsconfig.json +11 -0
- package/templates/react-vite/tsconfig.node.json +18 -0
- package/templates/react-vite/vite.config.ts +6 -0
- package/templates/react-vite/vitest.config.ts +9 -0
- package/templates/server/package.json +1 -1
- package/templates/vitepress/.vitepress/config.ts +4 -5
- package/templates/vitepress/.vitepress/home/content.ts +2 -2
- package/templates/vitepress/.vitepress/home/faq.ts +16 -0
- package/templates/vitepress/.vitepress/mermaid/markdown.ts +18 -0
- package/templates/vitepress/.vitepress/mermaid/mermaid.vue +66 -0
- package/templates/vitepress/.vitepress/mermaid/render.ts +37 -0
- package/templates/vitepress/.vitepress/navigation/routes.ts +7 -0
- package/templates/vitepress/.vitepress/seo.ts +12 -1
- package/templates/vitepress/.vitepress/theme/components/HomePage.vue +2 -16
- package/templates/vitepress/.vitepress/theme/index.ts +3 -1
- package/templates/vitepress/ai/create.md +1 -1
- package/templates/vitepress/package.json +4 -8
- package/templates/vitepress/reference/artifacts.md +51 -0
- package/templates/vitepress/reference/commands.md +152 -3
- package/templates/vitepress/reference/config.md +101 -7
- package/templates/vitepress/reference/dependencies.md +116 -0
- package/templates/vitepress/reference/dependency-admission.md +67 -0
- package/templates/vitepress/reference/devcontainer.md +25 -0
- package/templates/vitepress/reference/index.md +1 -0
- package/templates/vitepress/reference/install-security.md +51 -0
- package/templates/vitepress/reference/knip.md +55 -0
- package/templates/vitepress/reference/move.md +39 -0
- package/templates/vitepress/reference/organization-presets.md +89 -0
- package/templates/vitepress/reference/removal.md +42 -0
- package/templates/vitepress/reference/template-assets.md +40 -1
- package/templates/vitepress/reference/templates.md +376 -9
- package/templates/vitepress/start/diagnose.md +19 -2
- package/templates/vitepress/tasks/checks.md +149 -1
- package/templates/vitepress/tasks/ci.md +93 -1
- package/templates/vitepress/tasks/index.md +1 -1
- package/templates/vitepress/tasks/release.md +72 -6
- package/templates/vitepress/test/mermaid.test.ts +39 -0
- package/templates/vitepress/test/render.test.ts +48 -0
- package/templates/vitepress/test/seo.test.ts +19 -0
- package/templates/vitepress/tsconfig.json +8 -8
- package/templates/vitepress/vitest.config.ts +8 -0
- package/templates/vitepress/zh/ai/create.md +1 -1
- package/templates/vitepress/zh/learn/monorepo/manage.md +1 -1
- package/templates/vitepress/zh/reference/artifacts.md +51 -0
- package/templates/vitepress/zh/reference/commands.md +151 -3
- package/templates/vitepress/zh/reference/config.md +94 -2
- package/templates/vitepress/zh/reference/dependencies.md +116 -0
- package/templates/vitepress/zh/reference/dependency-admission.md +67 -0
- package/templates/vitepress/zh/reference/devcontainer.md +25 -0
- package/templates/vitepress/zh/reference/execution-model.md +1 -1
- package/templates/vitepress/zh/reference/index.md +1 -0
- package/templates/vitepress/zh/reference/install-security.md +51 -0
- package/templates/vitepress/zh/reference/knip.md +55 -0
- package/templates/vitepress/zh/reference/move.md +39 -0
- package/templates/vitepress/zh/reference/organization-presets.md +89 -0
- package/templates/vitepress/zh/reference/removal.md +42 -0
- package/templates/vitepress/zh/reference/template-assets.md +22 -6
- package/templates/vitepress/zh/reference/templates.md +356 -9
- package/templates/vitepress/zh/start/diagnose.md +24 -13
- package/templates/vitepress/zh/tasks/checks.md +150 -0
- package/templates/vitepress/zh/tasks/ci.md +93 -1
- package/templates/vitepress/zh/tasks/index.md +1 -1
- package/templates/vitepress/zh/tasks/release.md +72 -6
- package/templates/vitepress/zh/tasks/reports.md +1 -1
- package/templates/vue-lib/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Upstream source
|
|
2
|
+
|
|
3
|
+
This template adapts the static empty starter from [Cloudflare Nimbus](https://github.com/cloudflare/nimbus), released under the MIT license (see `LICENSE`).
|
|
4
|
+
|
|
5
|
+
- Starter tag: `templates-v0.7.9`
|
|
6
|
+
- Starter commit: `aae348048a8c659f84c39696ee6b20c2ad2f5ae2`
|
|
7
|
+
- Nimbus package: `@cloudflare/nimbus-docs@0.15.2`
|
|
8
|
+
- Astro: `7.3.1`
|
|
9
|
+
|
|
10
|
+
Nimbus declares Astro `>=7.2.6 <8`; Astro requires Node `>=22.12.0`, so this workspace retains its stricter Node `>=22.13.0` baseline. Builds, Astro diagnostics and TypeScript checks were verified with the repository's TypeScript `6.0.3` and Vite `8.3.1` constraints. Resolved dependencies are recorded in the monorepo's root `pnpm-lock.yaml`; generated projects use their own root workspace lockfile.
|
|
11
|
+
|
|
12
|
+
Agent endpoint routes and the content-loading approach come from that starter. The bilingual layout, navigation, search interface, examples and workspace checks are repoctl adaptations. These files are maintained locally; generating a project never downloads the upstream starter.
|
|
13
|
+
|
|
14
|
+
The local head component emits page-specific language metadata because the upstream head uses the site-wide locale. Client scripts are emitted as external assets so Astro does not inline them before Vite finalizes Pagefind's dynamic import.
|
|
15
|
+
|
|
16
|
+
The package version and starter tag were checked against published package metadata. `nimbus.json` records the reviewed package API baseline. The original full starter was not copied wholesale, so upstream starter diffs are not a claim that every local file is an unmodified upstream component.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import nimbus, { defineConfig as defineNimbusConfig } from '@cloudflare/nimbus-docs'
|
|
2
|
+
import { defineConfig } from 'astro/config'
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
output: 'static',
|
|
6
|
+
// Keep the Pagefind loader external so Vite finalizes dynamic imports before Astro renders it.
|
|
7
|
+
vite: { build: { assetsInlineLimit: 0 } },
|
|
8
|
+
integrations: [nimbus(defineNimbusConfig({
|
|
9
|
+
// Set your production origin before publishing.
|
|
10
|
+
site: 'https://docs.example.com',
|
|
11
|
+
title: 'Project docs',
|
|
12
|
+
description: 'Guides and examples for your project.',
|
|
13
|
+
locale: 'en',
|
|
14
|
+
github: null,
|
|
15
|
+
}), {
|
|
16
|
+
icons: false,
|
|
17
|
+
rules: {
|
|
18
|
+
'nimbus/frontmatter-shape': 'error',
|
|
19
|
+
'nimbus/internal-link': 'error',
|
|
20
|
+
'nimbus/single-h1': 'error',
|
|
21
|
+
},
|
|
22
|
+
markdown: {
|
|
23
|
+
componentMap: {
|
|
24
|
+
Aside: { revision: '1', render: ({ children }) => children },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
})],
|
|
28
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import astro from 'eslint-plugin-astro'
|
|
2
|
+
import * as mdx from 'eslint-plugin-mdx'
|
|
3
|
+
import { defineEslintConfig } from 'repoctl/tooling'
|
|
4
|
+
|
|
5
|
+
const shared = await defineEslintConfig({ options: { astro: false, formatters: false } })
|
|
6
|
+
|
|
7
|
+
// Markup has its own parser and formatter. Shared JS rules still check the
|
|
8
|
+
// virtual TypeScript files extracted from Astro script blocks.
|
|
9
|
+
const code = shared.map((config) => {
|
|
10
|
+
if (Object.keys(config).every(key => key === 'name' || key === 'ignores')) {
|
|
11
|
+
return config
|
|
12
|
+
}
|
|
13
|
+
return { ...config, ignores: [...(config.ignores ?? []), '**/*.astro', '**/*.mdx', '**/*.mdx/**'] }
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default [
|
|
17
|
+
...code,
|
|
18
|
+
...astro.configs['flat/recommended'],
|
|
19
|
+
{
|
|
20
|
+
...mdx.flat,
|
|
21
|
+
files: ['**/*.mdx'],
|
|
22
|
+
languageOptions: { ...mdx.flat.languageOptions, globals: { Aside: 'readonly' } },
|
|
23
|
+
},
|
|
24
|
+
{ ignores: ['.astro/**', '.nimbus/**', 'dist/**', '**/*.css'] },
|
|
25
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@icebreakers/nimbus-template",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"description": "Bilingual Nimbus documentation starter",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.13.0"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "astro dev",
|
|
13
|
+
"build": "pnpm check:locales && astro build",
|
|
14
|
+
"preview": "astro preview",
|
|
15
|
+
"typecheck": "astro check && tsc --noEmit",
|
|
16
|
+
"lint": "eslint . && stylelint \"src/styles/**/*.css\" && nimbus-docs lint",
|
|
17
|
+
"lint:docs": "nimbus-docs lint",
|
|
18
|
+
"lint:docs:fix": "nimbus-docs lint --fix",
|
|
19
|
+
"check:locales": "node scripts/check-locales.mjs"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@cloudflare/nimbus-docs": "0.15.2",
|
|
23
|
+
"astro": "7.3.5"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@astrojs/check": "^0.9.10",
|
|
27
|
+
"@astrojs/language-server": "2.17.1",
|
|
28
|
+
"astro-eslint-parser": "^3.2.0",
|
|
29
|
+
"eslint-plugin-astro": "^3.2.1",
|
|
30
|
+
"eslint-plugin-mdx": "^3.8.1",
|
|
31
|
+
"pagefind": "^1.5.2",
|
|
32
|
+
"typescript": "^6.0.3"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="7" fill="#1d4ed8"/><path d="M9 8h10l4 4v12H9zM18 8v5h5M12 17h8M12 21h6" fill="none" stroke="white" stroke-width="1.6" stroke-linejoin="round"/></svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import { readdir } from 'node:fs/promises'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
const content = new URL('../src/content/docs/', import.meta.url)
|
|
6
|
+
const files = await readdir(content, { recursive: true })
|
|
7
|
+
const pages = files.filter(file => /\.mdx?$/.test(file)).map(file => file.split(path.sep).join('/'))
|
|
8
|
+
const english = pages.filter(file => !file.startsWith('zh/')).sort()
|
|
9
|
+
const chinese = pages.filter(file => file.startsWith('zh/')).map(file => file.slice(3)).sort()
|
|
10
|
+
assert.deepEqual(chinese, english, 'Every published page needs matching English and Chinese source files.')
|
|
11
|
+
console.log(`Locale parity checked: ${english.length} page pairs.`)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { withBase } from '@cloudflare/nimbus-docs/runtime'
|
|
3
|
+
import { config } from 'virtual:nimbus/config'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
title: string
|
|
7
|
+
description?: string | undefined
|
|
8
|
+
markdownUrl?: string | undefined
|
|
9
|
+
noindex?: boolean | undefined
|
|
10
|
+
chinese: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { title, description = config.description, markdownUrl, noindex, chinese } = Astro.props
|
|
14
|
+
const base = import.meta.env.BASE_URL
|
|
15
|
+
const fullTitle = `${title} | ${config.title}`
|
|
16
|
+
const language = chinese ? 'zh-CN' : 'en'
|
|
17
|
+
const canonical = new URL(Astro.url.pathname, Astro.site)
|
|
18
|
+
const structuredData = JSON.stringify({
|
|
19
|
+
'@context': 'https://schema.org',
|
|
20
|
+
'@type': 'WebPage',
|
|
21
|
+
'name': fullTitle,
|
|
22
|
+
description,
|
|
23
|
+
'url': canonical.href,
|
|
24
|
+
'inLanguage': language,
|
|
25
|
+
})
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<title>{fullTitle}</title>
|
|
29
|
+
<meta name="generator" content={Astro.generator} />
|
|
30
|
+
<meta name="description" content={description} />
|
|
31
|
+
{noindex && <meta name="robots" content="noindex" />}
|
|
32
|
+
<link rel="icon" type="image/svg+xml" href={withBase('/favicon.svg', base)} />
|
|
33
|
+
<link rel="stylesheet" href={withBase('/_nimbus/shiki.css', base)} />
|
|
34
|
+
<link rel="canonical" href={canonical} />
|
|
35
|
+
<link rel="sitemap" href={withBase('/sitemap-index.xml', base)} />
|
|
36
|
+
{markdownUrl && <link rel="alternate" type="text/markdown" href={new URL(withBase(markdownUrl, base), Astro.site)} />}
|
|
37
|
+
<meta property="og:title" content={fullTitle} />
|
|
38
|
+
<meta property="og:type" content="article" />
|
|
39
|
+
<meta property="og:site_name" content={config.title} />
|
|
40
|
+
<meta property="og:locale" content={chinese ? 'zh_CN' : 'en_US'} />
|
|
41
|
+
<meta property="og:description" content={description} />
|
|
42
|
+
<meta property="og:url" content={canonical} />
|
|
43
|
+
<script type="application/ld+json" set:html={structuredData} />
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
interface SearchResult {
|
|
2
|
+
url: string
|
|
3
|
+
meta: { title?: string }
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface Pagefind {
|
|
7
|
+
init: () => Promise<void>
|
|
8
|
+
search: (query: string) => Promise<{ results: { data: () => Promise<SearchResult> }[] }>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Pagefind is emitted by the Nimbus production build, not bundled by Vite.
|
|
12
|
+
export function mountSearch(root: HTMLElement) {
|
|
13
|
+
const form = root.querySelector('form')!
|
|
14
|
+
const input = root.querySelector('input')!
|
|
15
|
+
const status = root.querySelector<HTMLElement>('[role="status"]')!
|
|
16
|
+
const results = root.querySelector('ul')!
|
|
17
|
+
let api: Promise<Pagefind> | undefined
|
|
18
|
+
let request = 0
|
|
19
|
+
|
|
20
|
+
form.addEventListener('submit', async (event) => {
|
|
21
|
+
event.preventDefault()
|
|
22
|
+
const current = ++request
|
|
23
|
+
results.replaceChildren()
|
|
24
|
+
const query = input.value.trim()
|
|
25
|
+
if (!query) {
|
|
26
|
+
status.textContent = ''
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
status.textContent = root.dataset.loading ?? ''
|
|
30
|
+
try {
|
|
31
|
+
const base = (root.dataset.base ?? '/').replace(/\/$/, '')
|
|
32
|
+
api ??= import(/* @vite-ignore */ `${base}/pagefind/pagefind.js`).then(async (module: Pagefind) => {
|
|
33
|
+
await module.init()
|
|
34
|
+
return module
|
|
35
|
+
})
|
|
36
|
+
const response = await (await api).search(query)
|
|
37
|
+
const pages = await Promise.all(response.results.slice(0, 10).map(result => result.data()))
|
|
38
|
+
if (current !== request) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
status.textContent = pages.length ? '' : root.dataset.empty ?? ''
|
|
42
|
+
for (const page of pages) {
|
|
43
|
+
const url = new URL(page.url, window.location.origin)
|
|
44
|
+
if (url.origin !== window.location.origin) {
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
const item = document.createElement('li')
|
|
48
|
+
const link = document.createElement('a')
|
|
49
|
+
link.href = url.href
|
|
50
|
+
link.textContent = page.meta.title ?? page.url
|
|
51
|
+
item.append(link)
|
|
52
|
+
results.append(item)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
api = undefined
|
|
57
|
+
if (current === request) {
|
|
58
|
+
status.textContent = root.dataset.unavailable ?? ''
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { labels } from '../../lib/locale'
|
|
3
|
+
|
|
4
|
+
interface Props { chinese: boolean }
|
|
5
|
+
const { chinese } = Astro.props
|
|
6
|
+
const text = labels[chinese ? 'zh' : 'en']
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<details class="search-panel" data-search data-base={import.meta.env.BASE_URL} data-loading={text.loading} data-empty={text.empty} data-unavailable={text.unavailable}>
|
|
10
|
+
<summary>{text.search}</summary>
|
|
11
|
+
<form role="search">
|
|
12
|
+
<label for="docs-search">{text.search}</label>
|
|
13
|
+
<div class="search-controls">
|
|
14
|
+
<input id="docs-search" name="query" type="search" required autocomplete="off" />
|
|
15
|
+
<button type="submit">{text.submit}</button>
|
|
16
|
+
</div>
|
|
17
|
+
</form>
|
|
18
|
+
<p role="status" aria-live="polite"></p>
|
|
19
|
+
<ul class="search-results"></ul>
|
|
20
|
+
</details>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import { mountSearch } from './client'
|
|
24
|
+
|
|
25
|
+
document.querySelectorAll<HTMLElement>('[data-search]').forEach(mountSearch)
|
|
26
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { SidebarItem } from '@cloudflare/nimbus-docs/types'
|
|
3
|
+
import { withBase } from '@cloudflare/nimbus-docs/runtime'
|
|
4
|
+
|
|
5
|
+
interface Props { items: SidebarItem[] }
|
|
6
|
+
const { items } = Astro.props
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<ul class="navigation-list">
|
|
10
|
+
{items.map(item => (
|
|
11
|
+
<li>
|
|
12
|
+
{item.type === 'group'
|
|
13
|
+
? (
|
|
14
|
+
<>
|
|
15
|
+
{item.indexHref
|
|
16
|
+
? <a href={withBase(item.indexHref, import.meta.env.BASE_URL)} aria-current={item.indexIsCurrent ? 'page' : undefined}>{item.label}</a>
|
|
17
|
+
: <span>{item.label}</span>}
|
|
18
|
+
<Astro.self items={item.children} />
|
|
19
|
+
</>
|
|
20
|
+
)
|
|
21
|
+
: (
|
|
22
|
+
<a href={withBase(item.href, import.meta.env.BASE_URL)} aria-current={item.type === 'link' && item.isCurrent ? 'page' : undefined}>{item.label}</a>
|
|
23
|
+
)}
|
|
24
|
+
</li>
|
|
25
|
+
))}
|
|
26
|
+
</ul>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Quick start
|
|
3
|
+
description: Run, edit and publish your documentation.
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Install dependencies
|
|
9
|
+
|
|
10
|
+
At the monorepo root:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
corepack enable
|
|
14
|
+
pnpm install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Start the site
|
|
18
|
+
|
|
19
|
+
In the documentation workspace:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Edit `src/content/docs/index.mdx` and its Chinese counterpart `src/content/docs/zh/index.mdx`.
|
|
26
|
+
|
|
27
|
+
## Build and preview
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pnpm build
|
|
31
|
+
pnpm preview
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The build writes `dist/` and creates the search index. Set your production URL in `astro.config.ts` before publishing.
|
|
35
|
+
|
|
36
|
+
Continue with the [writing guide](/writing/).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Welcome
|
|
3
|
+
description: A home for your project’s guides and examples.
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Start with the essentials
|
|
9
|
+
|
|
10
|
+
Follow the [quick start](/get-started/) to run this site locally, then use the [writing guide](/writing/) to add your own documentation.
|
|
11
|
+
|
|
12
|
+
## One source, two ways to read
|
|
13
|
+
|
|
14
|
+
Read in your browser or open the Markdown link below each page. The documentation index at `/llms.txt` helps tools find individual pages without downloading the entire site.
|
|
15
|
+
|
|
16
|
+
[阅读中文文档](/zh/)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Writing guide
|
|
3
|
+
description: Add pages that work for readers and tools.
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Add a page
|
|
9
|
+
|
|
10
|
+
Create matching files under `src/content/docs/` and `src/content/docs/zh/`. Give each page a title, description and sidebar order in frontmatter.
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
title: Your page
|
|
14
|
+
description: What the reader will learn.
|
|
15
|
+
sidebar:
|
|
16
|
+
order: 3
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Use components carefully
|
|
20
|
+
|
|
21
|
+
<Aside>
|
|
22
|
+
Keep the meaning of an example in its text. Interactive illustrations should have a written explanation too.
|
|
23
|
+
</Aside>
|
|
24
|
+
|
|
25
|
+
Register components in `src/components.ts` and their text representation in `astro.config.ts`.
|
|
26
|
+
|
|
27
|
+
## Validate before publishing
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pnpm build
|
|
31
|
+
pnpm lint
|
|
32
|
+
pnpm typecheck
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Use `draft: true` while a page is unfinished. Open the published Markdown link and check that examples, links and component text are readable.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 快速开始
|
|
3
|
+
description: 运行、编辑和发布你的文档。
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 安装依赖
|
|
9
|
+
|
|
10
|
+
在 monorepo 根目录执行:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
corepack enable
|
|
14
|
+
pnpm install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 启动站点
|
|
18
|
+
|
|
19
|
+
进入文档工作区执行:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
编辑 `src/content/docs/zh/index.mdx`,并同步英文版本 `src/content/docs/index.mdx`。
|
|
26
|
+
|
|
27
|
+
## 构建与预览
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pnpm build
|
|
31
|
+
pnpm preview
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
构建会生成 `dist/` 和搜索索引。发布前,在 `astro.config.ts` 中填写正式站点地址。
|
|
35
|
+
|
|
36
|
+
继续阅读[写作指南](/zh/writing/)。
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 欢迎
|
|
3
|
+
description: 在这里记录项目的使用指南与示例。
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 从基础开始
|
|
9
|
+
|
|
10
|
+
按照[快速开始](/zh/get-started/)在本地运行站点,再参考[写作指南](/zh/writing/)添加自己的文档。
|
|
11
|
+
|
|
12
|
+
## 一份内容,两种阅读方式
|
|
13
|
+
|
|
14
|
+
读者可以浏览网页,也可以打开每页底部的 Markdown 链接。文档索引 `/zh/llms.txt`帮助工具定位单个页面,无需下载整个站点。
|
|
15
|
+
|
|
16
|
+
[Read the English documentation](/)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 写作指南
|
|
3
|
+
description: 添加适合读者和工具使用的页面。
|
|
4
|
+
sidebar:
|
|
5
|
+
order: 2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 添加页面
|
|
9
|
+
|
|
10
|
+
在 `src/content/docs/` 和 `src/content/docs/zh/` 下创建路径对应的文件,在 frontmatter 中填写标题、描述和导航顺序。
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
title: 页面标题
|
|
14
|
+
description: 读者将在本页学到什么。
|
|
15
|
+
sidebar:
|
|
16
|
+
order: 3
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 使用组件
|
|
20
|
+
|
|
21
|
+
<Aside>
|
|
22
|
+
用文字保留示例的含义。交互图示也需要配套文字说明。
|
|
23
|
+
</Aside>
|
|
24
|
+
|
|
25
|
+
在 `src/components.ts` 中注册组件,并在 `astro.config.ts` 中定义对应的文本输出。
|
|
26
|
+
|
|
27
|
+
## 发布前检查
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pnpm build
|
|
31
|
+
pnpm lint
|
|
32
|
+
pnpm typecheck
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
未完成的页面设置 `draft: true`。打开构建后的 Markdown 链接,确认示例、链接和组件文字均可阅读。
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Astro checks component props through its generated TSX representation.
|
|
2
|
+
// Plain tsc needs the runtime module shape for imports in src/components.ts.
|
|
3
|
+
declare module '*.astro' {
|
|
4
|
+
const component: import('astro/runtime/server/index.js').AstroComponentFactory
|
|
5
|
+
export default component
|
|
6
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { DocsPageProps } from '@cloudflare/nimbus-docs/types'
|
|
3
|
+
import { withBase } from '@cloudflare/nimbus-docs/runtime'
|
|
4
|
+
import { config } from 'virtual:nimbus/config'
|
|
5
|
+
import Head from '../components/head.astro'
|
|
6
|
+
import Search from '../components/search/index.astro'
|
|
7
|
+
import Sidebar from '../components/sidebar.astro'
|
|
8
|
+
import { labels } from '../lib/locale'
|
|
9
|
+
import '../styles/site.css'
|
|
10
|
+
|
|
11
|
+
type Props = Omit<DocsPageProps, 'breadcrumbs' | 'prevNext'> & { chinese: boolean, alternate: string }
|
|
12
|
+
const { title, description, sidebar, headings, markdownUrl, chinese, alternate, noindex, draft, searchable } = Astro.props
|
|
13
|
+
const text = labels[chinese ? 'zh' : 'en']
|
|
14
|
+
const base = import.meta.env.BASE_URL
|
|
15
|
+
const indexUrl = withBase(chinese ? '/zh/llms.txt' : '/llms.txt', base)
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<!doctype html>
|
|
19
|
+
<html lang={chinese ? 'zh-CN' : 'en'}>
|
|
20
|
+
<head>
|
|
21
|
+
<meta charset="utf-8" />
|
|
22
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
23
|
+
<Head title={title} description={description} markdownUrl={markdownUrl} noindex={noindex || draft} chinese={chinese} />
|
|
24
|
+
<link rel="alternate" hreflang={chinese ? 'en' : 'zh-CN'} href={new URL(withBase(alternate, base), Astro.site)} />
|
|
25
|
+
<link rel="alternate" type="text/plain" href={indexUrl} title={text.index} />
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<a class="skip-link" href="#main-content">{text.skip}</a>
|
|
29
|
+
<header class="site-header">
|
|
30
|
+
<a class="brand" href={withBase(chinese ? '/zh/' : '/', base)}>{config.title}</a>
|
|
31
|
+
<a class="language-link" href={withBase(alternate, base)} lang={chinese ? 'en' : 'zh-CN'}>{chinese ? 'English' : '简体中文'}</a>
|
|
32
|
+
</header>
|
|
33
|
+
<div class="docs-grid">
|
|
34
|
+
<aside class="site-rail">
|
|
35
|
+
<Search chinese={chinese} />
|
|
36
|
+
<nav aria-label={text.navigation}>
|
|
37
|
+
<p class="rail-title">{text.navigation}</p>
|
|
38
|
+
{sidebar !== false && <Sidebar items={sidebar} />}
|
|
39
|
+
</nav>
|
|
40
|
+
<a class="index-link" href={indexUrl}>llms.txt ↗</a>
|
|
41
|
+
</aside>
|
|
42
|
+
<main id="main-content" tabindex="-1">
|
|
43
|
+
<div data-pagefind-body={searchable !== false && !noindex && !draft ? '' : undefined} data-pagefind-ignore={searchable === false || noindex || draft ? '' : undefined}>
|
|
44
|
+
<h1>{title}</h1>
|
|
45
|
+
{description && <p class="description">{description}</p>}
|
|
46
|
+
<article><slot /></article>
|
|
47
|
+
</div>
|
|
48
|
+
{markdownUrl && (
|
|
49
|
+
<footer>
|
|
50
|
+
<a href={withBase(markdownUrl, base)}>
|
|
51
|
+
{text.markdown}
|
|
52
|
+
{' '}
|
|
53
|
+
↗
|
|
54
|
+
</a>
|
|
55
|
+
</footer>
|
|
56
|
+
)}
|
|
57
|
+
</main>
|
|
58
|
+
<aside class="page-rail">
|
|
59
|
+
{headings !== false && headings.length > 0 && (
|
|
60
|
+
<nav aria-label={text.contents}>
|
|
61
|
+
<p class="rail-title">{text.contents}</p>
|
|
62
|
+
<ul class="navigation-list">
|
|
63
|
+
{headings.map(heading => <li><a href={`#${heading.slug}`}>{heading.text}</a></li>)}
|
|
64
|
+
</ul>
|
|
65
|
+
</nav>
|
|
66
|
+
)}
|
|
67
|
+
</aside>
|
|
68
|
+
</div>
|
|
69
|
+
</body>
|
|
70
|
+
</html>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SidebarItem } from '@cloudflare/nimbus-docs/types'
|
|
2
|
+
|
|
3
|
+
export function isChinese(path: string) {
|
|
4
|
+
return path === '/zh' || path.startsWith('/zh/')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function alternatePath(path: string) {
|
|
8
|
+
return isChinese(path) ? path.slice(3) || '/' : `/zh${path}`
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function localizeSidebar(items: SidebarItem[], chinese: boolean): SidebarItem[] {
|
|
12
|
+
return items.flatMap((item): SidebarItem[] => {
|
|
13
|
+
if (item.type !== 'group') {
|
|
14
|
+
return item.type === 'external' || isChinese(item.href) === chinese ? [item] : []
|
|
15
|
+
}
|
|
16
|
+
const children = localizeSidebar(item.children, chinese)
|
|
17
|
+
const indexHref = item.indexHref && isChinese(item.indexHref) === chinese ? item.indexHref : undefined
|
|
18
|
+
if (!children.length && !indexHref) {
|
|
19
|
+
return []
|
|
20
|
+
}
|
|
21
|
+
return [{ ...item, indexHref, children }]
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const labels = {
|
|
26
|
+
en: {
|
|
27
|
+
navigation: 'On this site',
|
|
28
|
+
contents: 'On this page',
|
|
29
|
+
skip: 'Skip to content',
|
|
30
|
+
search: 'Search documentation',
|
|
31
|
+
submit: 'Search',
|
|
32
|
+
empty: 'No matching pages.',
|
|
33
|
+
loading: 'Searching…',
|
|
34
|
+
unavailable: 'Search is unavailable. Try again after building the site.',
|
|
35
|
+
markdown: 'Read Markdown',
|
|
36
|
+
index: 'Documentation index',
|
|
37
|
+
},
|
|
38
|
+
zh: {
|
|
39
|
+
navigation: '站点导航',
|
|
40
|
+
contents: '本页目录',
|
|
41
|
+
skip: '跳转到正文',
|
|
42
|
+
search: '搜索文档',
|
|
43
|
+
submit: '搜索',
|
|
44
|
+
empty: '没有找到匹配的页面。',
|
|
45
|
+
loading: '正在搜索…',
|
|
46
|
+
unavailable: '搜索暂不可用,请构建站点后重试。',
|
|
47
|
+
markdown: '阅读 Markdown',
|
|
48
|
+
index: '文档索引',
|
|
49
|
+
},
|
|
50
|
+
} as const
|