-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
243 lines (230 loc) · 7.37 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
243 lines (230 loc) · 7.37 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
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import {GlobExcludeDefault} from '@docusaurus/utils';
import packages from './src/data/packages.json';
// Use Algolia DocSearch when configured, otherwise fall back to local search.
// Set ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, and ALGOLIA_INDEX_NAME env vars
// to activate Algolia. Apply at https://docsearch.algolia.com/apply/
const useAlgolia = Boolean(
process.env.ALGOLIA_APP_ID && process.env.ALGOLIA_SEARCH_API_KEY
);
const localSearchTheme: NonNullable<Config['themes']>[number] = [
'@easyops-cn/docusaurus-search-local',
{
hashed: true,
indexBlog: false,
docsRouteBasePath: '/docs',
highlightSearchTermsOnTargetPage: true,
searchResultLimits: 8,
searchBarShortcutHint: true,
},
];
// Slender version reference for the site footer. Reads the shared packages.json
// (same source as the docs-home Packages table) and renders one row per package:
// the package name + registry on the left, a live shields.io version pill on the
// right. CSS aligns the pills into a neat column (see custom.css).
const packageFooterItems = packages.map((pkg) => {
const isGem = pkg.registry === 'rubygems';
const registryShort = isGem ? 'gem' : 'npm';
const page = isGem
? `https://rubygems.org/gems/${pkg.name}`
: `https://www.npmjs.com/package/${pkg.name}`;
const badge = isGem
? `https://img.shields.io/gem/v/${pkg.name}?style=flat-square&label=`
: `https://img.shields.io/npm/v/${pkg.name}?style=flat-square&label=`;
return {
html: `<a class="footer__package" href="${page}" target="_blank" rel="noopener noreferrer"><span class="footer__package-name">${pkg.name} <span class="footer__package-registry">(${registryShort})</span></span><img class="footer__package-version" src="${badge}" alt="${pkg.name} ${registryShort} version" loading="lazy" /></a>`,
};
});
const config: Config = {
title: 'React on Rails',
tagline: 'Integrate React with Rails, including SSR, RSC, and production-grade docs.',
favicon: 'img/logo-mark.png',
future: {
v4: true,
},
url: 'https://reactonrails.com',
baseUrl: '/',
organizationName: 'shakacode',
projectName: 'reactonrails.com',
onBrokenLinks: 'warn',
markdown: {
mermaid: true,
hooks: {
onBrokenMarkdownLinks: 'warn',
},
},
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
themes: [...(useAlgolia ? [] : [localSearchTheme]), '@docusaurus/theme-mermaid'],
presets: [
[
'classic',
{
docs: {
sidebarPath: './sidebars.ts',
routeBasePath: 'docs',
exclude: [...GlobExcludeDefault, '**/planning/**'],
editUrl: ({docPath}) => {
const root = 'https://github.com/shakacode/react_on_rails/tree/main/docs/';
if (docPath === 'README.md') {
return `${root}README.md`;
}
if (docPath.startsWith('pro/')) {
return `${root}${docPath}`;
}
return `${root}oss/${docPath}`;
},
},
blog: false,
theme: {
customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],
themeConfig: {
metadata: [
{
name: 'algolia-site-verification',
content: 'B2E2910709F2DC66',
},
],
image: 'img/react-on-rails-social-card.png',
colorMode: {
respectPrefersColorScheme: true,
},
announcementBar: {
id: 'consultation_cta',
content:
'Want expert advice on your React on Rails setup? <a href="https://meetings.hubspot.com/justingordon/30-minute-consultation">Book a complimentary 30-minute assessment</a> with the ShakaCode team.',
isCloseable: true,
},
navbar: {
title: 'React on Rails',
logo: {
alt: 'React on Rails Logo',
src: 'img/logo-mark.png',
width: 40,
height: 40,
},
items: [
{
type: 'docSidebar',
sidebarId: 'docsSidebar',
position: 'left',
label: 'Docs',
},
{to: '/examples', label: 'Examples', position: 'left'},
{to: '/pro', label: 'React on Rails Pro', position: 'left'},
{
href: 'https://www.shakacode.com/contact/',
label: 'Get Expert Help',
position: 'right',
className: 'navbar-cta',
},
{
href: 'https://github.com/shakacode/react_on_rails',
label: 'GitHub',
position: 'right',
},
{
href: 'https://github.com/sponsors/shakacode',
label: 'Sponsor',
position: 'right',
},
],
},
footer: {
style: 'light',
links: [
{
title: 'Docs',
items: [
{
label: 'Documentation Guide',
to: '/docs',
},
{label: 'Create a New App', to: '/docs/getting-started/create-react-on-rails-app'},
{
label: 'Install into Existing Rails App',
to: '/docs/getting-started/existing-rails-app',
},
{label: 'Quick Start', to: '/docs/getting-started/quick-start'},
{label: 'Compare OSS and Pro', to: '/docs/getting-started/oss-vs-pro'},
{label: 'Upgrade to Pro', to: '/docs/pro/upgrading-to-pro'},
{label: 'React on Rails Pro', to: '/docs/pro'},
],
},
{
title: 'Resources',
items: [
{
label: 'Examples',
to: '/examples',
},
{
label: 'Discussions',
href: 'https://github.com/shakacode/react_on_rails/discussions',
},
{
label: 'Changelog',
to: '/docs/upgrading/changelog',
},
{
label: 'ShakaCode',
href: 'https://www.shakacode.com',
},
{
label: 'Book a Complimentary Assessment',
href: 'https://meetings.hubspot.com/justingordon/30-minute-consultation',
},
],
},
{
title: 'More',
items: [
{
label: 'React on Rails Pro',
to: '/pro',
},
{
label: 'Pro Pricing & Sign Up',
href: 'https://pro.reactonrails.com/',
},
{
label: 'GitHub',
href: 'https://github.com/shakacode/react_on_rails',
},
{
label: 'Sponsor',
href: 'https://github.com/sponsors/shakacode',
},
],
},
{
title: 'Packages',
items: packageFooterItems,
},
],
copyright: `Copyright © ${new Date().getFullYear()} ShakaCode. Built with Docusaurus.`,
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.vsDark,
additionalLanguages: ['ruby', 'markup-templating', 'erb', 'diff', 'haml', 'bash', 'regex', 'ignore'],
},
...(useAlgolia && {
algolia: {
appId: process.env.ALGOLIA_APP_ID!,
apiKey: process.env.ALGOLIA_SEARCH_API_KEY!,
indexName: process.env.ALGOLIA_INDEX_NAME || 'reactonrails',
contextualSearch: true,
},
}),
} satisfies Preset.ThemeConfig,
};
export default config;