-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
265 lines (253 loc) · 8.17 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
265 lines (253 loc) · 8.17 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import fs from 'fs';
import path from 'path';
import {themes as prismThemes} from 'prism-react-renderer';
import {GlobExcludeDefault} from '@docusaurus/utils';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import type {PluginOptions as LocalSearchOptions} from '@easyops-cn/docusaurus-search-local';
const isProd = process.env.NODE_ENV === 'production';
const devSearchDir = path.join(__dirname, '.cache', 'dev-local-search');
if (!isProd) {
fs.mkdirSync(devSearchDir, {recursive: true});
}
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
const config: Config = {
title: 'Quicker 文档',
tagline: 'Quicker V2 使用说明与迁移指南',
favicon: 'img/favicon.ico',
headTags: [
{
tagName: 'link',
attributes: {
rel: 'apple-touch-icon',
href: '/img/apple-touch-icon.png',
},
},
],
// Drop the default "Docusaurus vX" generator meta from built HTML.
ssrTemplate: `
<!DOCTYPE html>
<html <%~ it.htmlAttributes %>>
<head>
<meta charset="UTF-8">
<script>
(function () {
var root = document.documentElement;
try {
// Only the explicit query. Do not key off iframe: Cursor / in-app
// browsers also have window.self !== window.top.
if (/(?:^|[?&])embed=1(?:&|$)/.test(location.search)) {
root.setAttribute('data-qk-embed', '');
}
} catch (e) {}
function apply() {
root.style.setProperty('--qk-dpr', String(window.devicePixelRatio || 1));
}
apply();
try {
var mq;
function watch() {
apply();
if (mq) mq.removeEventListener('change', watch);
mq = window.matchMedia('(resolution: ' + (window.devicePixelRatio || 1) + 'dppx)');
mq.addEventListener('change', watch);
}
watch();
} catch (e) {}
})();
</script>
<% it.metaAttributes.forEach((metaAttribute) => { %>
<%~ metaAttribute %>
<% }); %>
<%~ it.headTags %>
<% it.stylesheets.forEach((stylesheet) => { %>
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
<% }); %>
<% it.scripts.forEach((script) => { %>
<script src="<%= it.baseUrl %><%= script %>" defer></script>
<% }); %>
</head>
<body <%~ it.bodyAttributes %>>
<%~ it.preBodyTags %>
<div id="__docusaurus"><%~ it.appHtml %></div>
<%~ it.postBodyTags %>
</body>
</html>
`,
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
future: {
v4: true, // Improve compatibility with the upcoming Docusaurus v4
},
// Set the production url of your site here
url: 'https://docs.getquicker.net',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'QuickerOrg', // Usually your GitHub org/user name.
projectName: 'docs.getquicker.net', // Usually your repo name.
onBrokenLinks: 'throw',
markdown: {
mermaid: true,
},
themes: [
'@docusaurus/theme-mermaid',
[
'@easyops-cn/docusaurus-search-local',
{
hashed: 'filename',
language: ['en', 'zh'],
// docs-only mode: docs are served from `/`, not `/docs`.
docsRouteBasePath: '/',
indexBlog: false,
indexPages: false,
// Live UI previews dump param tables / enums into HTML; skip them so
// the lunr index stays small and first search stays fast.
ignoreCssSelectors: ['.qk-docs-preview', '.docusaurus-mermaid-container'],
} satisfies LocalSearchOptions,
],
],
plugins: ['./plugins/doc-gallery', './plugins/dev-local-search', './plugins/prefetch-previews'],
clientModules: [
'./src/clientModules/quickerEmbedChrome.ts',
'./src/clientModules/prefetchSearchIndex.ts',
'./src/clientModules/prefetchDocPreviews.ts',
],
staticDirectories: isProd
? ['static']
: ['static', '.cache/dev-local-search'],
// Even if you don't use internationalization, you can use this field to set
// useful metadata like html lang. For example, if your site is Chinese, you
// may want to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'zh-Hans',
locales: ['zh-Hans'],
},
presets: [
[
'classic',
{
docs: {
sidebarPath: './sidebars.ts',
routeBasePath: '/',
editUrl:
'https://github.com/QuickerOrg/docs.getquicker.net/tree/main/',
},
blog: false,
pages: {
exclude: [
...GlobExcludeDefault,
...(isProd ? ['**/lab/screenshot-review/**'] : []),
],
},
// Encode apostrophes in loc. The what's-new/ directory is not renamed
// in this change; raw "'" in <loc> can break XML consumers / some edges.
sitemap: {
lastmod: 'date',
createSitemapItems: async (params) => {
const {defaultCreateSitemapItems, ...rest} = params;
const items = await defaultCreateSitemapItems(rest);
return items.map((item) => ({
...item,
url: item.url.replaceAll("'", '%27'),
}));
},
},
theme: {
customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],
themeConfig: {
image: 'img/apple-touch-icon.png',
colorMode: {
respectPrefersColorScheme: true,
},
navbar: {
title: 'Quicker 文档',
logo: {
alt: 'Quicker',
src: 'img/logo.svg',
srcDark: 'img/logo-dark.svg',
},
items: [
{
to: '/v2/getting-started',
position: 'left',
label: '开始使用',
},
{to: '/v2/features', label: '功能使用', position: 'left'},
{to: '/v2/xaction', label: '组合动作', position: 'left'},
{to: '/release-notes', label: '更新记录', position: 'left'},
{type: 'search', position: 'right'},
...(!isProd
? [
{
to: '/lab/screenshot-review',
label: '截图审核',
position: 'right' as const,
},
]
: []),
{
href: 'https://getquicker.net',
label: 'Quicker 官网',
position: 'right',
},
{
href: 'https://github.com/QuickerOrg/docs.getquicker.net',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'light',
links: [
{label: 'Quicker V2', to: '/v2'},
{label: '更新记录', to: '/release-notes'},
{label: '官网 V2', href: 'https://getquicker.net/V2'},
{label: '1.x 文档', href: 'https://getquicker.net/KC'},
{label: '讨论区', href: 'https://getquicker.net/QA'},
{
label: 'GitHub',
href: 'https://github.com/QuickerOrg/docs.getquicker.net',
},
],
copyright: `© ${new Date().getFullYear()} Quicker`,
},
mermaid: {
theme: {light: 'neutral', dark: 'dark'},
options: {
fontFamily:
'"Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif',
flowchart: {
curve: 'basis',
padding: 12,
nodeSpacing: 36,
rankSpacing: 48,
htmlLabels: true,
},
},
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.vsDark,
// Languages beyond prism-react-renderer defaults (TS/TSX already included).
// Requires the `prismjs` package (Docusaurus peer / transitive).
additionalLanguages: ['csharp', 'powershell', 'python', 'batch'],
},
} satisfies Preset.ThemeConfig,
customFields: {
// 后续 QuickerWeb 提供评论挂载页后,填入例如:
// https://getquicker.net/V2Docs/Comments
quickerCommentsBaseUrl: '',
// Local screenshot-review API (tools/screenshot-replace/review-api.mjs). Dev only.
...(isProd
? {}
: {screenshotReviewApiBase: 'http://127.0.0.1:3920'}),
},
};
export default config;