Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy VitePress GitHub Pages

on:
push:
workflow_dispatch:
workflow_run:
workflows: ["Fetch Upstream Data"]
types: [ completed ]

# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
group: pages
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整的 git 历史记录用于时间戳
- uses: pnpm/action-setup@v3
with:
version: latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: pnpm install
- name: Build with VitePress
run: pnpm build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: .vitepress/dist

# 部署工作
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
29 changes: 29 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PR Check

on:
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ dist-ssr
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.vitepress/cache/
.vitepress/dist/
pnpm-workspace.yaml
.DS_Store
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
9 changes: 0 additions & 9 deletions .prettierrc.json

This file was deleted.

165 changes: 165 additions & 0 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import { figure } from '@mdit/plugin-figure';
import { defineConfig, type HeadConfig } from 'vitepress';
import {
navTranslations,
themeConfigTranslations,
} from './data/i18n';

// SEO 相关常量
const SITE_URL = 'https://pclce-web.demo.fis.ink';
const SITE_NAME = 'PCL CE';
const DEFAULT_DESCRIPTION =
'PCL CE是基于 PCL2 构建的开源免费 Minecraft 启动器,提供智能崩溃分析、多文件夹实例管理、资源一键下载与多账号支持';
const DEFAULT_KEYWORDS =
'PCL,PCL2,Minecraft启动器,我的世界启动器,开源启动器,崩溃分析,模组管理,Java管理';

// https://vitepress.dev/reference/site-config
export default defineConfig({
srcDir: './src',
title: 'PCL CE',
description: '开源免费的 Minecraft 启动器',
cleanUrls: true,
sitemap: {
hostname: SITE_URL,
},

markdown: {
lineNumbers: true,
image: { lazyLoading: true },
config: (md) => {
md.use(figure);
},
},

// 支持 iconify-icon 组件
vue: {
template: {
compilerOptions: { isCustomElement: (tag) => tag === 'iconify-icon' },
},
},

head: [
['link', { rel: 'icon', href: '/img/logo.ico' }],
['meta', { name: 'theme-color', content: '#0066CC' }],
// SEO 基础标签
['meta', { name: 'author', content: 'PCL Community' }],
['meta', { name: 'keywords', content: DEFAULT_KEYWORDS }],
['meta', { name: 'robots', content: 'index, follow' }],
// 预连接优化
[
'link',
{ rel: 'preconnect', href: 'https://github.com', crossorigin: '' },
],
['link', { rel: 'dns-prefetch', href: 'https://github.com' }],
],

// 动态生成 SEO 标签
transformPageData(pageData) {
const pagePath = pageData.relativePath
.replace(/\.md$/, '')
.replace(/\/index$/, '/');
const canonicalUrl = `${SITE_URL}/${pagePath}`;
const ogImage = pageData.frontmatter.ogImage || '/img/f1.png';
const pageKeywords = pageData.frontmatter.keywords || DEFAULT_KEYWORDS;

// 确定当前语言和路径
let langCode = 'zh-CN';
let langPath = pagePath;
if (pagePath.startsWith('en/')) {
langCode = 'en';
langPath = pagePath.replace('en/', '');
}

// 生成 hreflang 标签
const hreflangLinks: HeadConfig[] = [
[
'link',
{
rel: 'alternate',
hreflang: 'zh-CN',
href: `${SITE_URL}/${langPath}`,
},
],
[
'link',
{
rel: 'alternate',
hreflang: 'en',
href: `${SITE_URL}/en/${langPath}`,
},
],
[
'link',
{
rel: 'alternate',
hreflang: 'x-default',
href: `${SITE_URL}/${langPath}`,
},
],
];

const head: HeadConfig[] = [
// Open Graph 标签
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:site_name', content: SITE_NAME }],
['meta', { property: 'og:locale', content: langCode }],
['meta', { property: 'og:title', content: pageData.title || SITE_NAME }],
[
'meta',
{
property: 'og:description',
content: pageData.description || DEFAULT_DESCRIPTION,
},
],
['meta', { property: 'og:url', content: canonicalUrl }],
['meta', { property: 'og:image', content: `${SITE_URL}${ogImage}` }],
// Twitter Card 标签
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['meta', { name: 'twitter:title', content: pageData.title || SITE_NAME }],
[
'meta',
{
name: 'twitter:description',
content: pageData.description || DEFAULT_DESCRIPTION,
},
],
['meta', { name: 'twitter:image', content: `${SITE_URL}${ogImage}` }],
// SEO 标签
['meta', { name: 'keywords', content: pageKeywords }],
['link', { rel: 'canonical', href: canonicalUrl }],
...hreflangLinks,
];

pageData.frontmatter.head ??= [];
pageData.frontmatter.head.push(...head);
},

locales: {
root: {
label: '简体中文',
lang: 'zh-CN',
title: 'PCL CE',
description: '开源免费的 Minecraft 启动器,支持崩溃分析与多版本管理',
themeConfig: {
nav: navTranslations['zh-CN'],
...themeConfigTranslations['zh-CN'],
},
},
en: {
label: 'English',
lang: 'en',
title: 'PCL CE',
description:
'Open Source & Free Minecraft Launcher with Smart Crash Analysis',
themeConfig: {
nav: navTranslations.en,
...themeConfigTranslations.en,
},
},
},

themeConfig: {
logo: '/img/logo.ico',
socialLinks: [{ icon: 'github', link: 'https://github.com/PCL-Community' }],
},
});
2 changes: 2 additions & 0 deletions .vitepress/data/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 重导出所有本地化相关的内容
export * from './locales/index';
81 changes: 81 additions & 0 deletions .vitepress/data/locales/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import type { LocaleMessages } from './index';

export const en: LocaleMessages = {
// Navigation
nav: {
home: '<iconify-icon class="i-mr" icon="mdi:home" style="color:#3498db"></iconify-icon>Home',
download:
'<iconify-icon class="i-mr" icon="mdi:download" style="color:#2ecc71"></iconify-icon>Download',
about:
'<iconify-icon class="i-mr" icon="mdi:information" style="color:#9b59b6"></iconify-icon>About',
},

// Theme config
theme: {
prevPage: 'Previous',
nextPage: 'Next',
outlineLabel: 'On this page',
lastUpdated: 'Last updated',
langMenuLabel: 'Language',
returnToTopLabel: 'Return to top',
sidebarMenuLabel: 'Menu',
darkModeSwitchLabel: 'Theme',
lightModeSwitchTitle: 'Light theme',
darkModeSwitchTitle: 'Dark theme',
},

// Footer
footer: {
quickLinks: 'Quick Links',
home: 'Home',
download: 'Download',
about: 'About',
community: 'Community',
feedback: 'Issues',
discussions: 'Discussions',
beian: '',
copyright: 'MIT License.',
},

// Download page
download: {
title: 'Download PCL CE',
latestStable: 'Latest Stable Release',
systemCheck: 'Check System Architecture',
systemCheckDesc: 'Press **Win + S**, search for **System Information**.',
systemType: 'Check **System Type**:',
x64Hint: '**x64-based PC** → Download X64',
arm64Hint: '**ARM64-based PC** → Download ARM64',
tipTitle: 'Tips',
tipX64: 'Most PCs are **X64**',
tipArm64: '**ARM64** is for devices like Surface Pro X',
tipUnsure: 'Unsure? Try **X64** first',
privacyTitle: 'Privacy Notice',
privacyDesc: 'By downloading and running, you agree to our privacy policy:',
mirrorChyanTitle: 'MirrorChyan Download',
mirrorChyanDesc: 'Use MirrorChyan CDK for high-speed download',
mirrorChyanBtn: 'MirrorChyan Download',
downloadLinks: 'Download Links',
x64Version: 'X64 Version',
x64Desc: 'For most Windows PCs',
arm64Version: 'ARM64 Version',
arm64Desc: 'For ARM-based Windows PCs',
historicalVersions: 'Historical Versions',
historicalDesc: 'Need an older version? Download here:',
historicalBtn: 'Historical Versions',
alsoDownload: 'Or download directly from:',
},

// About page
about: {
title: 'PCL Community',
subtitle:
'Unofficial community organization, not affiliated with PCL developer.',
githubTitle: 'GitHub',
githubDesc: 'Source code, issues & contributions',
bilibiliTitle: 'Bilibili',
bilibiliDesc: 'Updates and tutorials',
joinTitle: 'Join Us',
joinDesc: 'Join discussions and build together',
},
};
Loading
Loading