-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
107 lines (94 loc) · 3.43 KB
/
docusaurus.config.ts
File metadata and controls
107 lines (94 loc) · 3.43 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
import fs from 'node:fs';
import { themes as prismThemes } from 'prism-react-renderer';
import type { Config } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import { headerMenu } from './src/config/headerMenu';
import { presets } from './src/config/presets';
import { extractMarkdownTitleInfo } from './src/utils/index';
const config: Config = {
title: 'Hyperledger Identus',
tagline: 'Hyperledger Identus Docs',
url: 'https://hyperledger-identus.github.io/',
baseUrl: '/docs/',
onBrokenLinks: 'throw',
onBrokenAnchors: 'ignore',
favicon: 'img/favicon.ico',
organizationName: 'hyperledger-identus',
projectName: 'docs',
markdown: {
mermaid: true,
hooks: {
onBrokenMarkdownLinks: 'warn'
},
async parseFrontMatter(params) {
const result = await params.defaultParseFrontMatter(params);
// Only process typedoc-generated files that lack an explicit title
if (result.frontMatter.title || !params.filePath.includes('sdk-ts/docs/sdk/')) {
return result;
}
const { extractMarkdownTitleInfo } = await import('./src/utils/index.js');
const info = extractMarkdownTitleInfo(params.fileContent);
let title = info.title;
if (info.sidebar_label) {
result.frontMatter.sidebar_label = info.sidebar_label;
}
if (info.sidebar_position !== undefined) {
result.frontMatter.sidebar_position = info.sidebar_position;
}
// 2. For root README, fall back to package.json description
if (!title && params.filePath.endsWith('sdk/README.md')) {
try {
const pkg = JSON.parse(fs.readFileSync('sdk-ts/package.json', 'utf8'));
title = pkg.description;
} catch { /* ignore */ }
}
// 3. Bold project header (e.g. **@scope/pkg v1.0.0**)
if (!title) {
const boldMatch = params.fileContent.match(/^\*\*(.+?)\*\*$/m);
title = boldMatch?.[1]?.trim();
if (title) {
// Strip all backslash escapes typedoc proactively adds for the bold header fallback
// (since extractMarkdownTitleInfo already handles it for standard headings)
title = title.replace(/\\([^a-zA-Z0-9])/g, '$1');
}
}
if (title) {
result.frontMatter.title = title;
}
return result;
},
},
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
presets,
plugins: [
require.resolve('docusaurus-lunr-search'),
[
'@docusaurus/plugin-google-gtag',
{
trackingID: 'G-BLNS09BXBY',
anonymizeIP: true,
},
],
],
themeConfig: {
navbar: {
logo: {
alt: 'Identus logo',
src: 'img/identus-navbar-light.png',
srcDark: "img/identus-navbar-light.png",
},
items: headerMenu,
},
footer: {
copyright: `Hyperledger Identus CC BY 4.0`,
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},
} satisfies Preset.ThemeConfig,
};
export default config;