Skip to content

Commit fc8d311

Browse files
feat: Add GitHub Pages deployment for landing page
Add static export workflow to deploy landing page to GitHub Pages without a server. Conditionally switch between 'export' and 'standalone' output via GITHUB_PAGES env var. Fix pre-existing type errors in header.tsx and simple-editor.tsx.
1 parent 92c39dd commit fc8d311

4 files changed

Lines changed: 75 additions & 3 deletions

File tree

.github/workflows/pages.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Deploy Landing Page to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [master]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: pnpm/action-setup@v4
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: pnpm
29+
30+
- name: Install dependencies
31+
run: pnpm install --frozen-lockfile
32+
33+
- name: Remove dynamic routes for static export
34+
run: |
35+
rm -rf apps/web/src/app/\(main\)/spaces/\[id\]
36+
rm -rf apps/web/src/app/\(public\)/share
37+
rm -rf apps/web/src/app/invite
38+
rm -rf apps/web/src/app/public/spaces/\[id\]
39+
rm -f apps/web/src/app/sitemap.ts
40+
rm -f apps/web/src/app/robots.ts
41+
42+
- name: Build static export
43+
run: pnpm --filter @docStudio/web build
44+
env:
45+
GITHUB_PAGES: 'true'
46+
NEXT_PUBLIC_SITE_URL: https://jason-chen-coder.github.io/DocStudio
47+
NEXT_PUBLIC_API_URL: ''
48+
NEXT_PUBLIC_WEBSOCKET_URL: ''
49+
NEXT_PUBLIC_CDN_URL: ''
50+
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: apps/web/out
55+
56+
deploy:
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
runs-on: ubuntu-latest
61+
needs: build
62+
steps:
63+
- name: Deploy to GitHub Pages
64+
id: deployment
65+
uses: actions/deploy-pages@v4

apps/web/next.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import type { NextConfig } from "next";
22

3+
const isGithubPages = process.env.GITHUB_PAGES === 'true';
4+
35
const nextConfig: NextConfig = {
4-
// 生成独立部署包,用于 Docker 容器(减小镜像体积)
5-
output: 'standalone',
6+
// GitHub Pages 使用静态导出,Docker 部署使用 standalone 模式
7+
output: isGithubPages ? 'export' : 'standalone',
8+
// GitHub Pages 部署在子路径 /DocStudio 下
9+
basePath: isGithubPages ? '/DocStudio' : '',
610
images: {
11+
// GitHub Pages 不支持 next/image 优化,需要关闭
12+
unoptimized: isGithubPages,
713
remotePatterns: [
814
// 开发环境:直连本地 MinIO
915
{

apps/web/src/components/layout/header.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function Header() {
3737
}, []);
3838

3939
const avatarUrl = getAvatarUrl(user?.avatarUrl, user?.name);
40+
const initial = user?.name?.charAt(0)?.toUpperCase() || '?';
4041
const { theme, toggleTheme, mounted } = useTheme();
4142

4243
return (

apps/web/src/components/tiptap-templates/simple/simple-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ export function SimpleEditor({
616616
],
617617
// In collab mode, Yjs manages content entirely — pass undefined.
618618
// In non-collab mode, parse JSON string into Tiptap JSON object for initial render.
619-
content: isCollabMode ? undefined : parseContent(content),
619+
content: isCollabMode ? undefined : (parseContent(content) as import('@tiptap/core').Content),
620620
editable,
621621
onCreate: ({ editor }: { editor: Editor }) => {
622622
onReady?.(editor);

0 commit comments

Comments
 (0)