@docubook/create 2.3.0 → 2.4.0

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.
Files changed (53) hide show
  1. package/package.json +1 -1
  2. package/src/dist/app/docs/[[...slug]]/page.tsx +2 -5
  3. package/src/dist/app/layout.tsx +1 -3
  4. package/src/dist/app/page.tsx +2 -21
  5. package/src/dist/components/SearchModal.tsx +1 -1
  6. package/src/dist/components/context-popover.tsx +1 -1
  7. package/src/dist/components/docs-menu.tsx +2 -2
  8. package/src/dist/components/markdown/AccordionGroupMdx.tsx +1 -1
  9. package/src/dist/components/markdown/AccordionMdx.tsx +4 -4
  10. package/src/dist/components/markdown/CardMdx.tsx +4 -4
  11. package/src/dist/components/markdown/FileTreeMdx.tsx +4 -4
  12. package/src/dist/components/markdown/ImageMdx.tsx +1 -1
  13. package/src/dist/components/markdown/ReleaseMdx.tsx +1 -1
  14. package/src/dist/components/markdown/TooltipsMdx.tsx +1 -1
  15. package/src/dist/components/sublink.tsx +1 -1
  16. package/src/dist/docs/components/accordion-group.mdx +68 -0
  17. package/src/dist/docs/components/accordion.mdx +59 -0
  18. package/src/dist/docs/components/button.mdx +40 -0
  19. package/src/dist/docs/components/card-group.mdx +47 -0
  20. package/src/dist/docs/components/card.mdx +68 -0
  21. package/src/dist/docs/components/code-block.mdx +67 -0
  22. package/src/dist/docs/components/custom.mdx +38 -0
  23. package/src/dist/docs/components/file-tree.mdx +109 -0
  24. package/src/dist/docs/components/image.mdx +37 -0
  25. package/src/dist/docs/components/index.mdx +9 -0
  26. package/src/dist/docs/components/keyboard.mdx +117 -0
  27. package/src/dist/docs/components/link.mdx +34 -0
  28. package/src/dist/docs/components/note.mdx +44 -0
  29. package/src/dist/docs/components/release-note.mdx +114 -0
  30. package/src/dist/docs/components/stepper.mdx +45 -0
  31. package/src/dist/docs/components/tables.mdx +35 -0
  32. package/src/dist/docs/components/tabs.mdx +72 -0
  33. package/src/dist/docs/components/tooltips.mdx +22 -0
  34. package/src/dist/docs/components/youtube.mdx +23 -0
  35. package/src/dist/docs/getting-started/introduction.mdx +18 -0
  36. package/src/dist/docs/getting-started/quick-start-guide.mdx +60 -0
  37. package/src/dist/docu.json +36 -33
  38. package/src/dist/eslint.config.mjs +17 -30
  39. package/src/dist/lib/markdown.ts +32 -17
  40. package/src/dist/lib/utils.ts +1 -1
  41. package/src/dist/next.config.mjs +10 -11
  42. package/src/dist/package.json +1 -1
  43. package/src/dist/docs/api-reference/delete/index.mdx +0 -63
  44. package/src/dist/docs/api-reference/fetch/index.mdx +0 -63
  45. package/src/dist/docs/api-reference/get/index.mdx +0 -63
  46. package/src/dist/docs/api-reference/post/index.mdx +0 -63
  47. package/src/dist/docs/changelog/index.mdx +0 -49
  48. package/src/dist/docs/getting-started/development/index.mdx +0 -92
  49. package/src/dist/docs/getting-started/introduction/index.mdx +0 -92
  50. package/src/dist/docs/getting-started/quick-start-guide/index.mdx +0 -92
  51. /package/src/dist/components/{contexts/AccordionContext.ts → AccordionContext.ts} +0 -0
  52. /package/src/dist/components/{contexts/theme-provider.tsx → theme-provider.tsx} +0 -0
  53. /package/src/dist/lib/{routes-config.ts → routes.ts} +0 -0
@@ -0,0 +1,60 @@
1
+ ---
2
+ title : Quick Start Guide
3
+ description : a quick way to understand how to use it
4
+ date : 10-12-2024
5
+ ---
6
+
7
+ ## Adding a Route
8
+
9
+ To add a new page to your documentation, you need to register it in the `docu.json` file.
10
+
11
+ <Stepper>
12
+ <StepperItem title="Create the MDX file">
13
+ Create a new `.mdx` file in the `docs` directory. For example, `docs/my-new-page.mdx`.
14
+ </StepperItem>
15
+ <StepperItem title="Register in docu.json">
16
+ Open `docu.json` and add an entry to the `routes` array.
17
+
18
+ ```json
19
+ {
20
+ "title": "My New Page",
21
+ "href": "/my-new-page"
22
+ }
23
+ ```
24
+ </StepperItem>
25
+ </Stepper>
26
+
27
+ ## Writing Content
28
+
29
+ DocuBook supports standard Markdown and a variety of custom components to make your documentation more interactive.
30
+
31
+ ### Using Components
32
+
33
+ Here are some common components you can use:
34
+
35
+ #### Cards
36
+
37
+ Use cards to highlight important links or features.
38
+
39
+ <CardGroup cols={2}>
40
+ <Card title="Installation" icon="Download" href="#">
41
+ Learn how to install DocuBook.
42
+ </Card>
43
+ <Card title="Configuration" icon="Settings" href="#">
44
+ Configure your documentation site.
45
+ </Card>
46
+ </CardGroup>
47
+
48
+ #### Notes
49
+
50
+ Use notes to provide additional context or warnings.
51
+
52
+ <Note type="warning" title="Warning">
53
+ Always remember to back up your configuration files.
54
+ </Note>
55
+
56
+ <Note type="note" title="Pro Tip">
57
+ You can use Lucide icons in your cards by specifying the `icon` prop.
58
+ </Note>
59
+
60
+ For more details on available components, check out the [Components](/docs/components) section.
@@ -21,7 +21,7 @@
21
21
  "repository": {
22
22
  "url": "https://github.com/DocuBook/docubook",
23
23
  "editPathTemplate": "/blob/main/{filePath}",
24
- "editLink": true
24
+ "editLink": false
25
25
  },
26
26
  "sponsor": {
27
27
  "title": "Hosted on",
@@ -63,41 +63,44 @@
63
63
  "href": "/getting-started",
64
64
  "noLink": true,
65
65
  "context": {
66
- "icon": "Book",
67
- "description": "Set up your Documentation",
68
- "title": "Guides"
69
- },
70
- "items": [
71
- { "title": "Introduction", "href": "/introduction" },
72
- { "title": "Quick Start Guide", "href": "/quick-start-guide" },
73
- { "title": "Development", "href": "/development" }
74
- ]
66
+ "icon": "Book",
67
+ "description": "Set up your Documentation",
68
+ "title": "Guides"
75
69
  },
76
- {
77
- "title": "Api Reference",
78
- "href": "/api-reference",
70
+ "items": [
71
+ { "title": "Introduction", "href": "/introduction" },
72
+ { "title": "Quick Start Guide", "href": "/quick-start-guide" }
73
+ ]
74
+ },
75
+ {
76
+ "title": "Components",
77
+ "href": "/components",
79
78
  "noLink": true,
80
79
  "context": {
81
- "icon": "Terminal",
82
- "description": "reference for using the API",
83
- "title": "API Reference"
84
- },
85
- "items": [
86
- { "title": "Get", "href": "/get" },
87
- { "title": "Fetch", "href": "/fetch" },
88
- { "title": "Post", "href": "/post" },
89
- { "title": "Delete", "href": "/delete" }
90
- ]
80
+ "icon": "Layers",
81
+ "description": "Write with Markdown",
82
+ "title": "Markdown"
91
83
  },
92
- {
93
- "title": "Changelog",
94
- "href": "/changelog",
95
- "noLink": true,
96
- "context": {
97
- "icon": "History",
98
- "description": "Update and Changes",
99
- "title": "Release"
100
- }
101
- }
84
+ "items": [
85
+ { "title": "Accordion", "href": "/accordion" },
86
+ { "title": "Accordion Group", "href": "/accordion-group" },
87
+ { "title": "Button", "href": "/button" },
88
+ { "title": "Card", "href": "/card" },
89
+ { "title": "Card Group", "href": "/card-group" },
90
+ { "title": "Code Block", "href": "/code-block" },
91
+ { "title": "File Tree", "href": "/file-tree" },
92
+ { "title": "Image", "href": "/image" },
93
+ { "title": "Keyboard", "href": "/keyboard" },
94
+ { "title": "Link", "href": "/link" },
95
+ { "title": "Note", "href": "/note" },
96
+ { "title": "Release Note", "href": "/release-note" },
97
+ { "title": "Stepper", "href": "/stepper" },
98
+ { "title": "Tabs", "href": "/tabs" },
99
+ { "title": "Tooltips", "href": "/tooltips" },
100
+ { "title": "Tables", "href": "/tables" },
101
+ { "title": "Youtube", "href": "/youtube" },
102
+ { "title": "Custom", "href": "/custom" }
103
+ ]
104
+ }
102
105
  ]
103
106
  }
@@ -1,35 +1,22 @@
1
- import { defineConfig } from "eslint/config";
2
1
  import nextCoreWebVitals from "eslint-config-next/core-web-vitals";
3
2
  import nextTypescript from "eslint-config-next/typescript";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
3
  import js from "@eslint/js";
7
- import { FlatCompat } from "@eslint/eslintrc";
4
+ import tseslint from "typescript-eslint";
8
5
 
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
- const compat = new FlatCompat({
12
- baseDirectory: __dirname,
13
- recommendedConfig: js.configs.recommended,
14
- allConfig: js.configs.all
15
- });
16
-
17
- export default defineConfig([{
18
- extends: [
19
- ...nextCoreWebVitals,
20
- ...nextTypescript,
21
- ...compat.extends("plugin:@typescript-eslint/recommended")
22
- ],
23
-
24
- rules: {
25
- "@typescript-eslint/no-explicit-any": "warn",
26
-
27
- "@typescript-eslint/no-unused-vars": ["warn", {
28
- argsIgnorePattern: "^_",
29
- varsIgnorePattern: "^_",
30
- caughtErrorsIgnorePattern: "^_",
31
- }],
32
-
33
- "@typescript-eslint/no-empty-object-type": "off",
6
+ export default tseslint.config(
7
+ js.configs.recommended,
8
+ ...nextCoreWebVitals,
9
+ ...nextTypescript,
10
+ ...tseslint.configs["recommended"],
11
+ {
12
+ rules: {
13
+ "@typescript-eslint/no-explicit-any": "warn",
14
+ "@typescript-eslint/no-unused-vars": ["warn", {
15
+ argsIgnorePattern: "^_",
16
+ varsIgnorePattern: "^_",
17
+ caughtErrorsIgnorePattern: "^_",
18
+ }],
19
+ "@typescript-eslint/no-empty-object-type": "off",
20
+ },
34
21
  },
35
- }]);
22
+ );
@@ -6,7 +6,7 @@ import rehypePrism from "rehype-prism-plus";
6
6
  import rehypeAutolinkHeadings from "rehype-autolink-headings";
7
7
  import rehypeSlug from "rehype-slug";
8
8
  import rehypeCodeTitles from "rehype-code-titles";
9
- import { page_routes, ROUTES } from "./routes-config";
9
+ import { page_routes, ROUTES } from "./routes";
10
10
  import { visit } from "unist-util-visit";
11
11
  import type { Node, Parent } from "unist";
12
12
  import matter from "gray-matter";
@@ -163,17 +163,20 @@ export type BaseMdxFrontmatter = {
163
163
 
164
164
  export async function getDocsForSlug(slug: string) {
165
165
  try {
166
- const contentPath = getDocsContentPath(slug);
167
- const rawMdx = await fs.readFile(contentPath, "utf-8");
168
- return await parseMdx<BaseMdxFrontmatter>(rawMdx);
166
+ const { content, filePath } = await getRawMdx(slug);
167
+ const mdx = await parseMdx<BaseMdxFrontmatter>(content);
168
+ return {
169
+ ...mdx,
170
+ filePath,
171
+ };
169
172
  } catch (err) {
170
173
  console.log(err);
171
174
  }
172
175
  }
173
176
 
174
177
  export async function getDocsTocs(slug: string) {
175
- const contentPath = getDocsContentPath(slug);
176
- const rawMdx = await fs.readFile(contentPath, "utf-8");
178
+ const { content } = await getRawMdx(slug);
179
+ const rawMdx = content;
177
180
 
178
181
  // Regex to match code blocks (```...```), standard markdown headings (##), and <Release> tags
179
182
  const combinedRegex = /(```[\s\S]*?```)|^(#{2,4})\s(.+)$|<Release[^>]*version="([^"]+)"/gm;
@@ -222,8 +225,26 @@ function sluggify(text: string) {
222
225
  return slug.replace(/[^a-z0-9-]/g, "");
223
226
  }
224
227
 
225
- function getDocsContentPath(slug: string) {
226
- return path.join(process.cwd(), "/docs/", `${slug}/index.mdx`);
228
+ async function getRawMdx(slug: string) {
229
+ const commonPath = path.join(process.cwd(), "/docs/");
230
+ const paths = [
231
+ path.join(commonPath, `${slug}.mdx`),
232
+ path.join(commonPath, slug, "index.mdx"),
233
+ ];
234
+
235
+ for (const p of paths) {
236
+ try {
237
+ const content = await fs.readFile(p, "utf-8");
238
+ return {
239
+ content,
240
+ filePath: `docs/${path.relative(commonPath, p)}`,
241
+ };
242
+ } catch {
243
+ // ignore and try next
244
+ }
245
+ }
246
+
247
+ throw new Error(`Could not find mdx file for slug: ${slug}`);
227
248
  }
228
249
 
229
250
  function justGetFrontmatterFromMD<Frontmatter>(rawMd: string): Frontmatter {
@@ -245,16 +266,10 @@ export async function getAllChilds(pathString: string) {
245
266
 
246
267
  return await Promise.all(
247
268
  page_routes_copy.map(async (it) => {
248
- const totalPath = path.join(
249
- process.cwd(),
250
- "/docs/",
251
- prevHref,
252
- it.href,
253
- "index.mdx"
254
- );
255
- const raw = await fs.readFile(totalPath, "utf-8");
269
+ const slug = path.join(prevHref, it.href);
270
+ const { content } = await getRawMdx(slug);
256
271
  return {
257
- ...justGetFrontmatterFromMD<BaseMdxFrontmatter>(raw),
272
+ ...justGetFrontmatterFromMD<BaseMdxFrontmatter>(content),
258
273
  href: `/docs${prevHref}${it.href}`,
259
274
  };
260
275
  })
@@ -1,6 +1,6 @@
1
1
  import { type ClassValue, clsx } from "clsx";
2
2
  import { twMerge } from "tailwind-merge";
3
- import { EachRoute, ROUTES } from "./routes-config";
3
+ import { EachRoute, ROUTES } from "./routes";
4
4
 
5
5
  export function cn(...inputs: ClassValue[]) {
6
6
  return twMerge(clsx(inputs));
@@ -1,14 +1,13 @@
1
1
  /** @type {import('next').NextConfig} */
2
2
  const nextConfig = {
3
- images: {
4
- remotePatterns: [
5
- {
6
- protocol: "https",
7
- hostname: "**",
8
- },
9
- ],
10
- },
11
- };
12
-
13
- export default nextConfig;
3
+ images: {
4
+ remotePatterns: [
5
+ {
6
+ protocol: "https",
7
+ hostname: "**",
8
+ },
9
+ ],
10
+ },
11
+ }
14
12
 
13
+ export default nextConfig
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docubook",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "next dev",
@@ -1,63 +0,0 @@
1
- ---
2
- title : Delete
3
- description : example api DELETE
4
- date : 10-12-2024
5
- ---
6
-
7
- ## Heading 2
8
-
9
- this is regular text written in markdown format with `inline code`, **bold**, and *italic*
10
-
11
- ### Heading 3
12
-
13
- example of ordered list format :
14
-
15
- - list one
16
- - sub list
17
- - list two
18
- - list three
19
-
20
- #### Heading 4
21
-
22
- Below is an example of how to write a code block :
23
-
24
- ````plaintext
25
- ```javascript:main.js showLineNumbers {3-4}
26
- function isRocketAboutToCrash() {
27
- // Check if the rocket is stable
28
- if (!isStable()) {
29
- NoCrash(); // Prevent the crash
30
- }
31
- }
32
- ```
33
- ````
34
-
35
- example note :
36
- ```plaintext
37
- <Note type="note" title="Note">
38
- This is a general note to convey information to the user.
39
- </Note>
40
- ```
41
-
42
- displaying an image in markdown format :
43
-
44
- ```plaintext
45
- ![Alt text for the image](/images/example-img.png)
46
- ```
47
-
48
- render as :
49
- ![Alt text for the image](/images/example-img.png)
50
-
51
- For a complete guide on using markdown content in DocuBook, please refer to the [Components](https://docubook.pro/docs/components) page.
52
-
53
- <Note type="warning" title="Warning">
54
- every page that is indexed in a folder will have an `index.mdx` file with metadata :
55
- ```plaintext
56
- ---
57
- title : Introduction
58
- description : overview or synopsis of a project
59
- date : 10-12-2024
60
- image : example-img.png
61
- ---
62
- ```
63
- </Note>
@@ -1,63 +0,0 @@
1
- ---
2
- title : Fetch
3
- description : example api FETCH
4
- date : 10-12-2024
5
- ---
6
-
7
- ## Heading 2
8
-
9
- this is regular text written in markdown format with `inline code`, **bold**, and *italic*
10
-
11
- ### Heading 3
12
-
13
- example of ordered list format :
14
-
15
- - list one
16
- - sub list
17
- - list two
18
- - list three
19
-
20
- #### Heading 4
21
-
22
- Below is an example of how to write a code block :
23
-
24
- ````plaintext
25
- ```javascript:main.js showLineNumbers {3-4}
26
- function isRocketAboutToCrash() {
27
- // Check if the rocket is stable
28
- if (!isStable()) {
29
- NoCrash(); // Prevent the crash
30
- }
31
- }
32
- ```
33
- ````
34
-
35
- example note :
36
- ```plaintext
37
- <Note type="note" title="Note">
38
- This is a general note to convey information to the user.
39
- </Note>
40
- ```
41
-
42
- displaying an image in markdown format :
43
-
44
- ```plaintext
45
- ![Alt text for the image](/images/example-img.png)
46
- ```
47
-
48
- render as :
49
- ![Alt text for the image](/images/example-img.png)
50
-
51
- For a complete guide on using markdown content in DocuBook, please refer to the [Components](https://docubook.pro/docs/components) page.
52
-
53
- <Note type="warning" title="Warning">
54
- every page that is indexed in a folder will have an `index.mdx` file with metadata :
55
- ```plaintext
56
- ---
57
- title : Introduction
58
- description : overview or synopsis of a project
59
- date : 10-12-2024
60
- image : example-img.png
61
- ---
62
- ```
63
- </Note>
@@ -1,63 +0,0 @@
1
- ---
2
- title : Get
3
- description : example api GET
4
- date : 10-12-2024
5
- ---
6
-
7
- ## Heading 2
8
-
9
- this is regular text written in markdown format with `inline code`, **bold**, and *italic*
10
-
11
- ### Heading 3
12
-
13
- example of ordered list format :
14
-
15
- - list one
16
- - sub list
17
- - list two
18
- - list three
19
-
20
- #### Heading 4
21
-
22
- Below is an example of how to write a code block :
23
-
24
- ````plaintext
25
- ```javascript:main.js showLineNumbers {3-4}
26
- function isRocketAboutToCrash() {
27
- // Check if the rocket is stable
28
- if (!isStable()) {
29
- NoCrash(); // Prevent the crash
30
- }
31
- }
32
- ```
33
- ````
34
-
35
- example note :
36
- ```plaintext
37
- <Note type="note" title="Note">
38
- This is a general note to convey information to the user.
39
- </Note>
40
- ```
41
-
42
- displaying an image in markdown format :
43
-
44
- ```plaintext
45
- ![Alt text for the image](/images/example-img.png)
46
- ```
47
-
48
- render as :
49
- ![Alt text for the image](/images/example-img.png)
50
-
51
- For a complete guide on using markdown content in DocuBook, please refer to the [Components](https://docubook.pro/docs/components) page.
52
-
53
- <Note type="warning" title="Warning">
54
- every page that is indexed in a folder will have an `index.mdx` file with metadata :
55
- ```plaintext
56
- ---
57
- title : Introduction
58
- description : overview or synopsis of a project
59
- date : 10-12-2024
60
- image : example-img.png
61
- ---
62
- ```
63
- </Note>
@@ -1,63 +0,0 @@
1
- ---
2
- title : Post
3
- description : example api POST
4
- date : 10-12-2024
5
- ---
6
-
7
- ## Heading 2
8
-
9
- this is regular text written in markdown format with `inline code`, **bold**, and *italic*
10
-
11
- ### Heading 3
12
-
13
- example of ordered list format :
14
-
15
- - list one
16
- - sub list
17
- - list two
18
- - list three
19
-
20
- #### Heading 4
21
-
22
- Below is an example of how to write a code block :
23
-
24
- ````plaintext
25
- ```javascript:main.js showLineNumbers {3-4}
26
- function isRocketAboutToCrash() {
27
- // Check if the rocket is stable
28
- if (!isStable()) {
29
- NoCrash(); // Prevent the crash
30
- }
31
- }
32
- ```
33
- ````
34
-
35
- example note :
36
- ```plaintext
37
- <Note type="note" title="Note">
38
- This is a general note to convey information to the user.
39
- </Note>
40
- ```
41
-
42
- displaying an image in markdown format :
43
-
44
- ```plaintext
45
- ![Alt text for the image](/images/example-img.png)
46
- ```
47
-
48
- render as :
49
- ![Alt text for the image](/images/example-img.png)
50
-
51
- For a complete guide on using markdown content in DocuBook, please refer to the [Components](https://docubook.pro/docs/components) page.
52
-
53
- <Note type="warning" title="Warning">
54
- every page that is indexed in a folder will have an `index.mdx` file with metadata :
55
- ```plaintext
56
- ---
57
- title : Introduction
58
- description : overview or synopsis of a project
59
- date : 10-12-2024
60
- image : example-img.png
61
- ---
62
- ```
63
- </Note>
@@ -1,49 +0,0 @@
1
- ---
2
- title : Changelog
3
- description : changelog version
4
- date : 10-12-2024
5
- ---
6
-
7
- ## Output Markdown
8
-
9
- ```
10
- <Release version="1.0.0" date="2025-08-10" title="Release version 1.0.0">
11
- <Changes type="added">
12
- - add components
13
- </Changes>
14
- <Changes type="fixed">
15
- - fix globals.css
16
- </Changes>
17
- <Changes type="improved">
18
- - improved search components
19
- </Changes>
20
- <Changes type="deprecated">
21
- - deprecated footer components
22
- </Changes>
23
- <Changes type="removed">
24
- - removed utility class
25
- - removed unused hooks
26
- </Changes>
27
- </Release>
28
- ```
29
-
30
- ## Render as
31
-
32
- <Release version="1.0.0" date="2025-08-10" title="Release version 1.0.0">
33
- <Changes type="added">
34
- - add components
35
- </Changes>
36
- <Changes type="fixed">
37
- - fix globals.css
38
- </Changes>
39
- <Changes type="improved">
40
- - improved search components
41
- </Changes>
42
- <Changes type="deprecated">
43
- - deprecated footer components
44
- </Changes>
45
- <Changes type="removed">
46
- - removed utility class
47
- - removed unused hooks
48
- </Changes>
49
- </Release>