Skip to content

Commit 6b08e2c

Browse files
committed
feat: init
0 parents  commit 6b08e2c

30 files changed

Lines changed: 906 additions & 0 deletions

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Base URL for GitHub Pages
2+
VITE_BASE_URL=/gfl-docs/

.gfl.config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
debug: true # Enable debug mode for detailed output
2+
devBaseBranch: main # Base branch for feature development
3+
productionBranch: main # Main production branch
4+
featurePrefix: feature # Prefix for feature branches
5+
fixPrefix: fix # Prefix for bug fix branches
6+
hotfixPrefix: hotfix # Prefix for hotfix branches
7+
# Branch case format: lower, upper, snake, camel, pascal, kebab, original
8+
branchCaseFormat: lower

.github/workflows/deploy.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Deploy VitePress Site to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22'
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v4
30+
with:
31+
version: 9
32+
33+
- name: Get pnpm store directory
34+
id: pnpm-cache
35+
shell: bash
36+
run: |
37+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
38+
39+
- name: Setup pnpm cache
40+
uses: actions/cache@v4
41+
with:
42+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
43+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
44+
restore-keys: |
45+
${{ runner.os }}-pnpm-store-
46+
47+
- name: Install dependencies
48+
run: pnpm install --frozen-lockfile
49+
50+
- name: Build VitePress site
51+
run: pnpm build
52+
53+
- name: Deploy to GitHub Pages
54+
uses: peaceiris/actions-gh-pages@v4
55+
with:
56+
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
publish_dir: ./dist
58+
59+
- name: Output deployment URL
60+
run: |
61+
REPO_NAME=${{ github.repository }}
62+
PAGE_URL="https://${{ github.repository_owner }}.github.io/${REPO_NAME#*/}/"
63+
echo "🚀 Deployed to: $PAGE_URL"
64+
echo "$PAGE_URL"
65+
echo "site_url=$PAGE_URL" >> $GITHUB_OUTPUT
66+
67+
- name: Add to summary
68+
run: |
69+
REPO_NAME=${{ github.repository }}
70+
PAGE_URL="https://${{ github.repository_owner }}.github.io/${REPO_NAME#*/}/"
71+
echo "### 🎉 Deployed to: $PAGE_URL" >> $GITHUB_STEP_SUMMARY
72+
echo "" >> $GITHUB_STEP_SUMMARY
73+
echo "Access URL: [$PAGE_URL]($PAGE_URL)" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
node_modules
2+
bower_components
3+
coverage
4+
npm-debug.log
5+
yarn.lock
6+
package-lock.json
7+
.DS_Store
8+
9+
10+
# vscode
11+
.vscode
12+
.history
13+
.idea
14+
15+
# python cache
16+
__pycache__
17+
18+
# vitepress cache
19+
dist
20+
**/.vitepress/cache/
21+
**/.vitepress/temp/
22+
23+
# Environment variables
24+
.env.local
25+
.env.*.local
26+
27+
# Claude
28+
.claude/*.local.json
29+
30+
.gfl.config.local.yml

.vitepress/config.mts

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import { defineConfig, loadEnv } from "vitepress";
2+
import { generateSidebar } from "vitepress-sidebar";
3+
import { VitePWA } from "vite-plugin-pwa";
4+
import { pwaConfig } from "./pwa.config";
5+
6+
// 使用 VitePress 的 loadEnv 加载环境变量
7+
// mode: '' 会加载 .env 文件(只加载 VITE_ 开头的变量)
8+
const env = loadEnv("", process.cwd());
9+
10+
export default defineConfig({
11+
srcDir: "./src",
12+
base: env.VITE_BASE_URL || "/",
13+
lastUpdated: true,
14+
head: [
15+
["link", { rel: "icon", href: "/favicon.svg", type: "image/svg+xml" }],
16+
],
17+
title: "GFL",
18+
description: "A powerful command-line tool that simplifies GitHub Flow workflows",
19+
outDir: "./dist",
20+
vite: {
21+
plugins: [VitePWA(pwaConfig)],
22+
},
23+
locales: {
24+
root: {
25+
label: "简体中文",
26+
lang: "zh-CN",
27+
title: "SITE_TITLE",
28+
description: "SITE_DESCRIPTION",
29+
themeConfig: {
30+
logo: "/favicon.svg",
31+
lastUpdated: {
32+
text: "更新时间",
33+
},
34+
docFooter: {
35+
prev: "上一页",
36+
next: "下一页",
37+
},
38+
outline: {
39+
label: "大纲",
40+
level: [2, 3],
41+
},
42+
nav: [
43+
{ text: "首页", link: "/" },
44+
{ text: "组件", link: "/posts/components/index.md" },
45+
{ text: "Utils", link: "/posts/utils/index.md" },
46+
{ text: "规范", link: "/posts/standard/index.md" },
47+
{ text: "事故", link: "/posts/incidents/index.md" },
48+
],
49+
sidebar: generateSidebar({
50+
documentRootPath: "src",
51+
scanStartPath: "/posts",
52+
collapsed: false,
53+
capitalizeFirst: true,
54+
useTitleFromFileHeading: true,
55+
useTitleFromFrontmatter: true,
56+
hyphenToSpace: true,
57+
excludePattern: ["README.md"],
58+
debugPrint: false,
59+
}),
60+
search: {
61+
provider: "local",
62+
options: {
63+
translations: {
64+
button: {
65+
buttonText: "搜索",
66+
buttonAriaLabel: "搜索文档",
67+
},
68+
modal: {
69+
noResultsText: "无法找到相关结果",
70+
resetButtonTitle: "清除查询条件",
71+
footer: {
72+
selectText: "选择",
73+
navigateText: "切换",
74+
closeText: "关闭",
75+
},
76+
},
77+
},
78+
},
79+
},
80+
socialLinks: [
81+
{ icon: "github", link: "https://github.com/afeiship" },
82+
],
83+
footer: {
84+
message: "基于 MIT 许可发布",
85+
copyright: "Copyright © 2019-present aric.zheng",
86+
},
87+
},
88+
},
89+
en: {
90+
label: "English",
91+
lang: "en",
92+
title: "SITE_TITLE",
93+
description: "SITE_DESCRIPTION",
94+
themeConfig: {
95+
logo: "/favicon.svg",
96+
lastUpdated: {
97+
text: "Last updated",
98+
},
99+
docFooter: {
100+
prev: "Previous",
101+
next: "Next",
102+
},
103+
outline: {
104+
label: "On this page",
105+
level: [2, 3],
106+
},
107+
nav: [
108+
{ text: "Home", link: "/en/" },
109+
{ text: "Components", link: "/en/posts/components/index.md" },
110+
{ text: "Utils", link: "/en/posts/utils/index.md" },
111+
{ text: "Standard", link: "/en/posts/standard/index.md" },
112+
{ text: "Incidents", link: "/en/posts/incidents/index.md" },
113+
],
114+
sidebar: generateSidebar({
115+
documentRootPath: "src/en",
116+
scanStartPath: "/posts",
117+
collapsed: false,
118+
capitalizeFirst: true,
119+
useTitleFromFileHeading: true,
120+
useTitleFromFrontmatter: true,
121+
hyphenToSpace: true,
122+
excludePattern: ["README.md"],
123+
debugPrint: false,
124+
}),
125+
search: {
126+
provider: "local",
127+
options: {
128+
translations: {
129+
button: {
130+
buttonText: "Search",
131+
buttonAriaLabel: "Search documentation",
132+
},
133+
modal: {
134+
noResultsText: "No results for",
135+
resetButtonTitle: "Reset search",
136+
footer: {
137+
selectText: "to select",
138+
navigateText: "to navigate",
139+
closeText: "to close",
140+
},
141+
},
142+
},
143+
},
144+
},
145+
socialLinks: [
146+
{ icon: "github", link: "https://github.com/GITHUB_USERNAME" },
147+
],
148+
footer: {
149+
message: "Released under the MIT License.",
150+
copyright: "Copyright © 2019-present AUTHOR_NAME",
151+
},
152+
},
153+
},
154+
},
155+
});

.vitepress/pwa.config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { VitePWAOptions } from 'vite-plugin-pwa'
2+
3+
export const pwaConfig: Partial<VitePWAOptions> = {
4+
registerType: 'autoUpdate',
5+
includeAssets: ['favicon.svg'],
6+
manifest: {
7+
name: 'GFL',
8+
short_name: 'SITE_TITLE',
9+
description: 'A powerful command-line tool that simplifies GitHub Flow workflows',
10+
theme_color: '#3eaf7c',
11+
background_color: '#ffffff',
12+
display: 'standalone',
13+
icons: [
14+
{
15+
src: '/pwa-192x192.png',
16+
sizes: '192x192',
17+
type: 'image/png',
18+
purpose: 'any maskable'
19+
},
20+
{
21+
src: '/pwa-512x512.png',
22+
sizes: '512x512',
23+
type: 'image/png',
24+
purpose: 'any maskable'
25+
}
26+
]
27+
},
28+
workbox: {
29+
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
30+
navigateFallback: null
31+
}
32+
}

.vitepress/theme/ReloadPrompt.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div v-if="needRefresh" class="pwa-update-banner">
3+
<span>有新内容可用,点击更新</span>
4+
<button class="pwa-update-btn" @click="updateServiceWorker()">
5+
更新
6+
</button>
7+
</div>
8+
</template>
9+
10+
<script setup lang="ts">
11+
// @ts-ignore - virtual module from vite-plugin-pwa
12+
import { useRegisterSW } from 'virtual:pwa-register/vue'
13+
14+
const { needRefresh, updateServiceWorker } = useRegisterSW({
15+
onRegistered(r: any) {
16+
console.log('SW registered: ', r)
17+
},
18+
onRegisterError(error: any) {
19+
console.error('SW registration error', error)
20+
}
21+
})
22+
</script>
23+
24+
<style scoped>
25+
.pwa-update-banner {
26+
position: fixed;
27+
bottom: 0;
28+
left: 0;
29+
right: 0;
30+
background: var(--vp-c-bg-soft);
31+
color: var(--vp-c-text-1);
32+
padding: 12px 20px;
33+
text-align: center;
34+
z-index: 1000;
35+
border-top: 1px solid var(--vp-c-divider);
36+
display: flex;
37+
align-items: center;
38+
justify-content: center;
39+
gap: 16px;
40+
}
41+
42+
.pwa-update-btn {
43+
padding: 6px 16px;
44+
background: var(--vp-c-brand);
45+
color: white;
46+
border: none;
47+
border-radius: 4px;
48+
cursor: pointer;
49+
font-size: 14px;
50+
transition: opacity 0.2s;
51+
}
52+
53+
.pwa-update-btn:hover {
54+
opacity: 0.9;
55+
}
56+
</style>

.vitepress/theme/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Theme } from 'vitepress'
2+
import DefaultTheme from 'vitepress/theme'
3+
import { h } from 'vue'
4+
import ReloadPrompt from './ReloadPrompt.vue'
5+
6+
export default {
7+
extends: DefaultTheme,
8+
Layout() {
9+
return h(DefaultTheme.Layout, null, {
10+
'layout-bottom': () => h(ReloadPrompt)
11+
})
12+
}
13+
} as Theme

0 commit comments

Comments
 (0)