From e4030ed254cad58cf4213b0c2ef4399ae20ab98e Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sat, 11 Apr 2026 14:32:21 -0400 Subject: [PATCH] docs: deploy stable and beta docs --- .github/workflows/docs.yaml | 81 ++++++++++++++++++++++++++++++++ .npmrc | 1 + docs/.vitepress/config.ts | 5 ++ docs/.vitepress/theme/custom.css | 37 ++++++++++++--- docs/.vitepress/theme/env.d.ts | 3 ++ docs/.vitepress/theme/index.ts | 38 +++++++++++++-- docs/tsconfig.json | 12 +++++ tsconfig.json | 1 + wrangler.toml | 6 --- 9 files changed, 169 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/docs.yaml create mode 100644 docs/.vitepress/theme/env.d.ts create mode 100644 docs/tsconfig.json delete mode 100644 wrangler.toml diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..254f62d --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,81 @@ +name: Docs +on: + push: + tags: + - "v*" + branches: + - "release/docs" + +concurrency: + group: docs-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + beta: + name: Deploy Beta Docs + if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref_name, '-') + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v6 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + run_install: false + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version-file: package.json + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build docs + run: pnpm docs:build + env: + HEADPLANE_BETA_DOCS: "true" + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + command: pages deploy docs/.vitepress/dist --project-name=headplane-docs-beta + + stable: + name: Deploy Stable Docs + if: > + (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-')) + || github.ref == 'refs/heads/release/docs' + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v6 + + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + run_install: false + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version-file: package.json + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build docs + run: pnpm docs:build + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + command: pages deploy docs/.vitepress/dist --project-name=headplane-docs diff --git a/.npmrc b/.npmrc index 0ef8e44..b959029 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ side-effects-cache = false +public-hoist-pattern[]=vue diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 90a5a77..fb36915 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,6 +1,11 @@ import { defineConfig } from "vitepress"; export default defineConfig({ + vite: { + define: { + __HEADPLANE_BETA_DOCS__: JSON.stringify(process.env.HEADPLANE_BETA_DOCS === "true"), + }, + }, title: "Headplane", description: "The missing dashboard for Headscale", cleanUrls: true, diff --git a/docs/.vitepress/theme/custom.css b/docs/.vitepress/theme/custom.css index 3eb0162..2d14b22 100644 --- a/docs/.vitepress/theme/custom.css +++ b/docs/.vitepress/theme/custom.css @@ -1,17 +1,42 @@ html.dark .light-only { - display: none !important; + display: none !important; } html:not(.dark) .dark-only { - display: none !important; + display: none !important; } figure { - padding: 1em; + padding: 1em; } figcaption { - text-align: center; - font-size: 0.9em; - margin-top: 0.5em; + text-align: center; + font-size: 0.9em; + margin-top: 0.5em; +} + +:root { + --vp-layout-top-height: 36px; +} + +.beta-banner { + background-color: var(--vp-c-bg); + background-image: linear-gradient(var(--vp-c-warning-soft), var(--vp-c-warning-soft)); + color: var(--vp-c-warning-1); + text-align: center; + padding: 8px 16px; + font-size: 14px; + font-weight: 500; + position: fixed; + top: 0; + left: 0; + right: 0; + z-index: 100; +} + +.beta-banner a { + color: var(--vp-c-warning-1); + text-decoration: underline; + margin-left: 8px; } diff --git a/docs/.vitepress/theme/env.d.ts b/docs/.vitepress/theme/env.d.ts new file mode 100644 index 0000000..6e601d6 --- /dev/null +++ b/docs/.vitepress/theme/env.d.ts @@ -0,0 +1,3 @@ +/// + +declare const __HEADPLANE_BETA_DOCS__: boolean; diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 149273e..ce32f19 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,4 +1,36 @@ -import DefaultTheme from 'vitepress/theme'; -import './custom.css'; +import type { Theme } from "vitepress"; +import DefaultTheme from "vitepress/theme"; +import { h } from "vue"; -export default DefaultTheme; +import "./custom.css"; + +const beta = __HEADPLANE_BETA_DOCS__ ?? false; + +export default { + extends: DefaultTheme, + Layout() { + return h(DefaultTheme.Layout, null, { + "layout-top": () => + beta + ? h( + "div", + { + class: "beta-banner", + }, + [ + "You are currently viewing the ", + h("strong", "beta"), + " documentation for Headplane. ", + h( + "a", + { + href: "https://headplane.net", + }, + "Go to the stable docs →", + ), + ], + ) + : null, + }); + }, +} satisfies Theme; diff --git a/docs/tsconfig.json b/docs/tsconfig.json new file mode 100644 index 0000000..65cd1eb --- /dev/null +++ b/docs/tsconfig.json @@ -0,0 +1,12 @@ +{ + "include": [".vitepress/**/*"], + "compilerOptions": { + "module": "ESNext", + "moduleResolution": "bundler", + "target": "ES2022", + "lib": ["DOM", "DOM.Iterable", "ES2023"], + "noEmit": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/tsconfig.json b/tsconfig.json index 5b85c73..535de19 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "include": ["**/*", "**/.server/**/*", "**/.client/**/*", ".react-router/types/**/*"], + "exclude": ["docs"], "compilerOptions": { "lib": ["DOM", "DOM.Iterable", "ES2023"], "types": ["node", "vite/client"], diff --git a/wrangler.toml b/wrangler.toml deleted file mode 100644 index 2931343..0000000 --- a/wrangler.toml +++ /dev/null @@ -1,6 +0,0 @@ -name = "headplane" -compatibility_date = "2025-08-18" - -[assets] -directory = "docs/.vitepress/dist" -not_found_handling = "404-page"