File tree Expand file tree Collapse file tree 10 files changed +64
-36
lines changed
Expand file tree Collapse file tree 10 files changed +64
-36
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: Deploy to GitHub Pages
22
33on :
44 push :
5- branches : [ docs/plan-b ]
5+ branches : [ main, docs/plan-b ]
66 workflow_dispatch :
77
88permissions :
2424 - name : Setup Node.js
2525 uses : actions/setup-node@v4
2626 with :
27- node-version : ' 18 '
27+ node-version : ' 20 '
2828 cache : ' npm'
2929
3030 - name : Setup Pages
3535 - name : Install dependencies
3636 run : npm ci
3737
38+ - name : Generate Fumadocs MDX files
39+ run : npm run postinstall
40+
3841 - name : Build with Next.js
3942 run : npm run build
43+ env :
44+ NODE_ENV : production
4045
4146 - name : Upload artifact
4247 uses : actions/upload-pages-artifact@v3
Original file line number Diff line number Diff line change 11import { redirect } from 'next/navigation' ;
2+ import { i18n } from '@/lib/i18n' ;
3+
4+ // 生成静态参数,用于静态导出
5+ export function generateStaticParams ( ) {
6+ return i18n . languages . map ( ( lang ) => ( {
7+ lang,
8+ } ) ) ;
9+ }
210
311export default async function HomePage ( {
412 params,
Original file line number Diff line number Diff line change 11import { source } from '@/lib/source' ;
22import { DocsLayout } from 'fumadocs-ui/layouts/docs' ;
33import { baseOptions } from '@/app/layout.config' ;
4+ import { i18n } from '@/lib/i18n' ;
45import type { ReactNode } from 'react' ;
56
7+ // 生成静态参数,用于静态导出
8+ export function generateStaticParams ( ) {
9+ return i18n . languages . map ( ( lang ) => ( {
10+ lang,
11+ } ) ) ;
12+ }
13+
614export default async function Layout ( {
715 children,
816 params
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { use } from 'react';
66import type { ReactNode } from 'react' ;
77import type { Translations } from 'fumadocs-ui/i18n' ;
88import type { Metadata } from 'next' ;
9+ import { i18n } from '@/lib/i18n' ;
910
1011const inter = Inter ( {
1112 subsets : [ 'latin' ] ,
@@ -16,6 +17,12 @@ const zh: Partial<Translations> = {
1617 search : '搜索'
1718} ;
1819
20+ // 生成静态参数,用于静态导出
21+ export function generateStaticParams ( ) {
22+ return i18n . languages . map ( ( lang ) => ( {
23+ lang,
24+ } ) ) ;
25+ }
1926
2027// 可用语言配置
2128const locales = [
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import type { MetadataRoute } from 'next' ;
22import { i18n } from '@/lib/i18n' ;
33
4- // 获取基本URL,根据环境变量设置或默认为本地开发URL
5- const BASE_URL = process . env . NEXT_PUBLIC_BASE_URL || 'https://hellodify.com' ;
4+ // 强制静态生成,用于静态导出
5+ export const dynamic = 'force-static' ;
6+
7+ // 获取基本URL,根据环境变量设置或默认为 GitHub Pages URL
8+ const BASE_URL = process . env . NEXT_PUBLIC_BASE_URL || 'https://tencentcloudadp-devrel.github.io/hello-adp-docs' ;
69
710// 确保 BASE_URL 包含协议前缀
811function formatBaseUrl ( url : string ) : string {
Original file line number Diff line number Diff line change 33import { useEffect , useState } from 'react' ;
44import Link from 'next/link' ;
55import Image from 'next/image' ;
6- import type { ArticleCardView , CategoryLink } from '@/app/[lang]/(home)/page' ;
6+
7+ // 定义本地类型
8+ export interface ArticleCardView {
9+ id : string ;
10+ title : string ;
11+ description ?: string ;
12+ href : string ;
13+ categoryLabel : string ;
14+ author ?: string ;
15+ avatar ?: string ;
16+ updatedLabel : string ;
17+ demoUrl ?: string ;
18+ }
19+
20+ export interface CategoryLink {
21+ key ?: string ;
22+ label : string ;
23+ href : string ;
24+ }
725
826interface LandingCopy {
927 heroTitle : string ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -6,7 +6,15 @@ const withMDX = createMDX();
66const config = {
77 reactStrictMode : true ,
88 turbopack : false ,
9+
10+ // GitHub Pages 静态导出配置
11+ output : 'export' ,
12+ trailingSlash : true ,
13+ basePath : '/hello-adp-docs' ,
14+ assetPrefix : '/hello-adp-docs/' ,
15+
916 images : {
17+ unoptimized : true , // 静态导出必需
1018 remotePatterns : [
1119 {
1220 protocol : 'https' ,
@@ -30,7 +38,7 @@ config.headers = async () => [
3038 headers : [
3139 {
3240 key : 'Content-Security-Policy' ,
33- value : "frame-ancestors 'self' *.hellodify.com; frame-src 'self' *.hellodify .com http:// *.hellodify.com https://*.hellodify.com https:// giscus.app https://www.youtube.com https://*.youtube.com https://*.vercel.app https://vercel.com ; child-src 'self' *.hellodify .com http:// *.hellodify.com https://*.hellodify.com https:// giscus.app https://www.youtube.com https://*.youtube.com https://*.vercel.app https://vercel.com ; img-src 'self' data: *.hellodify .com http:// *.hellodify.com https://*.hellodify.com s2.loli.net https:// avatars.githubusercontent.com https://twimg.com https://pbs.twimg.com https://*.github.io https://*.youtube.com https://*.ytimg.com https://*.vercel.app https://vercel.com ; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://giscus.app https://www.googletagmanager.com https://www.google-analytics.com; connect-src 'self' https://api.github.com https://www.google-analytics.com https://www.googletagmanager.com https://analytics.google.com;"
41+ value : "frame-ancestors 'self' *.tencentcloud.com *. hellodify.com; frame-src 'self' *.tencentcloud .com *.hellodify.com https://giscus.app https://www.youtube.com/embed/ https://*.youtube.com https://*.vercel.app; child-src 'self' *.tencentcloud .com *.hellodify.com https://giscus.app https://www.youtube.com/embed/ https://*.youtube.com https://*.vercel.app; img-src 'self' data: *.tencentcloud .com *.hellodify.com https://avatars.githubusercontent.com https://twimg.com https://pbs.twimg.com https://*.github.io https://*.youtube.com https://*.ytimg.com https://*.vercel.app; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://giscus.app https://www.googletagmanager.com https://www.google-analytics.com; connect-src 'self' https://api.github.com https://www.google-analytics.com https://www.googletagmanager.com https://analytics.google.com;"
3442 }
3543 ]
3644 }
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { z } from 'zod';
99// You can customise Zod schemas for frontmatter and `meta.json` here
1010// see https://fumadocs.vercel.app/docs/mdx/collections#define-docs
1111export const docs = defineDocs ( {
12- dir : 'docs' ,
12+ dir : 'content/ docs' ,
1313 docs : {
1414 schema : frontmatterSchema . extend ( {
1515 author : z . string ( ) . optional ( ) ,
You can’t perform that action at this time.
0 commit comments