Repository navigation
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
344 lines (325 loc) · 12.3 KB
/
Copy pathdocusaurus.config.js
File metadata and controls
344 lines (325 loc) · 12.3 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
// @ts-check
// `@type` JSDoc annotations allow editor autocompletion and type checking
// (when paired with `@ts-check`).
// There are various equivalent ways to declare your Docusaurus config.
// See: https://docusaurus.io/docs/api/docusaurus-config
import {themes as prismThemes} from 'prism-react-renderer';
import rehypeCleanForLlms, {
remarkFixMarkdownLinks,
} from './plugins/llms-txt/clean-markdown.js';
import {buildRouteRules, SECTION_ORDER} from './plugins/llms-txt/route-rules.js';
/**
* Prism themes with the code block background taken from the Care tokens
* (see --care-code-background in src/css/care-tokens.css), so code blocks
* sit on Care's neutral surfaces in both colour modes.
* @param {import('prism-react-renderer').PrismTheme} theme
* @returns {import('prism-react-renderer').PrismTheme}
*/
const withCareCodeBackground = (theme) => ({
...theme,
plain: {...theme.plain, backgroundColor: 'var(--care-code-background)'},
});
const EDIT_URL = 'https://github.com/ohcnetwork/docs/tree/main/';
const CURRENT_LOCALE = process.env.DOCUSAURUS_CURRENT_LOCALE ?? 'en';
const IS_DEFAULT_LOCALE = CURRENT_LOCALE === 'en';
/** @type {Array<{id: string, label: string, path: string, routeBasePath: string, sidebarPath: string, sidebarId: string}>} */
const CARE_DEPLOYMENTS = [
{
id: 'hmis',
label: 'HMIS',
path: 'deployments/hmis',
routeBasePath: 'deployments/hmis',
sidebarPath: './sidebarsHmis.js',
sidebarId: 'hmisSidebar',
},
{
id: 'palliative',
label: 'Palliative',
path: 'deployments/palliative',
routeBasePath: 'deployments/palliative',
sidebarPath: './sidebarsPalliative.js',
sidebarId: 'palliativeSidebar',
},
];
/**
* Cross-cutting guide sections that are not tied to a Care release, so they
* live outside the versioned docs as their own (unversioned) plugin instances.
* @type {Array<{id: string, label: string, path: string, routeBasePath: string, sidebarPath: string, sidebarId: string}>}
*/
const GUIDE_SECTIONS = [
{
id: 'contributing',
label: 'Contributing',
path: 'contributing',
routeBasePath: 'contributing',
sidebarPath: './sidebarsContributing.js',
sidebarId: 'contributingSidebar',
},
{
id: 'deployment',
label: 'Deployment',
path: 'deployment',
routeBasePath: 'deployment',
sidebarPath: './sidebarsDeployment.js',
sidebarId: 'deploymentSidebar',
},
];
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Care',
tagline: 'The open EMR for modern healthcare',
favicon: 'img/favicon.ico',
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
future: {
v4: true, // Improve compatibility with the upcoming Docusaurus v4
},
// GitHub Pages — https://ohcnetwork.github.io/docs/
url: 'https://docs.ohc.network/',
baseUrl: '/',
organizationName: 'ohcnetwork',
projectName: 'docs',
customFields: {
playbookDeployments: CARE_DEPLOYMENTS.map(({id, label, routeBasePath}) => ({
id,
label,
routeBasePath,
})),
},
clientModules: [require.resolve('./src/clientModules/devLocaleWarning.js')],
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
// Even if you don't use internationalization, 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', 'ml'],
localeConfigs: {
en: {
label: 'English',
},
ml: {
label: 'മലയാളം',
},
},
},
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
routeBasePath: '',
sidebarPath: './sidebars.js',
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl: EDIT_URL,
lastVersion: '3.1',
includeCurrentVersion: false,
versions: {
'3.1': {
label: '3.1',
},
'3.0': {
label: '3.0',
banner: 'unmaintained',
},
},
},
blog: {
showReadingTime: true,
feedOptions: {
type: ['rss', 'atom'],
xslt: true,
},
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl: EDIT_URL,
// Useful options to enforce blogging best practices
onInlineTags: 'warn',
onInlineAuthors: 'warn',
onUntruncatedBlogPosts: 'warn',
},
theme: {
customCss: './src/css/custom.css',
},
}),
],
],
plugins: [
...[...CARE_DEPLOYMENTS, ...GUIDE_SECTIONS].map(
(instance) =>
/** @type {import('@docusaurus/types').PluginConfig} */ ([
'@docusaurus/plugin-content-docs',
{
id: instance.id,
path: instance.path,
routeBasePath: instance.routeBasePath,
sidebarPath: instance.sidebarPath,
editUrl: EDIT_URL,
},
])
),
// Generates /llms.txt, /llms-full.txt and a Markdown copy of every page
// (the page's URL + ".md") so AI agents can read the Care docs without
// scraping HTML. See https://llmstxt.org
// Only for the default (en) locale — the plugin has no per-locale cache.
// Each link's description is the page's `description:` front matter;
// CI fails if a page has none (scripts/add_descriptions.py --check).
IS_DEFAULT_LOCALE &&
/** @type {import('@docusaurus/types').PluginConfig} */ ([
'@signalwire/docusaurus-plugin-llms-txt',
/** @type {import('@signalwire/docusaurus-plugin-llms-txt').PluginOptions} */
({
siteTitle: 'Care',
// The first paragraph becomes the llms.txt summary (a blockquote).
// The rest is printed after it as plain Markdown: the place llms.txt
// keeps for notes on how to use the files.
siteDescription: [
'Care is an open-source Electronic Medical Record (EMR) platform for managing patients, health workers, and hospitals. This is the documentation for Care 3.1, the current release.',
[
'How to use these docs:',
'',
'- Every page is also available as Markdown: add `.md` to its URL, for example https://docs.ohc.network/concepts/clinical/patient.md. The links below already point to the Markdown.',
'- https://docs.ohc.network/llms-full.txt has every page in one file. It is several megabytes, so fetch single pages when you can.',
'- Concepts answer "What is…?": what each Care resource is, in plain language, and who can access it.',
'- Flows answer "How do I…?": step-by-step tasks in the Care web app, with the permissions each task needs.',
'- References answer "How is it built?": the Django models, API resource specs, enums and validation behind each module.',
'- Apps are optional add-ons that a deployment can install. Playbooks combine flows for one kind of deployment. Deployment covers self-hosting Care, and Contributing covers developing it.',
'- Care 3.0 is no longer maintained. Its pages are under https://docs.ohc.network/3.0/ and are not listed here. Some pages are translated into Malayalam, under https://docs.ohc.network/ml/.',
'- Where these pages and the code disagree, the code is right. The repositories are listed under Optional.',
].join('\n'),
].join('\n\n'),
// Sections, their names and their order come from the sidebar's
// folders; see plugins/llms-txt/route-rules.js.
depth: 1,
enableDescriptions: true,
onRouteError: 'warn',
content: {
enableMarkdownFiles: true,
enableLlmsFullTxt: true,
relativePaths: false,
includeDocs: true,
includePages: true,
// Only index the latest released version; older versions stay out of
// llms.txt so agents don't quote outdated behaviour.
includeVersionedDocs: false,
// Generated category pages only repeat the links that llms.txt
// already lists under each section heading.
includeGeneratedIndex: false,
excludeRoutes: ['/search/**', '/ml/**', '/**/tags/**', '/**/category/**'],
routeRules: buildRouteRules(),
beforeDefaultRehypePlugins: [rehypeCleanForLlms],
remarkPlugins: [remarkFixMarkdownLinks],
// Unaligned tables: column padding was 15% of llms-full.txt.
remarkGfm: {tablePipeAlign: false},
},
includeOrder: SECTION_ORDER,
optionalLinks: [
{
title: 'Care (backend) repository',
url: 'https://github.com/ohcnetwork/care',
description: 'Django REST backend source code.',
},
{
title: 'Care frontend repository',
url: 'https://github.com/ohcnetwork/care_fe',
description: 'React frontend source code.',
},
{
title: 'Documentation repository',
url: 'https://github.com/ohcnetwork/docs',
description: 'Source of this documentation site.',
},
{
title: 'Context7',
url: 'https://context7.com/ohcnetwork/docs',
description:
'These docs, indexed for coding agents through the Context7 MCP server.',
},
],
}),
]),
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// Replace with your project's social card
image: 'img/ohc_banner.png',
metadata: [
// Proves to Algolia that we own docs.ohc.network (DocSearch). Keep it:
// Algolia may check it again after the first verification.
{name: 'algolia-site-verification', content: '91DF49878919E88B'},
],
colorMode: {
respectPrefersColorScheme: true,
},
// Algolia DocSearch — https://docusaurus.io/docs/search#using-algolia-docsearch
// The index is filled by the Algolia crawler (Docusaurus v3 template),
// configured in the Algolia dashboard, not in this repo. The key is a
// public read-only key, so it is safe to commit.
// Contextual search (on by default) limits results to the reader's
// locale and docs version, so the crawler must also crawl /ml/.
algolia: {
appId: 'XAY1YU3IX6',
apiKey: '47fceaac86df0ac1f9116c12feafaaad',
indexName: 'Documentation Website',
},
navbar: {
title: 'Docs',
logo: {
alt: 'Care Documentation Logo',
src: 'img/care_logo_on_light.svg',
srcDark: 'img/care_logo_on_dark.svg',
},
items: [
{
type: 'docSidebar',
sidebarId: 'tutorialSidebar',
position: 'left',
label: 'Documentation',
docsPluginId: 'default',
},
{
type: 'dropdown',
label: 'Playbooks',
position: 'left',
items: CARE_DEPLOYMENTS.map((deployment) => ({
type: 'docSidebar',
sidebarId: deployment.sidebarId,
label: deployment.label,
docsPluginId: deployment.id,
})),
},
...GUIDE_SECTIONS.map((section) => ({
type: 'docSidebar',
sidebarId: section.sidebarId,
position: 'left',
label: section.label,
docsPluginId: section.id,
})),
{
type: 'localeDropdown',
position: 'right',
},
{
type: 'docsVersionDropdown',
position: 'right',
dropdownActiveClassDisabled: true,
docsPluginId: 'default',
versions: ['3.1', '3.0'],
},
],
},
footer: {
links: [],
copyright: `Copyright © ${new Date().getFullYear()} Open Healthcare Network Foundation. Built with Docusaurus.`,
},
prism: {
theme: withCareCodeBackground(prismThemes.oneLight),
darkTheme: withCareCodeBackground(prismThemes.oneDark),
},
}),
};
export default config;