Repository navigation
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
174 lines (156 loc) · 4.15 KB
/
Copy pathdocusaurus.config.js
File metadata and controls
174 lines (156 loc) · 4.15 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
// @ts-check
const {themes} = require("prism-react-renderer");
function normalizeBaseUrl(value) {
if (!value) {
return "/";
}
const trimmed = value.trim();
return trimmed === "/" ? "/" : `/${trimmed.replace(/^\/+|\/+$/g, "")}/`;
}
const githubRepository = process.env.GITHUB_REPOSITORY || "";
const [githubOwner, githubProject] = githubRepository.split("/", 2);
const isGitHubPagesRoot =
githubOwner &&
githubProject &&
`${githubOwner}.github.io`.toLowerCase() === githubProject.toLowerCase();
const netlifySiteUrl =
process.env.NETLIFY === "true"
? process.env.URL || process.env.DEPLOY_PRIME_URL
: "";
const siteUrl =
process.env.SITE_URL ||
netlifySiteUrl ||
(githubOwner
? `https://${githubOwner}.github.io`
: "https://docs.neoforged.net");
const siteBaseUrl = normalizeBaseUrl(
process.env.SITE_BASE_URL ||
(githubProject && !isGitHubPagesRoot ? `/${githubProject}/` : "/"),
);
const siteName = "Neoforge 26.1 模组开发教程";
/** @type {import('@docusaurus/types').Config} */
const config = {
title: siteName,
tagline: siteName,
favicon: "img/favicon-48.png",
url: siteUrl,
baseUrl: siteBaseUrl,
trailingSlash: true,
organizationName: githubOwner || "neoforged",
projectName: githubProject || "documentation",
// 译文和教程仍在补充,暂时不因未完成内容中的链接中止构建。
onBrokenLinks: "ignore",
onBrokenAnchors: "ignore",
i18n: {
defaultLocale: "zh-Hans",
locales: ["zh-Hans"],
},
headTags: [
{
tagName: "script",
attributes: {type: "application/ld+json"},
innerHTML: JSON.stringify({
"@context": "https://schema.org",
"@type": "WebSite",
name: siteName,
inLanguage: "zh-CN",
url: new URL(siteBaseUrl, siteUrl).href,
}),
},
],
presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
path: "./docs",
routeBasePath: "docs",
sidebarPath: require.resolve("./sidebars.js"),
exclude: ["README.md", "INDEX.md"],
},
blog: false,
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
}),
],
],
plugins: [
[
"@docusaurus/plugin-content-docs",
{
id: "tutorial",
path: "./tutorial",
routeBasePath: "tutorial",
sidebarPath: require.resolve("./tutorial-sidebar.js"),
exclude: ["README.md", "OUTLINE.md"],
},
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
metadata: [
{
name: "description",
content:
"面向零基础开发者的 Neoforge 26.1 中文模组开发教程,涵盖开发环境配置、物品与方块注册、资源与模型、数据生成、事件系统和常用 API,提供循序渐进的实践步骤与中文参考资料。",
},
{
name: "application-name",
content: siteName,
},
{
property: "og:site_name",
content: siteName,
},
],
colorMode: {
respectPrefersColorScheme: true,
},
navbar: {
title: siteName,
items: [
{
type: "docSidebar",
sidebarId: "tutorialSidebar",
docsPluginId: "tutorial",
position: "left",
label: "教程",
},
{
type: "docSidebar",
sidebarId: "docsSidebar",
position: "left",
label: "中文文档",
},
],
},
prism: {
theme: themes.oneLight,
darkTheme: themes.vsDark,
additionalLanguages: [
"java",
"gradle",
"toml",
"groovy",
"kotlin",
"javascript",
"json",
"json5",
"properties",
],
},
}),
markdown: {
mermaid: true,
preprocessor: ({fileContent}) =>
fileContent.replaceAll("<=", "<="),
hooks: {
onBrokenMarkdownLinks: "ignore",
},
},
themes: ["@docusaurus/theme-mermaid"],
};
module.exports = config;