Просмотр исходного кода

feat(docs): publish the component Storybook on the docs site

The docs site and the component workbench were entirely disconnected. The Pages deploy now builds the frontend Storybook and bundles it into the artifact under /storybook, so the live component reference ships with the documentation, and the navbar links to it. Story changes trigger a redeploy so the published workbench cannot go stale.
MHSanaei 11 часов назад
Родитель
Сommit
df3ba568d1
2 измененных файлов с 18 добавлено и 2 удалено
  1. 11 1
      .github/workflows/docs-deploy.yml
  2. 7 1
      docs/lib/layout.shared.tsx

+ 11 - 1
.github/workflows/docs-deploy.yml

@@ -9,6 +9,9 @@ on:
     branches: [main]
     branches: [main]
     paths:
     paths:
       - 'docs/**'
       - 'docs/**'
+      - 'frontend/src/components/**'
+      - 'frontend/.storybook/**'
+      - 'frontend/package-lock.json'
       - '.github/workflows/docs-deploy.yml'
       - '.github/workflows/docs-deploy.yml'
   workflow_dispatch:
   workflow_dispatch:
 
 
@@ -35,7 +38,7 @@ jobs:
           version: 11
           version: 11
       - uses: actions/setup-node@v6
       - uses: actions/setup-node@v6
         with:
         with:
-          node-version: 22
+          node-version-file: .nvmrc
           cache: pnpm
           cache: pnpm
           cache-dependency-path: docs/pnpm-lock.yaml
           cache-dependency-path: docs/pnpm-lock.yaml
       - run: pnpm install --frozen-lockfile
       - run: pnpm install --frozen-lockfile
@@ -52,6 +55,13 @@ jobs:
         # in place. That way both /docs/... and /en/docs/... resolve. Other
         # in place. That way both /docs/... and /en/docs/... resolve. Other
         # locales stay under /fa, /ru, /zh.
         # locales stay under /fa, /ru, /zh.
         run: cp -a out/en/. out/
         run: cp -a out/en/. out/
+      - name: Build the component Storybook (frontend/)
+        working-directory: frontend
+        run: |
+          npm ci
+          npm run build-storybook
+      - name: Bundle Storybook at /storybook
+        run: cp -a ../frontend/storybook-static out/storybook
       - uses: actions/upload-pages-artifact@v5
       - uses: actions/upload-pages-artifact@v5
         with:
         with:
           path: docs/out
           path: docs/out

+ 7 - 1
docs/lib/layout.shared.tsx

@@ -2,7 +2,7 @@ import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
 import { Heart } from 'lucide-react';
 import { Heart } from 'lucide-react';
 import { Logo } from '@/components/logo';
 import { Logo } from '@/components/logo';
 import { TelegramIcon } from '@/components/icons';
 import { TelegramIcon } from '@/components/icons';
-import { appName, productRepoUrl, telegramChannel, telegramChannelUrl, donateUrl } from './shared';
+import { appName, productRepoUrl, telegramChannel, telegramChannelUrl, donateUrl, siteUrl } from './shared';
 import { getSiteMessages } from './site-i18n';
 import { getSiteMessages } from './site-i18n';
 
 
 // Build locale-aware shared layout options. With `hideLocale: 'default-locale'`,
 // Build locale-aware shared layout options. With `hideLocale: 'default-locale'`,
@@ -28,6 +28,12 @@ export function baseOptions(lang: string): BaseLayoutProps {
         url: `${prefix}/docs`,
         url: `${prefix}/docs`,
         active: 'nested-url',
         active: 'nested-url',
       },
       },
+      // Live component workbench built from frontend/ and published alongside the docs.
+      {
+        text: 'Storybook',
+        url: `${siteUrl}/storybook/`,
+        external: true,
+      },
       {
       {
         type: 'icon',
         type: 'icon',
         label: `Telegram channel (@${telegramChannel})`,
         label: `Telegram channel (@${telegramChannel})`,