@sp-days-framework/create-sp-days 1.0.4 → 1.1.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/bin/index.js +2 -0
- package/docs/advanced-config.mdx +387 -0
- package/docs/changelog.mdx +106 -0
- package/docs/index.mdx +205 -0
- package/docs/install.mdx +199 -0
- package/docs/sidebar-sections.mdx +268 -0
- package/docs/sp-days-plugin-color-light.svg +53 -0
- package/lib/.tsbuildinfo +1 -0
- package/lib/.tsbuildinfo-build +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +36 -7
- package/package.json +31 -7
- package/publish-package-docs.js +12 -0
- package/templates/addon-resources/resources/api-reference.mdx +132 -0
- package/templates/addon-resources/resources/best-practice.mdx +407 -0
- package/templates/addon-resources/resources/cheat-sheet.mdx +120 -0
- package/templates/addon-resources/resources/cli-reference.mdx +280 -0
- package/templates/addon-resources/resources/configuration-guide.mdx +211 -0
- package/templates/addon-resources/resources/environment-setup.mdx +317 -0
- package/templates/addon-resources/resources/faq.mdx +146 -0
- package/templates/addon-resources/resources/glossary.mdx +78 -0
- package/templates/addon-resources/resources/index.mdx +67 -16
- package/templates/addon-resources/resources/quick-start.mdx +193 -0
- package/templates/addon-resources/resources/troubleshooting.mdx +263 -0
- package/templates/addon-resources/resources/useful-links.mdx +61 -0
- package/templates/page-course/README.md +62 -0
- package/templates/page-course/docusaurus.config.ts +59 -11
- package/templates/page-course/package.json +12 -2
- package/templates/page-course/sidebarSections.js +118 -0
- package/tsconfig.base.client.json +10 -0
- package/tsconfig.base.json +71 -0
- package/tsconfig.build.json +9 -0
- package/sp-days-framework-create-sp-days-1.0.3.tgz +0 -0
- package/templates/addon-resources/resources/interactive-tasks/creating-tasks.mdx +0 -254
- package/templates/addon-resources/resources/interactive-tasks/examples/_category_.yml +0 -3
- package/templates/addon-resources/resources/interactive-tasks/examples/advanced-usage.mdx +0 -304
- package/templates/addon-resources/resources/interactive-tasks/examples/basic-usage.mdx +0 -128
- package/templates/addon-resources/resources/interactive-tasks/index.mdx +0 -93
- package/templates/addon-resources/resources/interactive-tasks/setup/advanced-configuration.mdx +0 -273
- package/templates/addon-resources/resources/interactive-tasks/setup/index.mdx +0 -120
- package/templates/addon-resources/resources/interactive-tasks/task-progression.mdx +0 -140
- package/templates/addon-resources/resources/slidev-integration/index.mdx +0 -106
- package/templates/addon-resources/resources/slidev-integration/setup/advanced-configuration.mdx +0 -144
- package/templates/addon-resources/resources/slidev-integration/setup/index.mdx +0 -200
- package/templates/addon-resources/resources/sykehuspartner-theme/index.mdx +0 -105
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/_category_.yml +0 -2
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/content/_category_.yml +0 -2
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/content/center.mdx +0 -33
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/content/default.mdx +0 -59
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/content/full.mdx +0 -49
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/image/_category_.yml +0 -2
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/image/image-left.mdx +0 -37
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/image/image-right.mdx +0 -37
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/image/image.mdx +0 -56
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/multi-column/_category_.yml +0 -2
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/multi-column/three-cols-header.mdx +0 -49
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/multi-column/three-cols.mdx +0 -47
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/multi-column/two-cols-header.mdx +0 -43
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/multi-column/two-cols.mdx +0 -38
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/section/_category_.yml +0 -2
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/section/cover.mdx +0 -43
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/section/end.mdx +0 -33
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/section/intro.mdx +0 -49
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/section/section.mdx +0 -41
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/special/_category_.yml +0 -2
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/special/about-me.mdx +0 -92
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/special/fact.mdx +0 -47
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/special/quote.mdx +0 -27
- package/templates/addon-resources/resources/sykehuspartner-theme/layouts/special/statement.mdx +0 -28
- package/templates/addon-resources/resources/sykehuspartner-theme/setup/advanced-configuration.mdx +0 -79
- package/templates/addon-resources/resources/sykehuspartner-theme/setup/index.mdx +0 -104
- package/templates/addon-resources/resources/sykehuspartner-theme/syntax-and-icons.mdx +0 -89
- package/templates/addon-slidev/package.json +0 -54
package/lib/index.js
CHANGED
|
@@ -155,16 +155,20 @@ async function getProjectConfig(siteName, cliOptions) {
|
|
|
155
155
|
// Get addon selections
|
|
156
156
|
let addonSlidev;
|
|
157
157
|
let addonResources;
|
|
158
|
+
let includePackageDocs;
|
|
158
159
|
if (hasCliConfig) {
|
|
159
160
|
// If using CLI mode for config, also use CLI mode for addons (default to false if not specified)
|
|
160
161
|
addonSlidev = cliOptions.addonSlidev ?? false;
|
|
161
162
|
addonResources = cliOptions.addonResources ?? false;
|
|
163
|
+
includePackageDocs = cliOptions.includePackageDocs ?? false;
|
|
162
164
|
}
|
|
163
165
|
else if (cliOptions.addonSlidev !== undefined ||
|
|
164
|
-
cliOptions.addonResources !== undefined
|
|
166
|
+
cliOptions.addonResources !== undefined ||
|
|
167
|
+
cliOptions.includePackageDocs !== undefined) {
|
|
165
168
|
// Addon flags provided without config flags
|
|
166
169
|
addonSlidev = cliOptions.addonSlidev ?? false;
|
|
167
170
|
addonResources = cliOptions.addonResources ?? false;
|
|
171
|
+
includePackageDocs = cliOptions.includePackageDocs ?? false;
|
|
168
172
|
}
|
|
169
173
|
else {
|
|
170
174
|
// Interactive mode - prompt with default yes
|
|
@@ -181,6 +185,12 @@ async function getProjectConfig(siteName, cliOptions) {
|
|
|
181
185
|
message: 'Do you wish to add a Resources page?\n This will add a "./resources" directory and add comprehensive resources examples.',
|
|
182
186
|
initial: true,
|
|
183
187
|
},
|
|
188
|
+
{
|
|
189
|
+
type: "confirm",
|
|
190
|
+
name: "includePackageDocs",
|
|
191
|
+
message: "Do you wish to include package documentation?\n Useful for package development and easier access to docs, but adds unnecessary dependencies for production builds.\n You can remove this later (see README for instructions).",
|
|
192
|
+
initial: false,
|
|
193
|
+
},
|
|
184
194
|
], {
|
|
185
195
|
onCancel() {
|
|
186
196
|
logger.error("Addon selection is required.");
|
|
@@ -189,6 +199,7 @@ async function getProjectConfig(siteName, cliOptions) {
|
|
|
189
199
|
});
|
|
190
200
|
addonSlidev = addonAnswers.addonSlidev ?? true;
|
|
191
201
|
addonResources = addonAnswers.addonResources ?? true;
|
|
202
|
+
includePackageDocs = addonAnswers.includePackageDocs ?? false;
|
|
192
203
|
}
|
|
193
204
|
return {
|
|
194
205
|
directoryName: siteName,
|
|
@@ -199,6 +210,7 @@ async function getProjectConfig(siteName, cliOptions) {
|
|
|
199
210
|
tagline,
|
|
200
211
|
addonSlidev,
|
|
201
212
|
addonResources,
|
|
213
|
+
includePackageDocs,
|
|
202
214
|
gitRepositoryUrl: `https://github.com/${organizationName}/${repositoryName}`,
|
|
203
215
|
githubPagesUrl: `https://${organizationName}.github.io`,
|
|
204
216
|
baseUrl: "/",
|
|
@@ -216,10 +228,6 @@ async function installAddon(dest, addonName) {
|
|
|
216
228
|
const slidevSrc = path.join(addonPath, "slidev");
|
|
217
229
|
const slidevDest = path.join(dest, "slidev");
|
|
218
230
|
await fs.copy(slidevSrc, slidevDest);
|
|
219
|
-
// Overwrite package.json with the one that includes Slidev dependencies
|
|
220
|
-
const pkgSrc = path.join(addonPath, "package.json");
|
|
221
|
-
const pkgDest = path.join(dest, "package.json");
|
|
222
|
-
await fs.copy(pkgSrc, pkgDest, { overwrite: true });
|
|
223
231
|
logger.success("Slidev addon installed");
|
|
224
232
|
}
|
|
225
233
|
else if (addonName === "addon-resources") {
|
|
@@ -257,7 +265,9 @@ function removeConditionalMarkers(content, keepMarkers) {
|
|
|
257
265
|
async function processConditionalMarkers(dest, config) {
|
|
258
266
|
const markersToRemove = [];
|
|
259
267
|
const markersToKeep = [];
|
|
260
|
-
if
|
|
268
|
+
// Slidev addon should be kept if either addonSlidev OR includePackageDocs is enabled
|
|
269
|
+
const shouldKeepSlidev = config.addonSlidev || config.includePackageDocs;
|
|
270
|
+
if (!shouldKeepSlidev) {
|
|
261
271
|
markersToRemove.push("addon-slidev");
|
|
262
272
|
}
|
|
263
273
|
else {
|
|
@@ -269,6 +279,12 @@ async function processConditionalMarkers(dest, config) {
|
|
|
269
279
|
else {
|
|
270
280
|
markersToKeep.push("addon-resources");
|
|
271
281
|
}
|
|
282
|
+
if (!config.includePackageDocs) {
|
|
283
|
+
markersToRemove.push("package-docs");
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
markersToKeep.push("package-docs");
|
|
287
|
+
}
|
|
272
288
|
// Process docusaurus.config.ts
|
|
273
289
|
const configPath = path.join(dest, "docusaurus.config.ts");
|
|
274
290
|
let configContent = await fs.readFile(configPath, "utf-8");
|
|
@@ -287,6 +303,16 @@ async function processConditionalMarkers(dest, config) {
|
|
|
287
303
|
indexContent = removeConditionalMarkers(indexContent, markersToKeep);
|
|
288
304
|
await fs.writeFile(indexMdxPath, indexContent);
|
|
289
305
|
}
|
|
306
|
+
// Process package.json
|
|
307
|
+
const pkgPath = path.join(dest, "package.json");
|
|
308
|
+
if (await fs.pathExists(pkgPath)) {
|
|
309
|
+
let pkgContent = await fs.readFile(pkgPath, "utf-8");
|
|
310
|
+
// First remove sections for disabled addons
|
|
311
|
+
pkgContent = removeConditionalSections(pkgContent, markersToRemove);
|
|
312
|
+
// Then remove just the markers for enabled addons
|
|
313
|
+
pkgContent = removeConditionalMarkers(pkgContent, markersToKeep);
|
|
314
|
+
await fs.writeFile(pkgPath, pkgContent);
|
|
315
|
+
}
|
|
290
316
|
logger.success("Configuration processed");
|
|
291
317
|
}
|
|
292
318
|
async function processTemplateVariables(dest, config) {
|
|
@@ -367,8 +393,11 @@ export default async function init(rootDir, reqName, cliOptions = {}) {
|
|
|
367
393
|
logger.info("Creating a new SP-Days site...");
|
|
368
394
|
// Copy base template
|
|
369
395
|
await copyBaseTemplate(dest);
|
|
396
|
+
// If package docs are enabled, ensure Slidev addon is also installed
|
|
397
|
+
// (package docs include Slidev theme documentation, so we need the addon)
|
|
398
|
+
const shouldInstallSlidev = config.addonSlidev || config.includePackageDocs;
|
|
370
399
|
// Install addons if requested
|
|
371
|
-
if (
|
|
400
|
+
if (shouldInstallSlidev) {
|
|
372
401
|
await installAddon(dest, "addon-slidev");
|
|
373
402
|
}
|
|
374
403
|
if (config.addonResources) {
|
package/package.json
CHANGED
|
@@ -1,22 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sp-days-framework/create-sp-days",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-beta1",
|
|
4
4
|
"description": "Scaffolding tool for creating SP-Days course websites built on Docusaurus and Slidev.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/helse-sorost/sp-days-framework",
|
|
8
|
+
"url": "git+https://github.com/helse-sorost/sp-days-framework.git",
|
|
9
9
|
"directory": "create-sp-days"
|
|
10
10
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"author": "SP-Days Framework",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"docusaurus",
|
|
15
|
+
"scaffolding",
|
|
16
|
+
"cli",
|
|
17
|
+
"sp-days",
|
|
18
|
+
"course",
|
|
19
|
+
"training"
|
|
20
|
+
],
|
|
21
|
+
"bin": {
|
|
22
|
+
"create-sp-days": "bin/index.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin/**/*",
|
|
26
|
+
"lib/**/*",
|
|
27
|
+
"templates/**/*",
|
|
28
|
+
"tsconfig.*.json",
|
|
29
|
+
"docs/**/*",
|
|
30
|
+
"publish-package-docs.js",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
"./publish-package-docs": "./publish-package-docs.js"
|
|
14
36
|
},
|
|
15
|
-
"bin": "bin/index.js",
|
|
16
37
|
"publishConfig": {
|
|
17
38
|
"access": "public"
|
|
18
39
|
},
|
|
19
|
-
"
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc --build",
|
|
42
|
+
"watch": "tsc --build --watch"
|
|
43
|
+
},
|
|
20
44
|
"dependencies": {
|
|
21
45
|
"@docusaurus/logger": "3.9.2",
|
|
22
46
|
"@docusaurus/types": "3.9.2",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Sykehuspartner HF
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
id: "create-sp-days-docs",
|
|
10
|
+
path: require("path").join(__dirname, "docs"),
|
|
11
|
+
routeBasePath: "package-docs/create-sp-days",
|
|
12
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_label: "API Reference"
|
|
3
|
+
sidebar_custom_props:
|
|
4
|
+
section: "Templates"
|
|
5
|
+
section_position: 1
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
{/*
|
|
9
|
+
|
|
10
|
+
API Reference pages document REST, GraphQL, or other API endpoints with details about
|
|
11
|
+
parameters, request/response formats, and authentication. Keep examples realistic and
|
|
12
|
+
include error cases. Use tables for parameter documentation to maintain consistency.
|
|
13
|
+
|
|
14
|
+
*/}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# API Reference Template
|
|
18
|
+
|
|
19
|
+
Comprehensive documentation for all available API endpoints, including request parameters, response formats, and authentication requirements.
|
|
20
|
+
|
|
21
|
+
## Authentication
|
|
22
|
+
|
|
23
|
+
All API requests require authentication using an API key passed in the `Authorization` header.
|
|
24
|
+
|
|
25
|
+
```http
|
|
26
|
+
Authorization: Bearer YOUR_API_KEY
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Base URL
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
https://api.example.com/v1
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Endpoints
|
|
36
|
+
|
|
37
|
+
### GET /resource
|
|
38
|
+
|
|
39
|
+
Retrieve a list of resources.
|
|
40
|
+
|
|
41
|
+
**Parameters:**
|
|
42
|
+
|
|
43
|
+
| Name | Type | Required | Description |
|
|
44
|
+
|---------|----------|----------|---------------------------------------|
|
|
45
|
+
| `limit` | integer | No | Maximum number of results (default: 10) |
|
|
46
|
+
| `page` | integer | No | Page number for pagination (default: 1) |
|
|
47
|
+
| `sort` | string | No | Sort field and order (e.g., `name:asc`) |
|
|
48
|
+
|
|
49
|
+
**Example Request:**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
curl -X GET "https://api.example.com/v1/resource?limit=5&page=1" \
|
|
53
|
+
-H "Authorization: Bearer YOUR_API_KEY"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Example Response:**
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"data": [
|
|
61
|
+
{
|
|
62
|
+
"id": "123",
|
|
63
|
+
"name": "Example Resource",
|
|
64
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"meta": {
|
|
68
|
+
"total": 42,
|
|
69
|
+
"page": 1,
|
|
70
|
+
"limit": 5
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### POST /resource
|
|
76
|
+
|
|
77
|
+
Create a new resource.
|
|
78
|
+
|
|
79
|
+
**Request Body:**
|
|
80
|
+
|
|
81
|
+
| Field | Type | Required | Description |
|
|
82
|
+
|--------------|--------|----------|--------------------------------|
|
|
83
|
+
| `name` | string | Yes | Name of the resource |
|
|
84
|
+
| `description`| string | No | Optional description |
|
|
85
|
+
|
|
86
|
+
**Example Request:**
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
curl -X POST "https://api.example.com/v1/resource" \
|
|
90
|
+
-H "Authorization: Bearer YOUR_API_KEY" \
|
|
91
|
+
-H "Content-Type: application/json" \
|
|
92
|
+
-d '{
|
|
93
|
+
"name": "New Resource",
|
|
94
|
+
"description": "A sample resource"
|
|
95
|
+
}'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Example Response:**
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"id": "124",
|
|
103
|
+
"name": "New Resource",
|
|
104
|
+
"description": "A sample resource",
|
|
105
|
+
"created_at": "2024-01-15T10:35:00Z"
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Error Responses
|
|
110
|
+
|
|
111
|
+
| Status Code | Description |
|
|
112
|
+
|-------------|-----------------------------------|
|
|
113
|
+
| 400 | Bad Request - Invalid parameters |
|
|
114
|
+
| 401 | Unauthorized - Invalid API key |
|
|
115
|
+
| 404 | Not Found - Resource doesn't exist|
|
|
116
|
+
| 429 | Too Many Requests - Rate limited |
|
|
117
|
+
| 500 | Internal Server Error |
|
|
118
|
+
|
|
119
|
+
**Example Error Response:**
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"error": {
|
|
124
|
+
"code": "invalid_parameter",
|
|
125
|
+
"message": "The 'limit' parameter must be between 1 and 100"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
:::tip Rate Limits
|
|
131
|
+
API requests are limited to 100 requests per minute per API key. Check the `X-RateLimit-Remaining` header in responses.
|
|
132
|
+
:::
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_label: Best Practices
|
|
3
|
+
sidebar_position: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Docusaurus Best Practices & Guidelines
|
|
7
|
+
|
|
8
|
+
Recommended practices for writing high-quality Docusaurus documentation using MDX format.
|
|
9
|
+
|
|
10
|
+
## File Format
|
|
11
|
+
|
|
12
|
+
Always use `.mdx` extension for Docusaurus documentation files, even if not currently using JSX components.
|
|
13
|
+
|
|
14
|
+
**Benefits:**
|
|
15
|
+
- Enables use of Docusaurus MDX components (Tabs, Admonitions, etc.)
|
|
16
|
+
- Provides consistency across the documentation
|
|
17
|
+
- Makes files less portable but more powerful within Docusaurus ecosystem
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
✅ quick-start.mdx
|
|
21
|
+
❌ quick-start.md
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Frontmatter
|
|
25
|
+
|
|
26
|
+
Frontmatter fields are optional but useful for customization.
|
|
27
|
+
|
|
28
|
+
| Field | Purpose | Example |
|
|
29
|
+
|-------|---------|---------|
|
|
30
|
+
| `sidebar_label` | Shorter sidebar title or add icons | `sidebar_label: 🚀 Quick Start` |
|
|
31
|
+
| `sidebar_position` | Override alphabetical ordering | `sidebar_position: 1` |
|
|
32
|
+
| `title` | Override H1 as page title | `title: Getting Started Guide` |
|
|
33
|
+
|
|
34
|
+
Use `sidebar_label` when your H1 heading is too long for the sidebar, or to add emoji/icons for visual distinction.
|
|
35
|
+
|
|
36
|
+
**Alternative to `sidebar_position`:** Prefix filenames with numbers like `01-introduction.mdx`, `02-installation.mdx`, `03-configuration.mdx`.
|
|
37
|
+
|
|
38
|
+
## Component Imports
|
|
39
|
+
|
|
40
|
+
Always place imports immediately after frontmatter:
|
|
41
|
+
|
|
42
|
+
````mdx
|
|
43
|
+
---
|
|
44
|
+
sidebar_label: Examples
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
import Tabs from '@theme/Tabs';
|
|
48
|
+
import TabItem from '@theme/TabItem';
|
|
49
|
+
|
|
50
|
+
# Examples and Usage
|
|
51
|
+
````
|
|
52
|
+
|
|
53
|
+
## Heading Structure
|
|
54
|
+
|
|
55
|
+
Never skip heading levels – maintain logical document structure for accessibility.
|
|
56
|
+
|
|
57
|
+
```mdx
|
|
58
|
+
✅ Good
|
|
59
|
+
# Main Title (H1)
|
|
60
|
+
## Section (H2)
|
|
61
|
+
### Subsection (H3)
|
|
62
|
+
#### Detail (H4)
|
|
63
|
+
|
|
64
|
+
❌ Bad
|
|
65
|
+
# Main Title (H1)
|
|
66
|
+
### Subsection (H3) ← Skipped H2
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Don't create sections with only one sub-heading – it creates awkward TOC entries.
|
|
70
|
+
|
|
71
|
+
```mdx
|
|
72
|
+
❌ Bad
|
|
73
|
+
## Configuration
|
|
74
|
+
### Database Setup ← Only one H3 under H2
|
|
75
|
+
|
|
76
|
+
✅ Better - Remove sub-header
|
|
77
|
+
## Database Setup
|
|
78
|
+
|
|
79
|
+
✅ Better - Add more sub-headers
|
|
80
|
+
## Configuration
|
|
81
|
+
### Database Setup
|
|
82
|
+
### Cache Setup
|
|
83
|
+
### Logging Setup
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Adjust TOC depth using frontmatter if using many H4 headings:
|
|
87
|
+
|
|
88
|
+
```mdx
|
|
89
|
+
---
|
|
90
|
+
tableOfContents:
|
|
91
|
+
maxHeadingLevel: 3
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
# My Page
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Code Blocks
|
|
98
|
+
|
|
99
|
+
Always specify the language for proper syntax highlighting:
|
|
100
|
+
|
|
101
|
+
````mdx
|
|
102
|
+
✅ Good
|
|
103
|
+
```bash
|
|
104
|
+
npm install
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
❌ Bad
|
|
108
|
+
```
|
|
109
|
+
npm install
|
|
110
|
+
```
|
|
111
|
+
````
|
|
112
|
+
|
|
113
|
+
Use `title` attribute for known filenames or configuration files:
|
|
114
|
+
|
|
115
|
+
````mdx
|
|
116
|
+
```json title="package.json"
|
|
117
|
+
{
|
|
118
|
+
"name": "my-app",
|
|
119
|
+
"version": "1.0.0"
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
````
|
|
123
|
+
|
|
124
|
+
Highlight specific lines when showing modifications:
|
|
125
|
+
|
|
126
|
+
````mdx
|
|
127
|
+
```typescript title="app.ts" {3-5}
|
|
128
|
+
function greet(name: string) {
|
|
129
|
+
// highlight-next-line
|
|
130
|
+
console.log(`Hello, ${name}!`);
|
|
131
|
+
return `Welcome, ${name}`;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
````
|
|
135
|
+
|
|
136
|
+
Use backslash `\` for lengthy commands to improve readability:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
docker run -d \
|
|
140
|
+
--name my-container \
|
|
141
|
+
--publish 8080:80 \
|
|
142
|
+
--volume $(pwd):/app \
|
|
143
|
+
nginx:latest
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
For multiple commands, use one of these approaches:
|
|
147
|
+
|
|
148
|
+
````mdx
|
|
149
|
+
Option 1: Separate blocks
|
|
150
|
+
```bash
|
|
151
|
+
npm install
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm run dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Option 2: Chain with &&
|
|
159
|
+
```bash
|
|
160
|
+
npm install && npm run dev
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Option 3: Use comments
|
|
164
|
+
```bash
|
|
165
|
+
# Install dependencies
|
|
166
|
+
npm install
|
|
167
|
+
|
|
168
|
+
# Start development server
|
|
169
|
+
npm run dev
|
|
170
|
+
```
|
|
171
|
+
````
|
|
172
|
+
|
|
173
|
+
## Inline Code vs Code Blocks
|
|
174
|
+
|
|
175
|
+
Use inline code for short, single-line references:
|
|
176
|
+
|
|
177
|
+
- File paths: `src/components/Header.tsx`
|
|
178
|
+
- Variables: `API_KEY`
|
|
179
|
+
- Functions: `getUserById()`
|
|
180
|
+
- Small values: `true`, `null`, `"production"`
|
|
181
|
+
- Commands when mentioned in text: "Run `npm install` to get started"
|
|
182
|
+
|
|
183
|
+
Use code blocks for:
|
|
184
|
+
|
|
185
|
+
- Commands in step-by-step instructions or when you expect readers to copy
|
|
186
|
+
- Complete commands with options
|
|
187
|
+
- Configuration files
|
|
188
|
+
- Function/class implementations
|
|
189
|
+
- Multi-step procedures
|
|
190
|
+
|
|
191
|
+
## MDX Components
|
|
192
|
+
|
|
193
|
+
Don't use markdown headers inside Tabs components – they appear in the TOC. Use bold text or `<h3>` tags instead.
|
|
194
|
+
|
|
195
|
+
````mdx
|
|
196
|
+
❌ Bad
|
|
197
|
+
<Tabs>
|
|
198
|
+
<TabItem value="npm">
|
|
199
|
+
### Using npm ← Appears in TOC
|
|
200
|
+
```bash
|
|
201
|
+
npm install
|
|
202
|
+
```
|
|
203
|
+
</TabItem>
|
|
204
|
+
</Tabs>
|
|
205
|
+
|
|
206
|
+
✅ Good - Use bold text
|
|
207
|
+
<Tabs>
|
|
208
|
+
<TabItem value="npm">
|
|
209
|
+
|
|
210
|
+
**Using npm**
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npm install
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
</TabItem>
|
|
217
|
+
</Tabs>
|
|
218
|
+
|
|
219
|
+
✅ Good - Use <h3> tag
|
|
220
|
+
<Tabs>
|
|
221
|
+
<TabItem value="npm">
|
|
222
|
+
|
|
223
|
+
<h3>Using npm</h3>
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npm install
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
</TabItem>
|
|
230
|
+
</Tabs>
|
|
231
|
+
````
|
|
232
|
+
|
|
233
|
+
Maintain proper indentation for nested HTML/JSX:
|
|
234
|
+
|
|
235
|
+
````mdx
|
|
236
|
+
<details>
|
|
237
|
+
<summary>Click to expand</summary>
|
|
238
|
+
|
|
239
|
+
<div>
|
|
240
|
+
<p>Nested content should be indented</p>
|
|
241
|
+
<ul>
|
|
242
|
+
<li>Item 1</li>
|
|
243
|
+
<li>Item 2</li>
|
|
244
|
+
</ul>
|
|
245
|
+
</div>
|
|
246
|
+
|
|
247
|
+
</details>
|
|
248
|
+
````
|
|
249
|
+
|
|
250
|
+
## Admonitions
|
|
251
|
+
|
|
252
|
+
Admonitions steal focus (intentionally) – use only for important information. Limit to 1-2 per page section.
|
|
253
|
+
|
|
254
|
+
````mdx
|
|
255
|
+
:::note
|
|
256
|
+
General information or context
|
|
257
|
+
:::
|
|
258
|
+
|
|
259
|
+
:::tip
|
|
260
|
+
Helpful shortcuts or best practices
|
|
261
|
+
:::
|
|
262
|
+
|
|
263
|
+
:::warning
|
|
264
|
+
Potential pitfalls or deprecated features
|
|
265
|
+
:::
|
|
266
|
+
|
|
267
|
+
:::danger
|
|
268
|
+
Destructive actions or critical warnings
|
|
269
|
+
:::
|
|
270
|
+
|
|
271
|
+
:::info
|
|
272
|
+
Additional context or related information
|
|
273
|
+
:::
|
|
274
|
+
````
|
|
275
|
+
|
|
276
|
+
**When to use:**
|
|
277
|
+
|
|
278
|
+
- `:::note` – Additional context that's helpful but not critical
|
|
279
|
+
- `:::tip` – Efficiency shortcuts or recommended approaches
|
|
280
|
+
- `:::warning` – Potential issues, deprecated features, or gotchas
|
|
281
|
+
- `:::danger` – Data loss risks, breaking changes, security concerns
|
|
282
|
+
- `:::info` – Related resources or background information
|
|
283
|
+
|
|
284
|
+
## Tables
|
|
285
|
+
|
|
286
|
+
Use markdown tables for structured data like command options, configuration parameters, comparison matrices, or property documentation.
|
|
287
|
+
|
|
288
|
+
````mdx
|
|
289
|
+
| Option | Type | Default | Description |
|
|
290
|
+
|--------|------|---------|-------------|
|
|
291
|
+
| `port` | number | `3000` | Server port |
|
|
292
|
+
| `host` | string | `localhost` | Server host |
|
|
293
|
+
````
|
|
294
|
+
|
|
295
|
+
Keep column count reasonable and use concise headers for readability.
|
|
296
|
+
|
|
297
|
+
## Collapsible Sections
|
|
298
|
+
|
|
299
|
+
Hide advanced or supplementary information behind collapsible sections using `<details>`:
|
|
300
|
+
|
|
301
|
+
````mdx
|
|
302
|
+
<details>
|
|
303
|
+
<summary>Advanced configuration options</summary>
|
|
304
|
+
|
|
305
|
+
Content here is hidden by default and revealed on click.
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{
|
|
309
|
+
"advanced": true
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
</details>
|
|
314
|
+
````
|
|
315
|
+
|
|
316
|
+
**When to use:**
|
|
317
|
+
|
|
318
|
+
- Advanced configuration options
|
|
319
|
+
- Detailed explanations for specific edge cases
|
|
320
|
+
- Lengthy reference information
|
|
321
|
+
- Optional troubleshooting steps
|
|
322
|
+
|
|
323
|
+
## Directory Structure
|
|
324
|
+
|
|
325
|
+
Consider adding an `index.mdx` landing page in directories when the category needs an overview, navigation to sub-pages, or general context.
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
guides/
|
|
329
|
+
├── index.mdx ← Landing page for guides section
|
|
330
|
+
├── installation.mdx
|
|
331
|
+
├── configuration.mdx
|
|
332
|
+
└── deployment.mdx
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Links
|
|
336
|
+
|
|
337
|
+
Markdown links are useful but require careful consideration.
|
|
338
|
+
|
|
339
|
+
**Pros:**
|
|
340
|
+
- Great for connecting related documentation
|
|
341
|
+
- Improve content discoverability
|
|
342
|
+
- Enable quick navigation
|
|
343
|
+
|
|
344
|
+
**Cons:**
|
|
345
|
+
- Break when files are moved or renamed
|
|
346
|
+
- Create maintenance burden in large projects
|
|
347
|
+
- Can cause build errors if targets are deleted
|
|
348
|
+
|
|
349
|
+
**Guideline:**
|
|
350
|
+
|
|
351
|
+
- Use links in `index.mdx` landing pages for navigation
|
|
352
|
+
- Avoid excessive cross-linking in regular content pages
|
|
353
|
+
- Prefer sidebar navigation over inline links when possible
|
|
354
|
+
- Keep external links (to official docs, resources) – they're valuable
|
|
355
|
+
|
|
356
|
+
````mdx
|
|
357
|
+
✅ Good - Landing page with curated links
|
|
358
|
+
# Getting Started
|
|
359
|
+
|
|
360
|
+
- [Installation Guide](./installation.mdx)
|
|
361
|
+
- [Configuration](./configuration.mdx)
|
|
362
|
+
|
|
363
|
+
✅ Good - External resource
|
|
364
|
+
See the [official Docker documentation](https://docs.docker.com)
|
|
365
|
+
|
|
366
|
+
⚠️ Use sparingly - Cross-references between regular pages
|
|
367
|
+
For database setup, see [Configuration Guide](../config/database.mdx)
|
|
368
|
+
````
|
|
369
|
+
|
|
370
|
+
## Images & Assets
|
|
371
|
+
|
|
372
|
+
Store page-specific images in `.assets/` directory alongside the MDX file:
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
guides/
|
|
376
|
+
├── installation.mdx
|
|
377
|
+
└── .assets/
|
|
378
|
+
├── install-step1.png
|
|
379
|
+
└── install-step2.png
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Store shared resources in `/static/img/` for logos, icons, and reused graphics:
|
|
383
|
+
|
|
384
|
+
```
|
|
385
|
+
static/
|
|
386
|
+
└── img/
|
|
387
|
+
├── logo.svg
|
|
388
|
+
├── docker-icon.png
|
|
389
|
+
└── common/
|
|
390
|
+
└── warning-icon.svg
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Always include descriptive alt text for images:
|
|
394
|
+
|
|
395
|
+
````mdx
|
|
396
|
+
✅ Good
|
|
397
|
+

|
|
398
|
+
|
|
399
|
+
❌ Bad
|
|
400
|
+

|
|
401
|
+
````
|
|
402
|
+
|
|
403
|
+
**Performance tips:**
|
|
404
|
+
|
|
405
|
+
- Prefer SVG for logos and icons (smaller, scalable)
|
|
406
|
+
- Optimize PNG/JPG images before adding to repository
|
|
407
|
+
- Use appropriate image dimensions (don't scale down huge images with HTML)
|