-
Notifications
You must be signed in to change notification settings - Fork 31
/
docusaurus.config.ts
187 lines (175 loc) · 5.17 KB
/
docusaurus.config.ts
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
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import logger from '@docusaurus/logger';
import type * as Preset from '@docusaurus/preset-classic';
import remarkGithubAdmonitionsToDirectives from "remark-github-admonitions-to-directives";
import path from "path";
import YAML from "yaml";
import {existsSync, readFileSync} from "node:fs";
import {Tag} from "@docusaurus/utils";
type VariablesType = { [key: string]: string }
const variablesCache: { [key: string]: VariablesType } = {};
function getDocVariables(filePath: string): VariablesType|null {
let vars = variablesCache[filePath];
if (!vars) {
const px = filePath.match(/(^.+\/version-\d+\.\d+)\//)
if (!px) {
return null;
}
const vp = path.join(px[1], "variables.yml");
if (!existsSync(vp)) {
return null;
}
vars = YAML.parse(readFileSync(vp, "utf-8"))
variablesCache[filePath] = vars;
}
return vars
}
const config: Config = {
title: 'Telepresence',
tagline: 'Fast, local development for Kubernetes and OpenShift Microservices',
favicon: 'img/favicon.ico',
url: 'https://telepresence.io',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'telepresenceio', // Usually your GitHub org/username.
projectName: 'telepresence', // Usually your repo name.
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
// Even if you don't use internationalization, 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'],
},
presets: [
[
'classic',
{
docs: {
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl: ({docPath}) => {
return `https://github.com/telepresenceio/telepresence/tree/thallgren/add-documentation/docs/${docPath}`
},
exclude: ['**/release-notes.md', '**/README.md', '**/CONTRIBUTING.md'],
includeCurrentVersion: false,
beforeDefaultRemarkPlugins: [remarkGithubAdmonitionsToDirectives],
async sidebarItemsGenerator(args) {
const {docs, version: {versionName, contentPath}} = args;
type LinkItem = {
link?: string,
title: string,
items?: LinkItem[]
}
const idSet = new Set<string>(docs.map(doc => doc.id))
const linkToItem = ((linkItem: LinkItem) => {
if (linkItem.link) {
idSet.delete(linkItem.link);
return {
type: 'doc',
label: linkItem.title,
id: linkItem.link
}
}
return {
type: 'category',
label: linkItem.title,
items: linkItem.items.map(linkToItem)
}
})
const linksPath = path.join(contentPath, "doc-links.yml");
const items = YAML.parse(readFileSync(linksPath, "utf-8")).map(linkToItem);
for (const id of idSet) {
logger.warn(`"${path.join(versionName, 'doc-links.yml')}" has no entry for id "${id}"`);
}
return items;
},
},
theme: {
customCss: ['./src/css/custom.css', './src/css/telepresence.scss'],
},
} satisfies Preset.Options,
],
],
themeConfig: {
themeConfig: {
colorMode: {
respectPrefersColorScheme: true,
},
},
image: 'img/telepresence-social.jpg',
navbar: {
title: 'Telepresence',
logo: {
alt: 'Telepresence',
src: 'img/logo.svg',
},
items: [
{
type: 'doc',
position: 'left',
docId: 'quick-start',
label: 'Docs',
},
{
to: 'case-studies',
position: 'left',
label: 'Case studies',
},
{
to: 'community',
position: 'left',
label: 'Community',
},
{
to: 'about',
position: 'left',
label: 'About',
},
{
href: 'https://github.com/telepresenceio/telepresence',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
],
},
footer: {
copyright: `
<div>
The Linux Foundation® has registered trademarks and uses trademarks. For a list of trademarks of The Linux
Foundation, please see our <a href="https://www.linuxfoundation.org/legal/trademark-usage">Trademark Usage
page</a>
</div>
<div>
Built with
<a href="https://docusaurus.io/">Docusaurus
<img src="/img/docusaurus.png" alt="logo" style="height: 24px; vertical-align: middle"/>
</a>
</div>`,
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},
} satisfies Preset.ThemeConfig,
markdown: {
preprocessor({filePath, fileContent}) {
const vars = getDocVariables(filePath);
return vars? fileContent.replace(/\$(\S+)\$/g, (match, key) => {
const value = vars[key];
return (typeof value !== 'undefined') ? value : match;
}): fileContent;
},
},
plugins: ["docusaurus-plugin-sass", "./src/plugins/configure-svgo.ts"],
customFields: {
canonicalBaseUrl: "https://www.getambassador.io",
}
};
export default config;