-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
197 lines (182 loc) · 5.69 KB
/
Copy pathdocusaurus.config.js
File metadata and controls
197 lines (182 loc) · 5.69 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
// @ts-check
// `@type` JSDoc annotations allow editor autocompletion and type checking
// (when paired with `@ts-check`).
// See: https://docusaurus.io/docs/api/docusaurus-config
import {themes as prismThemes} from 'prism-react-renderer';
/* The released version is shown in the navbar and quoted in sample output on the
docs. Read it from the extension's latest GitHub release at build time so a
rebuild is all it takes to pick up a new release, rather than hunting down
every place a version is written down.
FALLBACK_VERSION keeps builds working when the API cannot be reached -- offline,
or rate limited, since this is an unauthenticated request. It is only a
backstop: bump it when it drifts too far from reality. */
const FALLBACK_VERSION = '0.3.0';
/* Stand-in written into the navbar config below and swapped for the real version
in createConfig, so the version lives in exactly one place. */
const VERSION_PLACEHOLDER = '__VERSION__';
async function latestDebuggerVersion() {
const url =
'https://api.github.com/repos/php-debugger/php-debugger/releases/latest';
try {
const response = await fetch(url, {
headers: {Accept: 'application/vnd.github+json'},
});
if (!response.ok) {
console.warn(
`[version] GitHub returned ${response.status}; falling back to ${FALLBACK_VERSION}`,
);
return FALLBACK_VERSION;
}
const {tag_name: tag} = await response.json();
return typeof tag === 'string' ? tag.replace(/^v/, '') : FALLBACK_VERSION;
} catch (error) {
console.warn(
`[version] could not reach GitHub (${error.message}); falling back to ${FALLBACK_VERSION}`,
);
return FALLBACK_VERSION;
}
}
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'PHP Debugger',
tagline: 'Zero-overhead debugging for PHP',
favicon: 'img/favicon.svg',
future: {
v4: true,
},
url: 'https://php-debugger.github.io',
// Overridable so PR preview builds can be served from a sub-path
baseUrl: process.env.BASE_URL || '/',
organizationName: 'php-debugger',
projectName: 'php-debugger.github.io',
onBrokenLinks: 'throw',
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
themes: [
[
'@easyops-cn/docusaurus-search-local',
/** @type {import('@easyops-cn/docusaurus-search-local').PluginOptions} */
({
hashed: true,
docsRouteBasePath: '/',
indexBlog: false,
indexPages: false,
highlightSearchTermsOnTargetPage: true,
}),
],
],
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
routeBasePath: '/',
sidebarPath: './sidebars.js',
},
blog: false,
theme: {
customCss: './src/css/custom.css',
},
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
colorMode: {
respectPrefersColorScheme: true,
},
navbar: {
logo: {
alt: 'PHP Debugger — zero-overhead debugging',
// The navbar is theme-inverted, so the white lockup goes on the
// light mode (dark bar) and the dark lockup on dark mode (light bar).
src: 'img/php-debugger-lockup-white.png',
srcDark: 'img/php-debugger-lockup.png',
},
items: [
{
to: '/getting-started/introduction',
label: 'Docs',
position: 'left',
},
{
to: '/user-guide/breakpoints',
label: 'Guide',
position: 'left',
},
{
to: '/reference/cli-options',
label: 'Reference',
position: 'left',
},
{
to: '/reference/debug-protocol',
label: 'API',
position: 'left',
},
{
href: 'https://github.com/php-debugger/php-debugger/releases',
label: 'Changelog',
position: 'left',
},
{
href: 'https://github.com/php-debugger/php-debugger',
label: 'GitHub',
position: 'left',
},
{
type: 'dropdown',
label: VERSION_PLACEHOLDER,
position: 'right',
items: [
{
label: `${VERSION_PLACEHOLDER} (latest)`,
href: 'https://github.com/php-debugger/php-debugger/releases/latest',
},
{
label: 'All releases',
href: 'https://github.com/php-debugger/php-debugger/releases',
},
],
},
],
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
additionalLanguages: ['php', 'ini', 'bash', 'powershell'],
},
}),
};
export default async function createConfig() {
const debuggerVersion = await latestDebuggerVersion();
const navbar = config.themeConfig.navbar;
return {
...config,
/* Available to pages via useDocusaurusContext().siteConfig.customFields. */
customFields: {...config.customFields, debuggerVersion},
themeConfig: {
...config.themeConfig,
navbar: {
...navbar,
items: navbar.items.map((item) =>
item.type === 'dropdown' && item.label === VERSION_PLACEHOLDER
? {
...item,
label: `v${debuggerVersion}`,
items: item.items.map((sub) =>
sub.label === `${VERSION_PLACEHOLDER} (latest)`
? {...sub, label: `v${debuggerVersion} (latest)`}
: sub,
),
}
: item,
),
},
},
};
}