diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml new file mode 100644 index 0000000..1843939 --- /dev/null +++ b/.github/workflows/deploy_preview.yml @@ -0,0 +1,42 @@ +name: Deploy Documentation Preview + +on: + workflow_dispatch: + inputs: + comment: + description: 'Deployment Documentation' + required: false + default: 'Manual preview deployment' + +jobs: + build-and-deploy: + if: github.ref_name == 'main' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Install dependencies + run: | + npm install + + - name: Build frontend + run: npm run build + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy out --project-name=deploystack-docs --branch=main + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml new file mode 100644 index 0000000..7ec7f5c --- /dev/null +++ b/.github/workflows/deploy_prod.yml @@ -0,0 +1,42 @@ +name: Deploy Documentation Production + +on: + workflow_dispatch: + inputs: + comment: + description: 'Deployment Documentation' + required: false + default: 'Manual Production deployment' + +jobs: + build-and-deploy: + if: github.ref_name == 'prod' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Install dependencies + run: | + npm install + + - name: Build frontend + run: npm run build + + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy out --project-name=deploystack-docs --branch=prod + gitHubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 707896b..c870832 100644 --- a/.gitignore +++ b/.gitignore @@ -71,4 +71,5 @@ coverage/ .jest/ ._*.mdx -._*.ts \ No newline at end of file +._*.ts +out/ diff --git a/app/api/search/route.ts b/app/api/search/route.ts deleted file mode 100644 index 0a57c2b..0000000 --- a/app/api/search/route.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { source } from '../../../lib/source'; -import { createFromSource } from 'fumadocs-core/search/server'; - -export const { GET } = createFromSource(source); diff --git a/app/docs/sitemap.xml/route.ts b/app/docs/sitemap.xml/route.ts index b05ed9c..25f1e6e 100644 --- a/app/docs/sitemap.xml/route.ts +++ b/app/docs/sitemap.xml/route.ts @@ -1,6 +1,9 @@ import { source } from '@/lib/source'; import { getCanonicalUrl } from '@/lib/seo-utils'; +export const dynamic = 'force-static'; +export const revalidate = false; + export async function GET() { const pages = source.getPages(); diff --git a/next.config.mjs b/next.config.mjs index c4e6ede..336687c 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -5,12 +5,15 @@ const withMDX = createMDX(); /** @type {import('next').NextConfig} */ const config = { reactStrictMode: true, + output: 'export', // Enable static HTML export + trailingSlash: true, // Required for static export + basePath: '/docs', // Set base path for the application + assetPrefix: '/docs', // Ensure assets are also prefixed with /docs + images: { + unoptimized: true // Required for static export + }, // Sitemap is now handled by app/docs/sitemap.xml/route.ts // If you have other Next.js configurations, add them here - // For example, if you need to serve static files from the 'public' directory - // and your images are in 'docs/assets/images', you might need to configure images domain - // or ensure they are moved to 'public/docs/assets/images' and referenced accordingly. - // For now, we'll stick to the basic config. }; export default withMDX(config); diff --git a/package.json b/package.json index 62fb72c..354b893 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "private": true, "scripts": { "dev": "next dev", - "build": "next build", + "build": "next build && npm run move-assets", + "move-assets": "mkdir -p out/docs/_next && cp -r out/_next/* out/docs/_next/ && rm -rf out/_next", "start": "next start", "lint:md": "npx markdownlint-cli2 '**/*.md' '#node_modules' '#.github'", "lint:links": "node check-links.js",