-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
158 lines (153 loc) · 5.37 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
158 lines (153 loc) · 5.37 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
import type { Config} from '@docusaurus/types'
import type { Options } from '@docusaurus/preset-classic'
const config: Config = {
title: 'Python Guide for JavaScript Engineers',
tagline: 'A free open-source eBook helping JavaScript developers master Python through practical code comparisons',
url: 'https://luckrnx09.com',
baseUrl: '/python-guide-for-javascript-engineers/',
trailingSlash: false,
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
favicon: 'img/favicon.ico',
projectName: 'python-guide-for-javascript-engineers',
// Custom fields (non-standard Docusaurus config)
customFields: {
image: 'img/book_cover.png',
},
presets: [
[
'classic',
({
docs: {
path: './docs',
sidebarPath: './sidebars.ts',
routeBasePath: '/',
sidebarCollapsed: false,
editUrl: 'https://github.com/luckrnx09/python-guide-for-javascript-engineers/edit/main/',
editLocalizedFiles: true,
},
blog: false,
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
sitemap: {
changefreq: 'weekly',
priority: 0.5,
lastmod: 'date',
}
}) as Options,
],
],
themeConfig: (
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
{
docs: {
sidebar: {
hideable: true,
},
},
colorMode: {
defaultMode: 'light',
disableSwitch: false,
respectPrefersColorScheme: true,
},
navbar: {
hideOnScroll: true,
title: 'Python Guide for JavaScript Engineers',
items: [
{
type: 'localeDropdown',
position: 'left',
},
{
label:'GitHub',
position: 'right',
href:'https://github.com/luckrnx09/python-guide-for-javascript-engineers'
},
],
logo: {
alt: 'Python Guide for JavaScript Engineers',
href: '/',
src: './img/favicon.ico'
},
},
metadata: [
{ name: 'keywords', content: 'Python, JavaScript, programming, tutorial, open source, ebook, learn Python, JS to Python' },
{ name: 'description', content: 'A free open-source eBook that helps JavaScript engineers quickly master Python through side-by-side code comparisons, practical examples, and hands-on projects.' },
{ name: 'author', content: 'luckrnx09' },
{ name: 'robots', content: 'index, follow' },
{ name: 'googlebot', content: 'index, follow' },
{ property: 'og:image', content: 'https://luckrnx09.com/python-guide-for-javascript-engineers/img/book_cover.png' },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:image', content: 'https://luckrnx09.com/python-guide-for-javascript-engineers/img/book_cover.png' },
],
}
),
plugins: [
// Structured data (JSON-LD) plugin
function structuredDataPlugin(_context: any, _options: any) {
return {
name: 'structured-data-plugin',
injectHtmlTags({ content }: any) {
const isZhCN = content?.permalink?.startsWith('/zh-cn/');
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'Book',
'name': isZhCN
? 'Python 指南 for JavaScript 工程师'
: 'Python Guide for JavaScript Engineers',
'description': isZhCN
? '一本免费的开源电子书,通过代码对比、实用示例和动手项目,帮助 JavaScript 工程师快速掌握 Python 语言。'
: 'A free open-source eBook that helps JavaScript engineers quickly master Python through side-by-side code comparisons, practical examples, and hands-on projects.',
'author': {
'@type': 'Person',
'name': 'luckrnx09',
'url': 'https://github.com/luckrnx09',
},
'url': 'https://luckrnx09.com/python-guide-for-javascript-engineers/',
'image': 'https://luckrnx09.com/python-guide-for-javascript-engineers/img/book_cover.png',
'inLanguage': isZhCN ? 'zh-CN' : 'en',
'license': 'https://opensource.org/licenses/MIT',
};
return {
headTags: `<script type="application/ld+json">${JSON.stringify(jsonLd)}</script>`,
};
},
};
},
// Microsoft Clarity analytics
function (_context: any, _options: any) {
return {
name: 'clarity-plugin',
injectHtmlTags() {
return {
postBodyTags: [`
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "k0fttuea53");
</script>
`],
};
},
};
},
[
require.resolve("@easyops-cn/docusaurus-search-local"),
{
hashed: true,
language: ["en", "zh"],
docsRouteBasePath: "/",
highlightSearchTermsOnTargetPage: true,
},
],
],
stylesheets: [],
i18n: {
defaultLocale: 'en',
locales: ['en', 'zh-cn'],
},
};
module.exports = config;