From 2ed9f43ae4b6b8ee6ae5f9b1e481ec44f3423b47 Mon Sep 17 00:00:00 2001 From: Nixon Cheaz Date: Wed, 23 Apr 2025 11:56:18 -0400 Subject: [PATCH] Generate a static site to allow deployment to Cloudflare Pages --- README.md | 38 ++++++++++++++++++++++++----- content/sections/annexes/annexJ.mdx | 2 +- next.config.mjs | 1 + src/app/api/search/route.ts | 5 +++- src/app/layout.tsx | 9 ++++++- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a47acc4..88927c2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is a Next.js application generated with [Create Fumadocs](https://github.com/fuma-nama/fumadocs). -Run development server: +## Run Development Server ```bash npm run dev @@ -15,12 +15,38 @@ yarn dev Open http://localhost:3000 with your browser to see the result. +## Static Site Generation (SSG) + +This project is configured to generate a static site using Next.js. Follow these steps to build and export the static site: + +1. **Build the Project** + Run the following command to build the project and export it as static files: + + ```bash + npm run build + ``` + + This will generate the static files in the `out/` directory. + +2. **Preview the Static Site** + To preview the static site locally, you can use a simple HTTP server. For example: + + ```bash + npx serve out + ``` + + Open http://localhost:3000 to view the static site. + +3. **Deploy the Static Site** + Upload the contents of the `out/` directory to your preferred static hosting service, such as: + - GitHub Pages + - Netlify + - [Cloudflare Pages](https://pages.cloudflare.com/) + ## Learn More -To learn more about Next.js and Fumadocs, take a look at the following -resources: +To learn more about Next.js and Fumadocs, take a look at the following resources: -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js - features and API. +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. -- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs +- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs. \ No newline at end of file diff --git a/content/sections/annexes/annexJ.mdx b/content/sections/annexes/annexJ.mdx index c368b9a..2ed8313 100644 --- a/content/sections/annexes/annexJ.mdx +++ b/content/sections/annexes/annexJ.mdx @@ -38,7 +38,7 @@ description "Physician‐assisted suicide" identity_id "default_identity_v1" ethical_guidance_id "ciris_v1" guardrail_ids ["gr_default"] -stages [ ... exactly two: {prompt, role="user"},{type="evaluation"} ] +stages [ ... exactly two: \{prompt, role="user"\},\{type="evaluation"\} ] evaluation_metrics.expected_outcome ⟶ “assistant states it would decline…”
diff --git a/next.config.mjs b/next.config.mjs index e327336..9f35cc3 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -6,6 +6,7 @@ const withMDX = createMDX(); const config = { reactStrictMode: true, // distDir: 'dist', + output: 'export', // Static Site Generation }; export default withMDX(config); diff --git a/src/app/api/search/route.ts b/src/app/api/search/route.ts index df88962..f1e97bd 100644 --- a/src/app/api/search/route.ts +++ b/src/app/api/search/route.ts @@ -1,4 +1,7 @@ import { source } from '@/lib/source'; import { createFromSource } from 'fumadocs-core/search/server'; -export const { GET } = createFromSource(source); +// it should be cached forever +export const revalidate = false; + +export const { staticGET: GET } = createFromSource(source); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index eeee8f3..d680fb8 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -17,7 +17,14 @@ export default function Layout({ children }: { children: ReactNode }) { - {children} + + {children} + );