Skip to content

Commit 6b65155

Browse files
docs update
1 parent bd94dd1 commit 6b65155

File tree

10 files changed

+64
-36
lines changed

10 files changed

+64
-36
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy to GitHub Pages
22

33
on:
44
push:
5-
branches: [ docs/plan-b ]
5+
branches: [ main, docs/plan-b ]
66
workflow_dispatch:
77

88
permissions:
@@ -24,7 +24,7 @@ jobs:
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
@@ -35,8 +35,13 @@ jobs:
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

app/[lang]/(home)/page.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { 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

311
export default async function HomePage({
412
params,

app/[lang]/docs/layout.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { source } from '@/lib/source';
22
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
33
import { baseOptions } from '@/app/layout.config';
4+
import { i18n } from '@/lib/i18n';
45
import type { ReactNode } from 'react';
56

7+
// 生成静态参数,用于静态导出
8+
export function generateStaticParams() {
9+
return i18n.languages.map((lang) => ({
10+
lang,
11+
}));
12+
}
13+
614
export default async function Layout({
715
children,
816
params

app/[lang]/layout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { use } from 'react';
66
import type { ReactNode } from 'react';
77
import type { Translations } from 'fumadocs-ui/i18n';
88
import type { Metadata } from 'next';
9+
import { i18n } from '@/lib/i18n';
910

1011
const 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
// 可用语言配置
2128
const locales = [

app/api/search/route.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/sitemap.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import type { MetadataRoute } from 'next';
22
import { 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 包含协议前缀
811
function formatBaseUrl(url: string): string {

components/home/LandingShowcase.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@
33
import { useEffect, useState } from 'react';
44
import Link from 'next/link';
55
import 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

826
interface LandingCopy {
927
heroTitle: string;

next.config.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

next.config.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ const withMDX = createMDX();
66
const 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
}

source.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
1111
export const docs = defineDocs({
12-
dir: 'docs',
12+
dir: 'content/docs',
1313
docs: {
1414
schema: frontmatterSchema.extend({
1515
author: z.string().optional(),

0 commit comments

Comments
 (0)