-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
315 lines (303 loc) · 10.5 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
315 lines (303 loc) · 10.5 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
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
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'
// Helper functions for i18n support
function getSiteTitle() {
switch (process.env.DOCUSAURUS_CURRENT_LOCALE) {
case 'en':
return 'Flowing Docs'
default:
return '知流小记'
}
}
function getSiteTagline() {
switch (process.env.DOCUSAURUS_CURRENT_LOCALE) {
case 'en':
return 'Technical documentation and knowledge sharing'
default:
return '技术文档与知识分享'
}
}
function getSiteBio() {
switch (process.env.DOCUSAURUS_CURRENT_LOCALE) {
case 'en':
return 'Technical Documentation Engineer'
default:
return '技术内容创作者'
}
}
function getSiteDescription() {
switch (process.env.DOCUSAURUS_CURRENT_LOCALE) {
case 'en':
return 'Personal blog about technical documentation, content design, and user experience optimization.'
default:
return '关于技术文档、内容设计和用户体验优化的个人博客。'
}
}
function getBlogDescription() {
switch (process.env.DOCUSAURUS_CURRENT_LOCALE) {
case 'en':
return 'Exploring technical communication, sharing practices in technical writing, user experience, and knowledge dissemination.'
default:
return '探索技术传播,分享技术写作、用户体验与知识传播实践。'
}
}
function getBlogSidebarTitle() {
switch (process.env.DOCUSAURUS_CURRENT_LOCALE) {
case 'en':
return 'Recent Posts'
default:
return '最近文章'
}
}
const config: Config = {
title: getSiteTitle(), // Site title, shown in the browser tab and elsewhere
tagline: getSiteTagline(),
titleDelimiter: '-', // Delimiter used in the page title
url: 'https://flowingdocs.com', // Primary domain for your site
baseUrl: '/', // Base path where the site is served
trailingSlash: true, // Match Netlify's deployed URL shape and generated canonical URLs
favicon: 'img/favicon.ico', // Path to the favicon
organizationName: 'heywalter', // GitHub org or username
projectName: 'flowingdocs', // Project name (used in some URLs)
customFields: {
// Custom fields you want to expose
bio: getSiteBio(),
description: getSiteDescription(),
},
themeConfig: {
// Main theme configuration
image: 'img/logo.webp', // Default social share image
docs: {
sidebar: {
hideable: true, // Allows the docs sidebar to be collapsible
},
},
navbar: {
logo: {
alt: 'Flowing Docs', // Alt text for the logo
src: 'img/logo.webp',
srcDark: 'img/logo-dark.webp', // Logo for dark mode
},
hideOnScroll: true, // Hides the navbar while scrolling down
items: [
{ label: '博客', position: 'left', to: 'blog' },
{ label: '技术写作', position: 'left', to: 'docs' },
{ label: '项目案例', position: 'left', to: 'showcase' },
{
label: '更多',
position: 'right',
items: [
{ label: '关于我', to: 'about' },
{ label: '归档', to: 'blog/archive' },
],
},
{
type: 'localeDropdown',
position: 'right',
},
],
},
footer: {
style: 'dark', // Dark footer theme
links: [
{
title: '学习',
items: [
{ label: '博客', to: 'blog' },
{ label: '技术写作', to: 'docs' },
{ label: '实战项目', to: 'showcase' },
{ label: '归档', to: 'blog/archive' },
],
},
{
title: '社交媒体',
items: [
{ label: '关于我', to: '/about' },
{ label: 'GitHub', href: social.github.href },
{ label: '邮箱', href: social.email.href },
{ label: 'Discord', href: social.discord.href },
],
},
{
title: '更多',
items: [
// { label: '友链', 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: `Copyright © 2026 - ${new Date().getFullYear()} Walter | Built with Docusaurus | <a href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank" rel="noopener noreferrer" style="color: inherit; text-decoration: underline; text-decoration-style: dashed; text-underline-offset: 2px;">CC BY-NC 4.0</a>`,
},
algolia: {
appId: 'Y48LY06LB3', // Algolia application ID
apiKey: 'cc2a65f5d1b2ea93e357a20ca611e41f', // Public search API key
indexName: 'FlowingDocs', // Algolia index name
},
prism: {
theme: themes.oneLight, // Light code-block theme
darkTheme: themes.oneDark, // Dark code-block theme
additionalLanguages: ['bash', 'json', 'java', 'python', 'php', 'graphql', 'rust', 'toml', 'protobuf', 'diff'],
defaultLanguage: 'javascript',
magicComments: [
{
className: 'theme-code-block-highlighted-line',
line: 'highlight-next-line', // Highlights the next line
block: { start: 'highlight-start', end: 'highlight-end' },
},
{
className: 'code-block-error-line',
line: 'This will error', // Highlights the error line
},
],
},
giscus: {
repo: 'heywalter/FlowingDocs', // GitHub repo for Giscus
repoId: 'R_kgDOQ3IAyQ',
category: 'General',
categoryId: 'DIC_kwDOQ3IAyc4C02fd',
theme: 'light',
darkTheme: 'dark_dimmed',
} satisfies Partial<GiscusConfig>,
tableOfContents: {
minHeadingLevel: 2, // TOC starts from <h2>
maxHeadingLevel: 4, // TOC ends at <h4>
},
liveCodeBlock: {
playgroundPosition: 'top', // Positions the live editor above the code
},
zoom: {
selector: '.markdown :not(em) > img', // Enables zooming for images in Markdown
background: {
light: 'rgb(255, 255, 255)', // Light mode overlay color
dark: 'rgb(50, 50, 50)', // Dark mode overlay color
},
},
} satisfies Preset.ThemeConfig,
presets: [
[
'classic',
{
docs: {
path: 'docs', // Docs markdown directory
sidebarPath: 'sidebars.ts', // Sidebar config for docs
},
blog: false, // Disables the default blog
theme: {
customCss: ['./src/css/custom.css', './src/css/tweet-theme.css'], // Global CSS
},
sitemap: {
priority: 0.5, // Default priority for sitemap
ignorePatterns: ['/search', '/search/**', '/en/search', '/en/search/**'],
},
gtag: {
trackingID: 'G-TW8Q38798D', // Google Analytics Measurement ID
anonymizeIP: true, // Masks IP addresses in analytics
},
debug: process.env.NODE_ENV === 'development', // Enables debug mode in development
} satisfies Preset.Options,
],
],
plugins: [
'docusaurus-plugin-image-zoom', // Adds zoom functionality for images in Markdown
'@docusaurus/plugin-ideal-image', // Generates responsive images for multiple screen sizes
[
'@docusaurus/plugin-pwa', // Enables Progressive Web App features
{
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' },
],
},
],
[
'./src/plugin/plugin-content-blog', // Custom blog plugin
{
path: 'blog',
editUrl: ({ locale, blogDirPath, blogPath, permalink }) =>
`https://github.com/heywalter/flowingdocs/edit/main/${blogDirPath}/${blogPath}`, // "Edit this page" link
editLocalizedFiles: false,
blogDescription: getBlogDescription(),
blogSidebarCount: 10, // Number of recent posts in the sidebar
blogSidebarTitle: getBlogSidebarTitle(),
postsPerPage: 10,
showReadingTime: true,
readingTime: ({ content, frontMatter, defaultReadingTime }) =>
defaultReadingTime({ content, options: { wordsPerMinute: 300 } }),
feedOptions: {
type: 'all',
title: 'Walter',
description: 'feedId:41215011978385457+userId:41840354283324416',
copyright: `Copyright © ${new Date().getFullYear()} Walter Built with Docusaurus.`,
},
},
],
async function tailwindcssPlugin() {
return {
name: 'docusaurus-tailwindcss', // Integrates Tailwind CSS via PostCSS
configurePostCss(postcssOptions) {
postcssOptions.plugins.push(require('tailwindcss'))
postcssOptions.plugins.push(require('autoprefixer'))
return postcssOptions
},
}
},
async function injectMotto() {
// Injects a custom motto comment into the HTML
return {
name: 'docusaurus-motto',
injectHtmlTags() {
return {
headTags: [
{
tagName: 'script',
innerHTML: `
(${function () {
// HTML comment with brand details
const motto = `
This site is built with ❤️ using Docusaurus.
Authored by Walter, a Technical Documentation Engineer.
--------
MISSION: Transform complex technology into flowing knowledge.
--------
GitHub: https://github.com/heywalter/flowingdocs
--------
"Documentation's purpose is to let knowledge flow freely." — Walter
`;
if (document.firstChild?.nodeType !== Node.COMMENT_NODE) {
document.prepend(document.createComment(motto));
}
}.toString()})();`,
},
],
}
},
}
},
],
i18n: {
defaultLocale: 'zh-Hans', // Default site locale
locales: ['zh-Hans', 'en'], // Supported locales
localeConfigs: {
'en': {
label: 'English',
},
'zh-Hans': {
label: '简体中文',
},
},
},
onBrokenLinks: 'warn', // Logs a warning on broken links instead of throwing an error
}
export default config