forked from kuizuo/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docusaurus.config.ts
293 lines (288 loc) · 8.91 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
import path from 'node:path'
import type { Config } from '@docusaurus/types'
import type * as Preset from '@docusaurus/preset-classic'
import { themes } from 'prism-react-renderer'
// import { Social } from './src/components/SocialLinks'
import { GiscusConfig } from './src/components/Comment'
const beian = '浙ICP备2021039023号'
// const beian1 = '闽公网安备35021102000847号'
interface TypeCustomFields {
siteName?: string
siteNameEn?: string
email?: string
bio?: string
description?: string
}
const config: Config & {
customFields: TypeCustomFields
} = {
title: '蜗牛的小窝',
url: 'https://zpeng.cn',
baseUrl: '/',
favicon: 'img/favicon.ico',
// 指定 GitHub 上的组织名称。这个配置项主要用于部署网站到 GitHub Pages。
organizationName: 'chaseFunny',
projectName: 'blog',
// 全局自定义常量,可以通过 useDocusaurusContext 获取
customFields: {
avatar: 'https://zpeng.cn/img/logo.png',
siteName: '蜗牛快跑', // 站点主人名称
siteNameEn: 'snailRun', // 站点主人名称 english
email: 'snailrun160@gmail.com', // 站点主人邮箱
bio: '摸着石头过河,也愿意当好一块石头', // 站点主人 slogan
description:
'个人博客网站,记录自己编程成长的过程,分享编程知识,个人项目等等,该网站基于 React 驱动的静态网站生成器 Docusaurus 构建。',
slogan:
'我们摸着石头过河,我也希望成为一块石头,愿意当好一块石头,让别人摸着我们过去,所以创建这个博客,记录自己学习和生活的经验', // 站点描述
},
themeConfig: {
// announcementBar: {
// id: 'announcementBar-3',
// content: ``,
// },
metadata: [
{
name: 'keywords',
content: '蜗牛的小窝 | snailRun',
},
{
name: 'keywords',
content: 'blog, web, javascript, typescript, node, react, vue',
},
{
name: 'keywords',
content: '编程爱好者, Web开发者, JavaScript开发者, 小程序开发, 全栈开发',
},
],
docs: {
sidebar: {
hideable: true,
},
},
navbar: {
logo: {
alt: '蜗牛的小窝 | snailRun',
src: 'img/logo.webp',
srcDark: 'img/logo.webp',
},
// https://docusaurus.io/docs/api/themes/configuration#navbar-overview-hideOnScroll
hideOnScroll: true,
items: [
{
label: '博客',
position: 'right',
to: 'blog',
},
{
label: '项目',
position: 'right',
to: 'project',
},
{
label: '更多',
position: 'right',
items: [
{ label: '归档', to: 'blog/archive' },
{ label: '笔记', to: 'docs/skill' },
{ label: '资源', to: 'resource' },
{ label: '友链', to: 'friends' },
{ 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: 'https://github.com/chaseFunny' },
{ label: 'Twitter', href: 'https://twitter.com/haozhan05554957' },
{
label: '掘金',
href: 'https://juejin.cn/user/3606868169065389',
},
{ label: 'Discord', href: 'https://discord.gg/6T3WBtCP' },
],
},
{
title: '更多',
items: [
{ label: '友链', position: 'right', to: 'friends' },
{ label: '导航', position: 'right', to: 'resource' },
{
html: `
<a href="https://docusaurus.io/zh-CN/" target="_blank" rel="noreferrer noopener">
<img src="/img/buildwith.png" alt="build with docusaurus" width="120" height="50"/>
<a/>
`,
},
],
},
],
// <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>
copyright: `
<p style="margin-bottom: 0;"><a href="http://beian.miit.gov.cn/">${beian}</a></p>
<p>Copyright © ${new Date().getFullYear()} - PRESENT 蜗牛快跑 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',
],
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.scss'],
},
sitemap: {
priority: 0.5,
},
gtag: {
trackingID: 'G-S4SD5NXWXF',
anonymizeIP: true,
},
// debug: true,
} satisfies Preset.Options,
],
],
plugins: [
'docusaurus-plugin-image-zoom',
'docusaurus-plugin-sass',
path.resolve(__dirname, './src/plugin/plugin-baidu-tongji'),
path.resolve(__dirname, './src/plugin/plugin-baidu-push'),
[
path.resolve(__dirname, './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: 'Blogs',
postsPerPage: 10,
showReadingTime: true,
readingTime: ({ content, frontMatter, defaultReadingTime }) =>
defaultReadingTime({ content, options: { wordsPerMinute: 300 } }),
feedOptions: {
type: 'all',
title: process.env.NAME_CN,
copyright: `Copyright © ${new Date().getFullYear()} ${
process.env.NAME_CN
} Built with Docusaurus.<p><a href="http://beian.miit.gov.cn/" class="footer_lin">${beian}</a></p>`,
},
},
],
['@docusaurus/plugin-ideal-image', { disableInDev: false }],
[
'@docusaurus/plugin-pwa',
{
debug: true,
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: '#cc70ed' },
],
},
],
],
headTags: [
{
tagName: 'meta',
attributes: {
name: 'description',
content: process.env.NAME_CN + '的个人博客',
},
},
],
stylesheets: [
'https://cdn.jsdelivr.net/npm/misans@4.0.0/lib/Normal/MiSans-Normal.min.css',
'https://cdn.jsdelivr.net/npm/misans@4.0.0/lib/Normal/MiSans-Semibold.min.css',
],
i18n: {
defaultLocale: 'zh-CN',
locales: ['en', 'zh-CN'],
localeConfigs: {
en: {
htmlLang: 'en-GB',
},
},
},
}
export default config