forked from kuizuo/blog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
docusaurus.config.ts
321 lines (317 loc) · 8.61 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
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 config: Config = {
title: '路漫漫',
url: 'https://lummstudio.com',
baseUrl: '/',
favicon: 'img/favicon.ico',
organizationName: 'lumm',
projectName: 'blog',
customFields: {
bio: '道阻且长,行则将至',
description:
'是一个由路漫漫创建的个人博客,主要分享编程开发知识和项目,该网站基于 React 驱动的静态网站生成器 Docusaurus 构建。',
},
themeConfig: {
// announcementBar: {
// id: 'announcementBar-3',
// content: ``,
// },
image: 'img/home.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: 'SEO',
position: 'right',
to: 'docs/seo',
},
{
label: '更多',
position: 'right',
items: [
{ label: '归档', to: 'blog/archive' },
{ label: '笔记', to: 'docs/skill' },
{ label: '资源', to: 'resources' },
{ 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' }
],
},
{
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: '友链', position: 'right', to: 'friends' },
{ label: '导航', position: 'right', to: 'resources' },
{
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/>
`,
},
],
},
],
copyright: `<p>Copyright © 2023 - ${new Date().getFullYear()} lumm. | Built with Docusaurus.</p>`,
},
algolia: {
appId: '1NL5WSDYRP',
apiKey: 'dec3ee67f37cd7de6cf839f8d96d0e48',
indexName: 'lumm',
searchPagePath: false
},
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: 'lumm369/blog',
repoId: 'R_kgDOMd2IBw',
category: 'Announcements',
categoryId: 'DIC_kwDOMd2IB84ChWkq',
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'],
},
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/lumm369/blog/edit/main/${blogDirPath}/${blogPath}`,
editLocalizedFiles: false,
blogDescription: '代码人生:编织技术与生活的博客之旅',
blogSidebarCount: 10,
blogSidebarTitle: 'Blogs',
postsPerPage: 12,
showReadingTime: true,
readingTime: ({ content, frontMatter, defaultReadingTime }) =>
defaultReadingTime({ content, options: { wordsPerMinute: 300 } }),
feedOptions: {
type: 'all',
title: '路漫漫',
copyright: `Copyright © ${new Date().getFullYear()} 路漫漫 Built with Docusaurus.`,
},
},
],
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 Lumm Blog %c https://github.com/lumm369/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 Lumm 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-Semibold.min.css',
],
i18n: {
defaultLocale: 'zh-CN',
locales: ['en', 'zh-CN'],
localeConfigs: {
en: {
htmlLang: 'en-GB',
},
},
},
onBrokenLinks: 'warn',
}
export default config