-
Notifications
You must be signed in to change notification settings - Fork 6
/
docusaurus.config.js
288 lines (275 loc) · 9.14 KB
/
docusaurus.config.js
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
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
import fs from 'fs';
import { themes } from 'prism-react-renderer';
const lightCodeTheme = themes.github;
const darkCodeTheme = themes.dracula;
import remarkCmdRun from './remark/cmd-run/index.js';
import remarkMqttCodeBlock from './remark/mqtt-codeblock/index.js';
import tabBlocks from 'docusaurus-remark-plugin-tab-blocks';
const docsDir = process.env.DOCS_DIR || 'docs';
const domain = process.env.DOMAIN || 'https://thin-edge.github.io';
const baseUrl = process.env.BASE_URL || '/thin-edge.io/';
const includeCurrentVersion = process.env.INCLUDE_CURRENT_VERSION || 'true';
const substitutePlaceholders = (value, { bold = false } = {}) => {
if (bold) {
return value.replaceAll('%%te%%', '**thin-edge.io**');
}
return value.replaceAll('%%te%%', 'thin-edge.io');
};
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Thin-edge',
tagline: 'The open edge framework for lightweight IoT devices',
favicon: 'img/favicon.ico',
markdown: {
mermaid: true,
// Use preprocessor to replace global variables
preprocessor: ({ filePath, fileContent }) => {
return substitutePlaceholders(fileContent, { bold: true });
},
parseFrontMatter: async (params) => {
// Reuse the default parser
const result = await params.defaultParseFrontMatter(params);
// Replace text placeholders
if (result.frontMatter.description) {
result.frontMatter.description = substitutePlaceholders(
result.frontMatter.description,
{ bold: false },
);
}
return result;
},
},
themes: ['@docusaurus/theme-mermaid'],
// Set the production url of your site here
url: domain,
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl,
// Normalize trailing slashes
trailingSlash: true,
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'thin-edge', // Usually your GitHub org/user name.
projectName: 'thin-edge', // Usually your repo name.
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
// Ignore until links have been fixed, as broken anchors were only
// checked from docusaurus 3.1 onwards
// onBrokenAnchors: 'log',
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
clientModules: [],
headTags: [
// Add permissions-policy to prevent chrome warnings
// Example: Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'interest-cohort'.
// https://github.com/orgs/community/discussions/52356
{
tagName: 'meta',
attributes: {
'http-equiv': 'Permissions-Policy',
content: 'interest-cohort=()',
},
},
],
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
routeBasePath: '/', // Serve the docs at the site's root
sidebarPath: require.resolve('./sidebars.js'),
// Resolve the symlink to prevent any webpack caching problems
// https://github.com/facebook/docusaurus/issues/3272#issuecomment-879295056
path: fs.realpathSync(docsDir),
// Should the unreleased docs be published
includeCurrentVersion: includeCurrentVersion === 'true',
// Enable "edit this page" links for only the current/next version
editUrl: ({ version, docPath }) =>
version == 'current'
? `https://github.com/thin-edge/thin-edge.io/edit/main/docs/src/${docPath}`
: undefined,
beforeDefaultRemarkPlugins: [
[
remarkCmdRun,
{ showErrors: false, strict: false, logErrors: false },
],
],
remarkPlugins: [
[
remarkMqttCodeBlock,
{
sync: true,
converters: ['tedge', 'mosquitto', 'mqtt'],
formats: ['legacy'],
// Enable both v1 and legacy examples in code blocks
// formats: ['v1', 'legacy'],
// Group the formats together in the same tabs
// e.g. if using 'v1' and 'legacy' formats, both will appear under the 'tedge'
// table if grouping is enabled
groupTabs: true,
},
],
tabBlocks,
],
},
blog: false, // Optional: disable the blog plugin
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
}),
],
],
plugins: [
// @ts-ignore
async function redirectInitialRequestToPathWithTrailingSlash(
context,
options,
) {
return {
name: 'plugin-redirect-trailing-slash',
configureWebpack(_config, _isServer, _utils) {
return {
devServer: {
setupMiddlewares(middlewares, _devServer) {
middlewares.unshift({
name: 'redirect-trailing-slash',
middleware: (req, res, next) => {
// We need to add a prefix to the path to do URL manipulation
let url = new URL(`https://example.com${req.url}`);
if (
url.pathname.length > 0 &&
!url.pathname.endsWith('/')
) {
// Manipulate just the path to preserve stuff after the path (like # or ?)
url.pathname += '/';
res.redirect(
302,
url.toString().slice('https://example.com'.length),
);
} else {
next();
}
},
});
return middlewares;
},
},
};
},
};
},
'plugin-image-zoom',
[
'@docusaurus/plugin-client-redirects',
{
redirects: [
{
to: '/',
from: ['/html/'],
},
],
createRedirects(existingPath) {
if (existingPath.includes('/html/')) {
// Redirect from /html/team/X to /docs
return [existingPath.replace('/html/', '/')];
}
return undefined; // Return a falsy value: no redirect created
},
},
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
docs: {
sidebar: {
hideable: true,
},
},
announcementBar: {
id: 'official-1.0.0-release',
content:
'thin-edge.io has reached 1.0.0 🚀 Install thin-edge.io for production grade device management on your edge device',
},
// Replace with your project's social card
navbar: {
title: 'documentation',
logo: {
alt: 'thin-edge.io',
src: 'img/thin-edge-logo.svg',
// Use separate dark-mode logo as is more cross compatible
// in different browsers (chrome and safari)
srcDark: 'img/thin-edge-logo-dark.svg',
},
items: [
{
type: 'docsVersionDropdown',
position: 'right',
dropdownItemsAfter: [],
dropdownActiveClassDisabled: true,
},
{
href: 'https://github.com/thin-edge/thin-edge.io',
className: 'header-github-link',
'aria-label': 'GitHub repository',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Community',
items: [
{
label: 'Github',
href: 'https://github.com/thin-edge/thin-edge.io',
},
{
label: 'YouTube',
href: 'https://www.youtube.com/@thin_edge_io/featured',
},
{
label: 'Twitter',
href: 'https://twitter.com/thin_edge_io',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} Software AG.`,
},
metadata: [
{
name: 'keywords',
content: 'iot, edge, cumulocity-iot, azure-iot, aws-iot, iot-devices',
},
],
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ['bash', 'json', 'json5', 'log', 'toml', 'python'],
},
algolia: {
appId: 'VJGN4W1RS0',
apiKey: '090e96d679061a08763f67008de705c6',
indexName: 'thin-edge-io',
contextualSearch: true,
searchParameters: {},
},
imageZoom: {
// Allow disabling image zoom on specific images
// by surrounding them in `_![image](image.png)_` or <em></em>
selector: '.markdown :not(em) > img',
},
}),
};
module.exports = config;