-
Notifications
You must be signed in to change notification settings - Fork 0
/
docusaurus.config.js
317 lines (298 loc) · 9.97 KB
/
docusaurus.config.js
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
// @ts-check
// Note: 类型注释允许类型检查和 IDE
// 参考案例: https://github.com/xiaohai-huang/learning-notes/blob/master/docusaurus.config.js
const path = require("path")
const lightCodeTheme = require("prism-react-renderer/themes/github")
const darkCodeTheme = require("prism-react-renderer/themes/dracula")
const { npm2yarn2pnpm } = require("@sapphire/docusaurus-plugin-npm2yarn2pnpm")
/** @type {import('@docusaurus/types').Config} */
const config = {
title: "哈希肯",
tagline:
"A place for organizing notes, writing blogs, and showcasing projects.",
favicon: "img/favicon.ico",
onBrokenLinks: "throw", // '忽略' | '日志' | '警告' | '扔'
onBrokenMarkdownLinks: "warn",
// Set the production url of your site here
url: "https://didilinkin.cn",
// 设置 /<baseUrl>/ 为您的网站提供服务的路径名称
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: "/",
// GitHub 页面部署配置。
// 如果您不使用 GitHub 页面,则不需要这些。
// organizationName: 'facebook', // Usually your GitHub org/user name.
// projectName: 'docusaurus', // Usually your repo name.
// 即使你不使用内部化,你也可以使用这个字段来设置有用的
// 像 html lang 这样的元数据。 例如,如果你的网站是中文的,你可能想要
// 用“zh-Hans”替换“en”。
i18n: {
defaultLocale: "zh-Hans",
locales: ["zh-Hans"],
},
plugins: [
// 用于快速别名本地模块的 Docusaurus v2 插件
// https://github.com/atomicpages/docusaurus-plugin-module-alias
async function plugin(context, options) {
return {
name: "docusaurus-plugin-module-alias",
configureWebpack() {
return {
resolve: {
alias: {
"@src": path.resolve(__dirname, "src"),
},
},
}
},
}
},
// 生成近乎理想的图像的 Docusaurus 插件(响应式、懒加载及低像素占位图)
// https://docusaurus.io/zh-CN/docs/api/plugins/@docusaurus/plugin-ideal-image
[
"@docusaurus/plugin-ideal-image",
{
quality: 70,
max: 1030, // 最大缩放图片尺寸。
min: 640, // 最小缩放图片尺寸。 如果原始值比这还低,会使用原图尺寸。
steps: 2, // 在 min 和 max 之间最多生成的图片数量(包含两端点)
disableInDev: false,
},
],
],
// 预设
presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve("./sidebars.js"),
// editUrl: '',
// showLastUpdateAuthor: true, // 是否显示最后更新文档的作者
showLastUpdateTime: true, // 是否显示最后更新文档的时间
breadcrumbs: true, // 在文档页面上启用或禁用面包屑导航
remarkPlugins: [
// [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
npm2yarn2pnpm,
],
},
pages: {
remarkPlugins: [
// require('@docusaurus/remark-plugin-npm2yarn'),
npm2yarn2pnpm,
],
},
blog: {
// path: "./blog", // 路径
// routeBasePath: "/blog",
showReadingTime: true,
sortPosts: "descending", // 排序方向, 倒叙
blogSidebarCount: "ALL",
blogSidebarTitle: "最近内容", // 博客侧边栏的标题
remarkPlugins: [
// [require('@docusaurus/remark-plugin-npm2yarn'), {sync: true}],
npm2yarn2pnpm,
],
// https://docusaurus.io/zh-CN/docs/blog#feed
feedOptions: {
type: "all",
copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`,
createFeedItems: async (params) => {
const { blogPosts, defaultCreateFeedItems, ...rest } = params
return defaultCreateFeedItems({
// 仅保留提要中的 10 篇最新博客文章
blogPosts: blogPosts.filter((item, index) => index < 10),
...rest,
})
},
},
},
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
sitemap: {
changefreq: "weekly",
priority: 0.5,
ignorePatterns: ["/tags/**"],
filename: "sitemap.xml",
},
}),
],
],
// plugins: [
// '@docusaurus/theme-live-codeblock',
// ],
// 主题
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// 替换为你项目的社交卡
image: "img/avataaars.png",
docs: {
sidebar: {
hideable: false, // 可隐藏侧边栏
autoCollapseCategories: true, // 自动折叠侧边栏类别
},
},
algolia: {
// Algolia 提供的应用 ID
appId: "VLDY0NMJL7",
// 公开 API 密钥:提交它没有危险
apiKey: "e2c5226bd3db05e06e8f6cc22b142c5f", // Search-Only API Key
indexName: "didilinkin-website",
},
// SEO
metadata: [
{
name: "keywords",
content: "哈希肯, didilinkin, didilinkin-website, didilinkin-blog",
},
{
name: "description",
content:
"哈希肯 didilinkin 的个人主页. Personal blog and Documentation about full-stack development.",
},
],
navbar: {
title: "哈希肯",
// https://docusaurus.io/zh-CN/docs/api/themes/configuration#navbar-logo
logo: {
alt: "My Site Logo",
src: "img/avataaars.png",
// srcDark: 'img/logo_dark.svg',
// href: '/',
// target: '_self',
// width: 32,
// height: 32,
// className: 'custom-navbar-logo-class',
// style: {border: 'solid red'},
},
hideOnScroll: false, // 自动隐藏顶部导航栏
// https://docusaurus.io/zh-CN/docs/api/themes/configuration#navbar-items
items: [
{
// type: "docs",
// docId: "docs",
position: "left",
label: "笔记",
to: "/docs",
},
{
to: "/blog",
label: "博客",
position: "left",
},
// { to: "/showcase", label: "展柜", position: "left" },
// { to: "/about", label: "关于", position: "right" },
{ type: "localeDropdown", position: "right" },
{
// label: "GitHub",
href: "https://github.com/didilinkin",
position: "right",
className: "header-icon header-github-link",
"aria-label": "GitHub repository",
// "uk-icon": "github",
},
{
href: "https://didilinkin.cn/blog/rss.xml",
position: "right",
className: "header-icon header-rss-link",
"aria-label": "RSS",
// "uk-icon": "rss",
},
],
},
footer: {
style: "dark",
links: [
{
title: "Docs",
items: [
{
label: "笔记",
to: "/docs",
},
],
},
{
title: "More",
items: [
{ label: "博客", to: "/blog" },
// { label: "关于", to: "/about" },
// { label: "Resources", href: "https://github.com/xiaohai-huang/resources" },
{
label: "GitHub",
href: "https://github.com/didilinkin",
},
],
},
{
title: "Entrance",
items: [
{
label: "Traefik Dashboard",
href: "https://dash.didilinkin.cn/",
},
// {
// label: "Prometheus",
// href: "https://prometheus.didilinkin.cn/",
// },
// {
// label: "Grafana",
// href: "https://grafana.didilinkin.cn/",
// },
],
},
],
copyright: `
Copyright © ${new Date().getFullYear()} 哈希肯. 本网站使用 <a href="https://docusaurus.io/zh-CN" target="_blank">Docusaurus</a> 构建
<br />
<p class="record--info"><a target="_blank" href="https://beian.miit.gov.cn/">鲁ICP备2020037005号-1</a></p>
`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
// https://docusaurus.io/zh-CN/docs/markdown-features/code-blocks#supported-languages
// https://prismjs.com/#supported-languages
additionalLanguages: [
"powershell",
"go",
"java",
"solidity",
"php",
"yaml",
"bash",
"git",
"typescript",
],
},
}),
// 主题
// https://docusaurus.io/zh-CN/docs/using-plugins#using-themes
themes: ["@docusaurus/theme-live-codeblock"],
// 这个选项允许你自定义 URL/链接后是否添加末尾斜杠,以及静态 HTML 会如何被生成。
// 类型:boolean | undefined
// https://docusaurus.io/zh-CN/docs/api/docusaurus-config#trailingSlash
// trailingSlash: false,
stylesheets: [
// {
// href: "https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css",
// integrity:
// "sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc",
// crossorigin: "anonymous",
// },
//
"https://cdn.staticfile.org/uikit/3.16.17/css/uikit.min.css",
"https://cdn.staticfile.org/sweetalert2/11.7.5/sweetalert2.min.css",
],
scripts: [
// "https://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js",
"/baidu-analytics/analytics.js",
{
src: "https://cdn.staticfile.org/sweetalert2/11.7.5/sweetalert2.min.js",
defer: true,
},
],
}
module.exports = config