forked from toss/slash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocusaurus.config.js
186 lines (171 loc) · 4.79 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
/* eslint-disable @typescript-eslint/no-var-requires */
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
const pnpapi = require('pnpapi');
const path = require('path');
require('@babel/register')({
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
ignore: [
path => {
const locator = pnpapi.findPackageLocator(path);
if (locator.name.startsWith('@toss/')) {
return false;
}
return true;
},
],
cache: true,
});
/** @type {import('@docusaurus/types').DocusaurusConfig} */
module.exports = {
title: 'Slash libraries',
tagline: 'A collection of TypeScript/JavaScript packages to build high-quality web services.',
url: 'https://slash.page/',
baseUrl: '/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
favicon: 'https://static.toss.im/tds/favicon/favicon.ico',
organizationName: 'toss',
projectName: 'slash',
i18n: {
path: './i18n',
defaultLocale: 'en',
locales: ['en', 'ko'],
localeConfigs: {
en: {
htmlLang: 'en-US',
},
ko: {
htmlLang: 'ko-KR',
},
},
},
themeConfig: {
navbar: {
title: 'Slash libraries',
logo: {
alt: 'Toss',
src: 'https://static.toss.im/icons/png/4x/icon-toss-logo.png',
},
items: [
{
type: 'doc',
docId: 'common/utils/README.i18n',
position: 'left',
label: 'Docs',
},
{
type: 'localeDropdown',
position: 'right',
},
{
href: 'https://github.com/toss/slash',
'aria-label': 'GitHub',
position: 'right',
className: 'navbar-github-link',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Docs',
items: [
{
label: 'Docs',
to: '/libraries/common/utils/README.i18n',
},
],
},
{
title: 'More',
items: [
{
label: 'GitHub',
href: 'https://github.com/toss/slash',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} Viva Republica, Inc.`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
algolia: {
appId: '5HUNJYWIP5',
apiKey: '7deeee6b4d09217c1dff5ff279561bf4',
siteId: 'f93364cf-0ae8-4398-b7bd-9a9f582c78ac',
indexName: 'slash',
branch: 'main',
contextualSearch: true,
},
},
plugins: [require.resolve('./scripts/webpack5-compat.js')],
presets: [
[
'@docusaurus/preset-classic',
{
theme: {
customCss: [require.resolve('./styles.css')],
},
docs: {
path: './docs',
routeBasePath: '/libraries',
sidebarPath: require.resolve('./sidebars.libraries.js'),
exclude: ['**/CHANGELOG.md'],
editUrl: ({ docPath, locale }) => {
const dirname = path.dirname(docPath);
const markdownFilename = getFilename(docPath);
const sourceFilename = getSourceFilename(markdownFilename, locale);
const editUrl = `${GITHUB_EDIT_PAGE_PREFIX}/packages/${dirname}/${sourceFilename}`;
return editUrl;
},
},
pages: {
path: 'pages',
routeBasePath: '/',
include: ['**/*.{js,jsx,ts,tsx,md,mdx,html}'],
mdxPageComponent: '@theme/MDXPage',
},
},
],
],
stylesheets: ['https://static.toss.im/tps/main.css', 'https://static.toss.im/tps/others.css'],
};
const GITHUB_EDIT_PAGE_PREFIX = 'https://github.com/toss/slash/edit/main';
/*
@example
input: twdk-next/src/components/TossNextApp/WebNavbarProvider/Navbar/type.generated.md
output: type.generated.md
*/
function getFilename(path) {
const names = path.split('/');
const filename = names[names.length - 1];
if (filename == null) {
throw new Error(`path가 올바르지 않습니다. ${path}`);
}
return filename;
}
function getSourceFilename(markdownFilename, locale) {
const isAutoGenerated = markdownFilename.endsWith('.tossdocs.md');
if (isAutoGenerated) {
return markdownFilename.replace('.tossdocs.md', '');
}
const isREADME = markdownFilename === 'README.i18n.md';
if (isREADME) {
if (locale === 'en') {
return markdownFilename.replace('.i18n.md', '.md');
} else {
return markdownFilename.replace('.i18n.md', `.${locale}.md`);
}
}
const isI18n = markdownFilename.endsWith('.i18n.md');
if (isI18n) {
return markdownFilename.replace('.i18n.md', `.${locale}.md`);
}
return markdownFilename;
}