-
Notifications
You must be signed in to change notification settings - Fork 156
/
docusaurus.config.ts
306 lines (301 loc) · 9.39 KB
/
docusaurus.config.ts
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
import type * as Preset from '@docusaurus/preset-classic'
import type { Config } from '@docusaurus/types'
import { themes } from 'prism-react-renderer'
import social from './data/social'
import type { GiscusConfig } from './src/components/Comment'
const beian = '闽ICP备2020017848号-2'
const beian1 = '闽公网安备35021102000847号'
const config: Config = {
title: '愧怍',
url: 'https://kuizuo.cn',
baseUrl: '/',
favicon: 'img/favicon.ico',
organizationName: 'kuizuo',
projectName: 'blog',
customFields: {
bio: '道阻且长,行则将至',
description:
'是一个由愧怍创建的个人博客,主要分享编程开发知识和项目,该网站基于 React 驱动的静态网站生成器 Docusaurus 构建。',
},
themeConfig: {
// announcementBar: {
// id: 'announcementBar-3',
// content: ``,
// },
image: 'img/og.png',
metadata: [
{
name: 'author',
content: '愧怍',
},
{
name: 'keywords',
content: 'blog, javascript, typescript, node, react, vue, web',
},
{
name: 'keywords',
content: '编程爱好者, Web开发者, 写过爬虫, 学过逆向, 主攻ts全栈',
},
],
docs: {
sidebar: {
hideable: true,
},
},
navbar: {
logo: {
alt: '愧怍',
src: 'img/logo.webp',
srcDark: 'img/logo.webp',
},
hideOnScroll: true,
items: [
{ label: '博客', position: 'right', to: 'blog' },
{ label: '项目', position: 'right', to: 'project' },
{ label: '友链', position: 'right', to: 'friends' },
{ label: '关于', position: 'right', to: 'about' },
{
label: '更多',
position: 'right',
items: [
{ label: '归档', to: 'blog/archive' },
{ label: '笔记', to: 'docs/skill' },
{ label: '工具推荐', to: 'docs/tools' },
],
},
// {
// type: 'localeDropdown',
// position: 'right',
// },
],
},
footer: {
style: 'dark',
links: [
{
title: '学习',
items: [
{ label: '博客', to: 'blog' },
{ label: '归档', to: 'blog/archive' },
{ label: '技术笔记', to: 'docs/skill' },
{ label: '实战项目', to: 'project' },
{ label: '前端示例', to: 'https://example.kuizuo.cn' },
],
},
{
title: '社交媒体',
items: [
{ label: '关于我', to: '/about' },
{ label: 'GitHub', href: social.github.href },
{ label: 'Twitter', href: social.x.href },
{ label: '掘金', href: social.juejin.href },
{ label: 'Discord', href: social.discord.href },
],
},
{
title: '网站',
items: [
{ label: 'js反混淆', to: 'https://js-deobfuscator.kuizuo.cn' },
{ label: 'cyberChef', to: 'https://gchq.github.io/CyberChef' },
{ label: 'api服务', to: 'https://api.kuizuo.cn' },
{ label: '便民服务', to: 'https://service.kuizuo.cn' },
{ label: '站点监控', to: 'https://uptime.kuizuo.cn' },
],
},
{
title: '更多',
items: [
{ label: '友链', position: 'right', to: 'friends' },
{
html: `
<a href="https://docusaurus.io" target="_blank" rel="noreferrer noopener">
<img src="/img/buildwith.png" alt="build with docusaurus" width="120" height="50"/>
</a>
`,
},
],
},
],
copyright: `
<p style="margin-bottom: 0;"><a href="http://beian.miit.gov.cn/">${beian}</a></p>
<p style="display: inline-flex; align-items: center;"><img style="height:20px;margin-right: 0.5rem;" src="/img/police.png" alt="police" height="20"/><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=${
beian1.match(/\d+/)?.[0]
}" >${beian1}</a></p>
<p>Copyright © 2020 - ${new Date().getFullYear()} kuizuo. | Built with Docusaurus.</p>
`,
},
algolia: {
appId: 'GV6YN1ODMO',
apiKey: '50303937b0e4630bec4a20a14e3b7872',
indexName: 'kuizuo',
},
prism: {
theme: themes.oneLight,
darkTheme: themes.oneDark,
additionalLanguages: ['bash', 'json', 'java', 'python', 'php', 'graphql', 'rust', 'toml', 'protobuf', 'diff'],
defaultLanguage: 'javascript',
magicComments: [
{
className: 'theme-code-block-highlighted-line',
line: 'highlight-next-line',
block: { start: 'highlight-start', end: 'highlight-end' },
},
{
className: 'code-block-error-line',
line: 'This will error',
},
],
},
giscus: {
repo: 'kuizuo/blog',
repoId: 'MDEwOlJlcG9zaXRvcnkzOTc2MjU2MTI=',
category: 'General',
categoryId: 'DIC_kwDOF7NJDM4CPK95',
theme: 'light',
darkTheme: 'dark_dimmed',
} satisfies Partial<GiscusConfig>,
tableOfContents: {
minHeadingLevel: 2,
maxHeadingLevel: 4,
},
liveCodeBlock: { playgroundPosition: 'top' },
zoom: {
selector: '.markdown :not(em) > img',
background: {
light: 'rgb(255, 255, 255)',
dark: 'rgb(50, 50, 50)',
},
},
} satisfies Preset.ThemeConfig,
presets: [
[
'classic',
{
docs: {
path: 'docs',
sidebarPath: 'sidebars.ts',
},
blog: false,
theme: {
customCss: ['./src/css/custom.css', './src/css/tweet-theme.css'],
},
sitemap: {
priority: 0.5,
},
gtag: {
trackingID: 'G-S4SD5NXWXF',
anonymizeIP: true,
},
debug: process.env.NODE_ENV === 'development',
} satisfies Preset.Options,
],
],
plugins: [
'docusaurus-plugin-image-zoom',
'@docusaurus/plugin-ideal-image',
// ['docusaurus-plugin-baidu-tongji', { token: 'c9a3849aa75f9c4a4e65f846cd1a5155' }],
[
'@docusaurus/plugin-pwa',
{
debug: process.env.NODE_ENV === 'development',
offlineModeActivationStrategies: ['appInstalled', 'standalone', 'queryString'],
pwaHead: [
{ tagName: 'link', rel: 'icon', href: '/img/logo.png' },
{ tagName: 'link', rel: 'manifest', href: '/manifest.json' },
{ tagName: 'meta', name: 'theme-color', content: '#12affa' },
],
},
],
[
'vercel-analytics',
{
debug: process.env.NODE_ENV === 'development',
mode: 'auto',
},
],
[
'./src/plugin/plugin-content-blog', // 为了实现全局 blog 数据,必须改写 plugin-content-blog 插件
{
path: 'blog',
editUrl: ({ locale, blogDirPath, blogPath, permalink }) =>
`https://github.com/kuizuo/blog/edit/main/${blogDirPath}/${blogPath}`,
editLocalizedFiles: false,
blogDescription: '代码人生:编织技术与生活的博客之旅',
blogSidebarCount: 10,
blogSidebarTitle: '博文',
postsPerPage: 12,
showReadingTime: true,
readingTime: ({ content, frontMatter, defaultReadingTime }) =>
defaultReadingTime({ content, options: { wordsPerMinute: 300 } }),
feedOptions: {
type: 'all',
title: '愧怍',
description: 'feedId:41215011978385457+userId:41840354283324416',
copyright: `Copyright © ${new Date().getFullYear()} 愧怍 Built with Docusaurus.<p><a href="http://beian.miit.gov.cn/" class="footer_lin">${beian}</a></p>`,
},
},
],
async function tailwindcssPlugin() {
return {
name: 'docusaurus-tailwindcss',
configurePostCss(postcssOptions) {
// Appends TailwindCSS and AutoPrefixer.
postcssOptions.plugins.push(require('tailwindcss'))
postcssOptions.plugins.push(require('autoprefixer'))
return postcssOptions
},
}
},
async function injectMotto() {
return {
name: 'docusaurus-motto',
injectHtmlTags() {
return {
headTags: [
{
tagName: 'script',
innerHTML: `
(${function () {
console.log(
`%c Kz Blog %c https://github.com/kuizuo/blog`,
'color: #fff; margin: 1em 0; padding: 5px 0; background: #12affa;',
'margin: 1em 0; padding: 5px 0; background: #efefef;',
)
const motto = `
This Webisite Powered By Kz Blog.
Written by Docusaurus, Coding with Love.
--------
Love what you do and do what you love.
`
if (document.firstChild?.nodeType !== Node.COMMENT_NODE) {
document.prepend(document.createComment(motto))
}
}.toString()})();`,
},
],
}
},
}
},
],
headTags: [
{
tagName: 'meta',
attributes: {
name: 'description',
content: '愧怍的个人博客',
},
},
],
stylesheets: [
'https://cdn.jsdelivr.net/npm/[email protected]/lib/Normal/MiSans-Normal.min.css',
'https://cdn.jsdelivr.net/npm/[email protected]/lib/Normal/MiSans-Medium.min.css',
'https://cdn.jsdelivr.net/npm/[email protected]/lib/Normal/MiSans-Semibold.min.css',
],
i18n: {
defaultLocale: 'zh-CN',
locales: ['zh-CN'],
},
onBrokenLinks: 'warn',
}
export default config