-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
151 lines (139 loc) · 4.07 KB
/
Copy pathdocusaurus.config.js
File metadata and controls
151 lines (139 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// @ts-check
import {themes as prismThemes} from 'prism-react-renderer';
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'GitHub Trending Reporter',
tagline: '每日 GitHub 热门项目追踪与 AI 分析',
favicon: 'img/logo.svg',
url: 'https://wayyoungboy.github.io',
baseUrl: '/github-trending-reporter/',
organizationName: 'wayyoungboy',
projectName: 'github-trending-reporter',
deploymentBranch: 'gh-pages',
trailingSlash: false,
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
i18n: {
defaultLocale: 'zh-Hans',
locales: ['zh-Hans'],
},
// 插件配置 - 复制 markdown 源文件到静态目录
plugins: [
async function copyMarkdownPlugin(context, options) {
return {
name: 'copy-markdown-plugin',
async postBuild({ outDir }) {
const fs = require('fs');
const path = require('path');
// 复制 reports 和 data 目录到 build 目录
const copyDir = (src, dest, extensions) => {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
const files = fs.readdirSync(src);
for (const file of files) {
const srcPath = path.join(src, file);
const destPath = path.join(dest, file);
const stat = fs.statSync(srcPath);
if (stat.isDirectory()) {
copyDir(srcPath, destPath, extensions);
} else if (extensions.some(ext => file.endsWith(ext))) {
fs.copyFileSync(srcPath, destPath);
}
}
};
const reportsDir = path.join(context.siteDir, 'reports');
const outReportsDir = path.join(outDir, 'reports');
if (fs.existsSync(reportsDir)) {
copyDir(reportsDir, outReportsDir, ['.md']);
}
const dataDir = path.join(context.siteDir, 'data');
const outDataDir = path.join(outDir, 'data');
if (fs.existsSync(dataDir)) {
copyDir(dataDir, outDataDir, ['.json']);
}
},
};
},
],
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: './sidebars.js',
path: 'reports',
routeBasePath: 'reports',
},
blog: false,
theme: {
customCss: './src/css/custom.css',
},
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
colorMode: {
defaultMode: 'dark',
disableSwitch: true,
respectPrefersColorScheme: false,
},
image: 'img/social-card.jpg',
navbar: {
title: 'GitHub Trending Reporter',
logo: {
alt: 'Logo',
src: 'img/logo.svg',
},
items: [
{
type: 'docSidebar',
sidebarId: 'reportsSidebar',
position: 'left',
label: '每日报告',
},
{
href: 'https://github.com/wayyoungboy/github-trending-reporter',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: '报告',
items: [
{
label: '每日报告',
to: '/reports/2026/01/2026-01-12',
},
],
},
{
title: '链接',
items: [
{
label: 'GitHub Trending',
href: 'https://github.com/trending',
},
{
label: '源代码',
href: 'https://github.com/wayyoungboy/github-trending-reporter',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} GitHub Trending Reporter. Built with Docusaurus.`,
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},
}),
};
export default config;