-
Notifications
You must be signed in to change notification settings - Fork 15
/
docusaurus.config.ts
327 lines (306 loc) · 16.1 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
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
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
const { themes } = require("prism-react-renderer");
const lightCodeTheme = themes.github;
const darkCodeTheme = themes.dracula;
const fs = require("fs");
const readline = require("readline");
const { gitlogPromise } = require("gitlog");
/** @type {import('@docusaurus/types').Config} */
const config: Config = {
title: "Ignite Cookbook for React Native",
tagline: "Cooking up some cool recipes in Ignite for React Native!",
url: "https://infinitered.github.io",
baseUrl: "/",
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.ico",
organizationName: "infinitered", // Usually your GitHub org/user name.
projectName: "ignite-cookbook", // Usually your repo name.
i18n: {
defaultLocale: "en",
locales: ["en"],
},
// Leaving this here for setting up a multi-doc instance for a community hub
// plugins: [
// [
// '@docusaurus/plugin-content-docs',
// /** @type {import('@docusaurus/plugin-content-docs').Options} */
// ({
// id: 'community',
// path: 'community',
// routeBasePath: 'community',
// sidebarPath: require.resolve('./sidebarsCommunity.js'),
// remarkPlugins: [npm2yarn],
// editCurrentVersion: true,
// showLastUpdateAuthor: true,
// showLastUpdateTime: true,
// }),
// ],
// ],
plugins: [
async function exampleCodeSnippets(_context, _options) {
return {
name: "example-code-snippets",
async loadContent() {
const snippets = [];
const docs = fs.readdirSync("docs/recipes");
// read each doc and extract code snippets
for await (const doc of docs) {
const docGitLog = await gitlogPromise({
repo: ".",
number: 1,
file: "docs/recipes/" + doc,
fields: ["authorDateRel"],
});
const lastUpdated = docGitLog?.[0]?.authorDateRel;
let author = ""; // Do we w÷nt to use the author from the doc or git log?
let title = "";
let publish_date = "";
const doc_name = doc;
const contents = [];
const input = fs.createReadStream("docs/recipes/" + doc);
const rl = readline.createInterface({
input,
crlfDelay: Infinity,
});
let recordContents = false;
for await (const line of rl) {
// extract author
if (!author && /author:/.test(line)) {
author = line.split(":")[1].trim();
continue;
}
// extract title
if (!title && /title:/.test(line)) {
title = line.split(":")[1].trim();
continue;
}
// extract publish_date
if (!publish_date && /publish_date:/.test(line)) {
publish_date = line.split(":")[1].trim();
continue;
}
// extract snippet contents
if (/```/.test(line)) {
recordContents = !recordContents;
if (!recordContents) contents.push("\n");
continue;
}
if (recordContents) contents.push(line + "\n");
}
// skip if no author or no contents
if (!author || !contents.length) continue;
snippets.push({
author,
content: contents.join(""),
lastUpdated,
title,
publish_date,
doc_name,
});
}
return snippets;
},
async contentLoaded({ content, actions }) {
const { setGlobalData } = actions;
setGlobalData({ snippets: content });
},
};
},
],
presets: [
[
"classic",
{
docs: {
path: "docs",
showLastUpdateAuthor: true,
showLastUpdateTime: true,
sidebarPath: require.resolve("./sidebars.js"),
},
blog: false,
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
gtag: {
trackingID: "G-1NP64B0XVM",
anonymizeIP: true,
},
} satisfies Preset.Options,
],
],
themeConfig:
{
// Disabling dark mode for now until we have a better dark mode theme
colorMode: {
defaultMode: "light",
disableSwitch: true,
},
navbar: {
hideOnScroll: true,
logo: {
alt: "React Native Cookbook Logo",
src: "img/logo.svg",
},
items: [
{
type: "search",
position: "right",
},
{
type: "doc",
docId: "intro",
position: "right",
html: '<div class="hover-underline">Recipes</div>',
},
{
position: "right",
html: '<div class="hover-underline">Ignite Boilerplate</div>',
to: "https://github.com/infinitered/ignite",
},
{
position: "right",
html: '<div class="hover-underline">Infinite Red</div>',
to: "https://infinite.red",
},
{
//override CSS only for this last item
style: { marginRight: "0px" },
type: "dropdown",
html: ` <div class="hover-underline">
Community
<img src="/img/caret-down.svg" alt="dropdown" class="icon" />
</div>
`,
position: "right",
items: [
{
html: ` <div>
<div class="dropdown-item hover-underline">
Slack community
<img src="/img/arrow.svg" alt="dropdown" class="icon" />
</div>
<div class="dropdown-item-description">
<p>Join a growing React Native community with 2,000 developers and counting.<p>
</div>
</div>
`,
to: "https://join.slack.com/t/infiniteredcommunity/shared_invite/zt-1e1gob8vn-pcFjKM~n1c~aXFsTnvHpdg",
},
{
html: ` <div>
<div class="dropdown-item hover-underline">
Submit an idea
<img src="/img/arrow.svg" alt="dropdown" class="icon" />
</div>
<div class="dropdown-item-description">
<p>Have an recipe idea for the cookbook? Contribute your ideas on GitHub!<p>
</div>
</div>
`,
to: "https://github.com/infinitered/ignite-cookbook/issues/new?assignees=&labels=new+recipe&template=recipe_idea.yml",
},
],
},
],
},
footer: {
copyright: 'From the team at <a href="https://infinite.red/" target="_blank" rel="noopener noreferrer" class="ir-footer-link">Infinite Red</a> <img width="32" height="32" src="/img/ir-mark.svg" alt="dropdown" class="ir-mark" />',
style: "dark",
links: [
{
title: "Community",
items: [
{
html: '<a href="https://join.slack.com/t/infiniteredcommunity/shared_invite/zt-1e1gob8vn-pcFjKM~n1c~aXFsTnvHpdg" target="_blank" rel="noopener noreferrer" class="footer__link-item">Slack Community<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://reactnativeradio.com/" target="_blank" rel="noopener noreferrer" class="footer__link-item">React Native Radio<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://reactnative.cc/" target="_blank" rel="noopener noreferrer" class="footer__link-item">React Native Newsletter<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
],
},
{
title: "Resources",
items: [
{
html: '<a href="https://github.com/infinitered/ignite-cookbook/issues" target="_blank" rel="noopener noreferrer" class="footer__link-item">Submit a Recipe<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://github.com/infinitered/ignite-cookbook" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub - Ignite Cookbook<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://github.com/infinitered/ignite" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub - Ignite Boilerplate<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://shift.infinite.red/" target="_blank" rel="noopener noreferrer" class="footer__link-item">RedShift Blog <div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://infinite.red/privacy-policy" target="_blank" rel="noopener noreferrer" class="footer__link-item">Privacy Policy<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
],
},
{
title: "Infinite Red",
items: [
{
html: '<a href="https://infinite.red/" target="_blank" rel="noopener noreferrer" class="footer__link-item">Website<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://docs.infinite.red/" target="_blank" rel="noopener noreferrer" class="footer__link-item">IR Docs<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
},
{
html: '<a href="https://chainreactconf.com" target="_blank" rel="noopener noreferrer" class="footer__link-item">Chain React Conf<div class="footer__links__custom"><svg width="18" height="18" viewBox="0 0 27 26" fill="none" xmlns="http://www.w3.org/2000/svg" class="" role="img"><g clip-path="url(#a)" stroke="#F4F2F1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7.312 18.781 19.245 6.85M19.245 17.986V6.849H8.108"></path></g><defs><clipPath id="a"><path fill="#fff" transform="rotate(45 6.534 16.072)" d="M0 0h18v18H0z"></path></clipPath></defs></svg></div></a>',
}
]
}
],
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: [
"bash",
"ruby",
"json",
"ejs",
"diff",
"markup-templating",
],
magicComments: [
// Remember to extend the default highlight class name as well!
{
className: "theme-code-block-highlighted-line",
line: "highlight-next-line",
block: { start: "highlight-start", end: "highlight-end" },
},
{
className: "code-block-error-line",
line: "error-line",
block: { start: "error-line-start", end: "error-line-end" },
},
{
className: "code-block-success-line",
line: "success-line",
block: { start: "success-line-start", end: "success-line-end" },
},
],
},
algolia: {
// The application ID provided by Algolia
appId: 'MFHD60DIB5',
// Public API key: it is safe to commit it
apiKey: '4e924e740d603ec90f106067754ccf50',
indexName: 'ignite-cookbook',
// Optional: Algolia search parameters
searchParameters: {},
// Optional: path for search page that enabled by default (`false` to disable it)
searchPagePath: 'search',
//... other Algolia params
},
} satisfies Preset.ThemeConfig,
};
module.exports = config;