Repository navigation
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
347 lines (320 loc) · 11.2 KB
/
Copy pathdocusaurus.config.js
File metadata and controls
347 lines (320 loc) · 11.2 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
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const { themes } = require('prism-react-renderer');
const schemaVersions = require('./schema_versions.json');
const { splitReleases } = require('./src/releaseCalendar');
const releaseCalendar = require('./static/release-calendar.json');
// both modes use the dark palette — code blocks are forced dark bg in
// light mode too (see custom.css), so light-theme token colors fail contrast.
const codeTheme = themes.nightOwl;
const defaultUrl = 'https://docs.overturemaps.org';
const defaultBaseUrl = '/';
// SCHEMA_PREVIEW is set by the schema repo's CI when building a PR preview of the
// schema reference docs (see OvertureMaps/schema/.github/workflows/schema-pr-preview.yml).
// When true, only the schema reference section is built — blog, community pages, and
// navbar items unrelated to the schema are excluded to keep the preview fast and focused.
const isSchemaPreview = process.env.SCHEMA_PREVIEW === 'true';
function getFromEnvironment(variableName, defaultValue) {
const environmentValue = process.env[variableName];
return environmentValue ? environmentValue : defaultValue;
}
function getLatestOvertureRelease() {
// Used only when the STAC catalog is unreachable: the newest release in release-calendar.json.
const fallback = splitReleases(releaseCalendar.releases).shipped[0].dataVersion;
try {
const { execSync } = require('child_process');
const response = execSync('curl -s https://stac.overturemaps.org/catalog.json', {
encoding: 'utf-8',
timeout: 10000,
});
const catalog = JSON.parse(response);
return catalog.latest || fallback;
} catch (error) {
console.warn(error);
console.warn('Failed to fetch latest Overture release, using fallback:', fallback);
return fallback;
}
}
const latestOvertureRelease = getLatestOvertureRelease();
// Dates with a release notes post (blog/YYYY-MM-DD-release-notes.mdx). The release
// history table links only to posts that exist; the blog isn't built for schema previews.
const releaseNoteDates = isSchemaPreview
? []
: require('fs')
.readdirSync('blog')
.flatMap((file) => /^(\d{4}-\d{2}-\d{2})-release-notes\.mdx?$/.exec(file)?.[1] ?? []);
// Schema reference docs are a separate, versioned docs instance (see README
// "Schema Reference"). Only released schema tags are published: snapshots live
// in schema_versioned_docs/, the newest is served at /schema/ and older ones at
// /schema/<tag>/. The `current` version (schema/reference, generated from a
// schema branch by the schema repo's CI) is built only for schema PR previews.
// Released versions are stable, so suppress the default "unmaintained" banner.
// The instance can't live under docs/: nested docs instances get their MDX
// compiled twice.
const [latestSchemaVersion] = schemaVersions;
const latestSchemaDocsDir = `schema_versioned_docs/version-${latestSchemaVersion}`;
const schemaVersionOptions = isSchemaPreview
? {
includeCurrentVersion: true,
onlyIncludeVersions: ['current'],
versions: { current: { label: 'preview', path: '' } },
}
: {
includeCurrentVersion: false,
lastVersion: latestSchemaVersion,
versions: Object.fromEntries(
schemaVersions.map((v) => [
v,
{ label: v, banner: 'none', path: v === latestSchemaVersion ? '' : v },
])
),
};
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Overture Documentation',
tagline: '',
favicon: 'img/favicon.png',
customFields: {
overtureRelease: latestOvertureRelease,
releaseNoteDates,
pmtiles_path: 'https://tiles.overturemaps.org/' + latestOvertureRelease,
},
future: {
v4: true,
faster: {
swcJsLoader: true,
swcJsMinimizer: true,
swcHtmlMinimizer: true,
lightningCssMinimizer: true,
rspackBundler: true,
},
},
// Set the production url of your site here
url: getFromEnvironment('DOCUSAURUS_URL', defaultUrl),
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: getFromEnvironment('DOCUSAURUS_BASE_URL', defaultBaseUrl),
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'OvertureMaps', // Usually your GitHub org/user name.
projectName: 'docs', // Usually your repo name.
onBrokenLinks: 'throw',
onBrokenAnchors: 'throw',
onDuplicateRoutes: 'throw',
markdown: {
hooks: {
onBrokenMarkdownLinks: 'throw',
},
},
trailingSlash: true,
// 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'],
},
themes: [],
plugins: [
[
'@docusaurus/plugin-content-docs',
/** @type {import('@docusaurus/plugin-content-docs').Options} */
({
id: 'schema',
path: 'schema',
routeBasePath: 'schema',
sidebarPath: require.resolve('./sidebars-schema.js'),
showLastUpdateTime: true,
breadcrumbs: false,
...schemaVersionOptions,
}),
],
...(isSchemaPreview
? []
: [
[
'@docusaurus/plugin-client-redirects',
{
redirects: [
{
from: '/releases',
to: '/release-calendar/',
},
// Release notes posts used custom slugs (/blog/<data version>/) before they
// were renamed to the standard blog/YYYY-MM-DD-release-notes.mdx.
...[
'2024-07-22',
'2024-08-20',
'2024-09-18',
'2024-10-23',
'2024-11-13',
'2024-12-18',
].map((date) => ({
from: `/blog/${date}.0`,
to: `/blog/${date.replaceAll('-', '/')}/release-notes/`,
})),
{
// Renamed from "Taxonomy Browser" to "Taxonomy Explorer".
from: '/guides/places/taxonomy-browser',
to: '/guides/places/taxonomy-explorer/',
},
],
},
],
[
'@docusaurus/plugin-content-pages',
{
id: 'community',
path: './community',
routeBasePath: 'community',
showLastUpdateTime: true,
},
],
[
'docusaurus-plugin-llms',
{
generateLLMsTxt: true,
generateLLMsFullTxt: true,
// Newest schema version only; older snapshots are excluded
docsDir: [
{ path: 'docs', routeBasePath: '/', label: 'Docs' },
{ path: latestSchemaDocsDir, routeBasePath: 'schema', label: 'Schema Reference' },
],
excludeImports: true,
removeDuplicateHeadings: true,
includeBlog: true,
// Order docs from most introductory to most detailed
includeOrder: [
'getting-data/**',
'guides/**',
`${latestSchemaDocsDir}/**`,
'examples/**',
'gers/**',
],
includeUnmatchedLast: true,
// Playground pages are interactive components, not useful for LLMs
ignoreFiles: ['playground/**'],
// Schema-only subset for LLMs focused on the data model
customLLMFiles: [
{
filename: 'llms-schema.txt',
includePatterns: [`${latestSchemaDocsDir}/**`],
fullContent: true,
title: 'Overture Maps Schema Reference',
description:
'Schema reference for all Overture Maps data types: addresses, base, buildings, divisions, places, and transportation.',
},
],
},
],
]),
],
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve('./sidebars.js'),
routeBasePath: '/',
showLastUpdateTime: true,
breadcrumbs: false,
},
blog: isSchemaPreview
? false
: {
blogTitle: 'Overture Engineering Blog',
blogDescription: 'Building Overture Maps',
blogSidebarTitle: 'Posts from the Overture engineering team',
blogSidebarCount: 20,
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
gtag:
process.env.DOCUSAURUS_URL === defaultUrl
? {
trackingID: 'G-JBXK7VCHV4',
anonymizeIP: true,
}
: false,
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
docs: {
sidebar: {
hideable: true,
},
},
image: 'img/omf_logo_transparent.png',
navbar: {
title: 'Overture Maps',
logo: {
alt: 'Overture Maps Foundation Logo',
src: 'img/omf_logo_transparent.png',
href: 'https://overturemaps.org',
},
items: [
{
to: '/',
position: 'left',
label: 'Docs',
},
...(!isSchemaPreview
? [
{
to: 'blog',
label: 'Blog',
position: 'left',
},
{
to: 'community',
label: 'Community',
position: 'left',
},
{
type: 'docsVersionDropdown',
docsPluginId: 'schema',
position: 'right',
// Only shown on schema pages; see custom.css
className: 'schema-version-dropdown',
},
]
: []),
{
to: 'https://github.com/OvertureMaps/docs',
position: 'right',
target: '_blank',
className: 'github-link',
'aria-label': 'View source on GitHub',
},
],
},
algolia: {
appId: 'MK8X1051PQ',
//this is the public search API key; ok to commit
apiKey: '29fe3f5bc0dabfade01c016695919c8d',
indexName: 'overturemaps',
contextualSearch: true,
// Optional: Algolia search parameters
searchParameters: {},
// Optional: path for search page that enabled by default (`false` to disable it)
searchPagePath: 'search',
// Optional: whether the insights feature is enabled or not on Docsearch (`false` by default)
insights: false,
},
footer: {
style: 'dark',
copyright: `Copyright © ${new Date().getFullYear()} Overture Maps Foundation.`,
},
prism: {
theme: codeTheme,
darkTheme: codeTheme,
additionalLanguages: ['bash', 'diff', 'json', 'sql', 'python'],
},
}),
};
module.exports = config;