From b43df8e18baa7a452dcbd2df2673966888d89b1b Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 6 Apr 2026 19:47:52 +0800 Subject: [PATCH 01/98] Migrate ThinkWatch docs into the marketing site Pull all 11 docs from /Users/faz/Dev/ThinkWatch/docs (5 EN + 5 zh-CN + secret-rotation EN-only) into a Docs section served at /docs and /zh-CN/docs. - New Astro content collection 'docs' loaded via glob from src/content/docs/{en,zh-CN}; sidebar order, labels, summaries, and per-doc locale availability declared in src/content/docs/_meta.ts - Strip the upstream language-switcher line at the top of every doc (we have a global switcher) before importing - Configure markdown pipeline: shiki theme github-dark-default, rehype-slug for heading IDs, rehype-autolink-headings to expose '#' anchors on hover - New DocsLayout with sticky sidebar navigation, current-page highlight, "Edit on GitHub" link, and a custom .prose-tw stylesheet for headings, code blocks, tables, blockquotes, inline code, and heading anchors (no @tailwindcss/typography dependency) - Dynamic [...slug] routes for both locales with case-insensitive filtering on the locale segment (Astro 5 normalizes glob ids) - Docs index landing pages in both locales with cards summarising each doc - Header gets a Docs nav link; the language switcher gracefully falls back to the docs index when the target locale is missing the current doc (e.g. secret-rotation only has English) - Footer Product column gains the Docs link dist now builds 18 pages (was 5). --- astro.config.mjs | 25 + package.json | 2 + pnpm-lock.yaml | 43 + src/components/SiteFooter.astro | 2 +- src/components/SiteHeader.astro | 18 +- src/content.config.ts | 9 +- src/content/docs/_meta.ts | 79 + src/content/docs/en/api-reference.md | 2346 ++++++++++++++++++++ src/content/docs/en/architecture.md | 467 ++++ src/content/docs/en/configuration.md | 539 +++++ src/content/docs/en/deployment-guide.md | 730 ++++++ src/content/docs/en/secret-rotation.md | 161 ++ src/content/docs/en/security.md | 421 ++++ src/content/docs/zh-CN/api-reference.md | 2338 +++++++++++++++++++ src/content/docs/zh-CN/architecture.md | 463 ++++ src/content/docs/zh-CN/configuration.md | 539 +++++ src/content/docs/zh-CN/deployment-guide.md | 730 ++++++ src/content/docs/zh-CN/security.md | 421 ++++ src/i18n/index.ts | 2 + src/layouts/DocsLayout.astro | 91 + src/pages/docs/[...slug].astro | 28 + src/pages/docs/index.astro | 37 + src/pages/zh-CN/docs/[...slug].astro | 29 + src/pages/zh-CN/docs/index.astro | 36 + src/styles/global.css | 145 ++ 25 files changed, 9697 insertions(+), 4 deletions(-) create mode 100644 src/content/docs/_meta.ts create mode 100644 src/content/docs/en/api-reference.md create mode 100644 src/content/docs/en/architecture.md create mode 100644 src/content/docs/en/configuration.md create mode 100644 src/content/docs/en/deployment-guide.md create mode 100644 src/content/docs/en/secret-rotation.md create mode 100644 src/content/docs/en/security.md create mode 100644 src/content/docs/zh-CN/api-reference.md create mode 100644 src/content/docs/zh-CN/architecture.md create mode 100644 src/content/docs/zh-CN/configuration.md create mode 100644 src/content/docs/zh-CN/deployment-guide.md create mode 100644 src/content/docs/zh-CN/security.md create mode 100644 src/layouts/DocsLayout.astro create mode 100644 src/pages/docs/[...slug].astro create mode 100644 src/pages/docs/index.astro create mode 100644 src/pages/zh-CN/docs/[...slug].astro create mode 100644 src/pages/zh-CN/docs/index.astro diff --git a/astro.config.mjs b/astro.config.mjs index fdfd6d1..61fb57c 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -3,6 +3,8 @@ import { defineConfig } from 'astro/config'; import react from '@astrojs/react'; import sitemap from '@astrojs/sitemap'; import tailwindcss from '@tailwindcss/vite'; +import rehypeSlug from 'rehype-slug'; +import rehypeAutolinkHeadings from 'rehype-autolink-headings'; // https://astro.build/config export default defineConfig({ @@ -15,6 +17,29 @@ export default defineConfig({ }, }, integrations: [react(), sitemap({ i18n: { defaultLocale: 'en', locales: { en: 'en', 'zh-CN': 'zh-CN' } } })], + markdown: { + shikiConfig: { + theme: 'github-dark-default', + wrap: false, + }, + rehypePlugins: [ + rehypeSlug, + [ + rehypeAutolinkHeadings, + { + behavior: 'append', + properties: { + className: ['heading-anchor'], + ariaLabel: 'Link to this section', + }, + content: { + type: 'text', + value: '#', + }, + }, + ], + ], + }, vite: { plugins: [tailwindcss()], }, diff --git a/package.json b/package.json index 968fac9..d6d1a9a 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,8 @@ "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", "@types/three": "^0.183.1", + "rehype-autolink-headings": "^7.1.0", + "rehype-slug": "^6.0.0", "sharp": "^0.34.5", "shiki": "^4.0.2", "typescript": "^5.7.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7f2e00..a1db4dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -51,6 +51,12 @@ importers: '@types/three': specifier: ^0.183.1 version: 0.183.1 + rehype-autolink-headings: + specifier: ^7.1.0 + version: 7.1.0 + rehype-slug: + specifier: ^6.0.0 + version: 6.0.0 sharp: specifier: ^0.34.5 version: 0.34.5 @@ -1469,6 +1475,9 @@ packages: hast-util-from-parse5@8.0.3: resolution: {integrity: sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==} + hast-util-heading-rank@3.0.0: + resolution: {integrity: sha512-EJKb8oMUXVHcWZTDepnr+WNbfnXKFNf9duMesmr4S8SXTJBJ9M4Yok08pu9vxdJwdlGRhVumk9mEhkEvKGifwA==} + hast-util-is-element@3.0.0: resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==} @@ -1484,6 +1493,9 @@ packages: hast-util-to-parse5@8.0.1: resolution: {integrity: sha512-MlWT6Pjt4CG9lFCjiz4BH7l9wmrMkfkJYCxFwKQic8+RTZgWPuWxwAfjJElsXkex7DJjfSJsQIt931ilUgmwdA==} + hast-util-to-string@3.0.1: + resolution: {integrity: sha512-XelQVTDWvqcl3axRfI0xSeoVKzyIFPwsAGSLIsKdJKQMXDYJS4WYrBNF/8J7RdhIcFI2BOHgAifggsvsxp/3+A==} + hast-util-to-text@4.0.2: resolution: {integrity: sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==} @@ -1963,12 +1975,18 @@ packages: regex@6.1.0: resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==} + rehype-autolink-headings@7.1.0: + resolution: {integrity: sha512-rItO/pSdvnvsP4QRB1pmPiNHUskikqtPojZKJPPPAVx9Hj8i8TwMBhofrrAYRhYOOBZH9tgmG5lPqDLuIWPWmw==} + rehype-parse@9.0.1: resolution: {integrity: sha512-ksCzCD0Fgfh7trPDxr2rSylbwq9iYDkSn8TCDmEJ49ljEUBxDVCzCHv7QNzZOfODanX4+bWQ4WZqLCRWYLfhag==} rehype-raw@7.0.0: resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==} + rehype-slug@6.0.0: + resolution: {integrity: sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==} + rehype-stringify@10.0.1: resolution: {integrity: sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==} @@ -3803,6 +3821,10 @@ snapshots: vfile-location: 5.0.3 web-namespaces: 2.0.1 + hast-util-heading-rank@3.0.0: + dependencies: + '@types/hast': 3.0.4 + hast-util-is-element@3.0.0: dependencies: '@types/hast': 3.0.4 @@ -3851,6 +3873,10 @@ snapshots: web-namespaces: 2.0.1 zwitch: 2.0.4 + hast-util-to-string@3.0.1: + dependencies: + '@types/hast': 3.0.4 + hast-util-to-text@4.0.2: dependencies: '@types/hast': 3.0.4 @@ -4453,6 +4479,15 @@ snapshots: dependencies: regex-utilities: 2.3.0 + rehype-autolink-headings@7.1.0: + dependencies: + '@types/hast': 3.0.4 + '@ungap/structured-clone': 1.3.0 + hast-util-heading-rank: 3.0.0 + hast-util-is-element: 3.0.0 + unified: 11.0.5 + unist-util-visit: 5.1.0 + rehype-parse@9.0.1: dependencies: '@types/hast': 3.0.4 @@ -4465,6 +4500,14 @@ snapshots: hast-util-raw: 9.1.0 vfile: 6.0.3 + rehype-slug@6.0.0: + dependencies: + '@types/hast': 3.0.4 + github-slugger: 2.0.0 + hast-util-heading-rank: 3.0.0 + hast-util-to-string: 3.0.1 + unist-util-visit: 5.1.0 + rehype-stringify@10.0.1: dependencies: '@types/hast': 3.0.4 diff --git a/src/components/SiteFooter.astro b/src/components/SiteFooter.astro index 1f0d88b..d6e0e2e 100644 --- a/src/components/SiteFooter.astro +++ b/src/components/SiteFooter.astro @@ -24,6 +24,7 @@ const year = new Date().getFullYear();