doccupine 0.0.97 → 0.0.99
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/dist/index.js +0 -0
- package/dist/templates/components/MDXComponents.d.ts +1 -1
- package/dist/templates/components/MDXComponents.js +3 -1
- package/dist/templates/components/layout/Card.d.ts +1 -1
- package/dist/templates/components/layout/Card.js +10 -1
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +228 -3
- package/dist/templates/components/layout/Footer.d.ts +1 -1
- package/dist/templates/components/layout/Footer.js +9 -1
- package/dist/templates/components/layout/SiteGate.d.ts +1 -1
- package/dist/templates/components/layout/SiteGate.js +8 -1
- package/dist/templates/mdx/code.mdx.d.ts +1 -1
- package/dist/templates/mdx/code.mdx.js +43 -1
- package/dist/templates/package.js +2 -2
- package/package.json +1 -1
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -48
- package/dist/metadata.d.ts +0 -11
- package/dist/metadata.js +0 -52
- package/dist/templates/accordion.mdx.d.ts +0 -1
- package/dist/templates/accordion.mdx.js +0 -41
- package/dist/templates/api/theme/routes.d.ts +0 -1
- package/dist/templates/api/theme/routes.js +0 -28
- package/dist/templates/app/api/theme/routes.d.ts +0 -1
- package/dist/templates/app/api/theme/routes.js +0 -29
- package/dist/templates/app/error.d.ts +0 -1
- package/dist/templates/app/error.js +0 -45
- package/dist/templates/app/layout.d.ts +0 -34
- package/dist/templates/app/layout.js +0 -184
- package/dist/templates/callouts.mdx.d.ts +0 -1
- package/dist/templates/callouts.mdx.js +0 -57
- package/dist/templates/cards.mdx.d.ts +0 -1
- package/dist/templates/cards.mdx.js +0 -25
- package/dist/templates/click-outside.d.ts +0 -1
- package/dist/templates/click-outside.js +0 -28
- package/dist/templates/code.d.ts +0 -1
- package/dist/templates/code.js +0 -202
- package/dist/templates/code.mdx.d.ts +0 -1
- package/dist/templates/code.mdx.js +0 -46
- package/dist/templates/commands.mdx.d.ts +0 -1
- package/dist/templates/commands.mdx.js +0 -48
- package/dist/templates/components/ClickOutside.d.ts +0 -1
- package/dist/templates/components/ClickOutside.js +0 -29
- package/dist/templates/components/layout/ClientThemeProvider.d.ts +0 -1
- package/dist/templates/components/layout/ClientThemeProvider.js +0 -85
- package/dist/templates/components/layout/CopyButton.d.ts +0 -1
- package/dist/templates/components/layout/CopyButton.js +0 -85
- package/dist/templates/components/layout/RenderMarkdown.d.ts +0 -1
- package/dist/templates/components/layout/RenderMarkdown.js +0 -61
- package/dist/templates/components/layout/Stepts.d.ts +0 -1
- package/dist/templates/components/layout/Stepts.js +0 -114
- package/dist/templates/components/layout/ThemeToggle.d.ts +0 -1
- package/dist/templates/components/layout/ThemeToggle.js +0 -107
- package/dist/templates/constants.d.ts +0 -5
- package/dist/templates/constants.js +0 -5
- package/dist/templates/docs-components.d.ts +0 -1
- package/dist/templates/docs-components.js +0 -441
- package/dist/templates/docs.d.ts +0 -1
- package/dist/templates/docs.js +0 -48
- package/dist/templates/fields.mdx.d.ts +0 -1
- package/dist/templates/fields.mdx.js +0 -42
- package/dist/templates/footer.d.ts +0 -1
- package/dist/templates/footer.js +0 -9
- package/dist/templates/header.d.ts +0 -1
- package/dist/templates/header.js +0 -275
- package/dist/templates/home.d.ts +0 -1
- package/dist/templates/home.js +0 -74
- package/dist/templates/home.mdx.d.ts +0 -1
- package/dist/templates/home.mdx.js +0 -44
- package/dist/templates/homemdx.d.ts +0 -1
- package/dist/templates/homemdx.js +0 -59
- package/dist/templates/icon.d.ts +0 -1
- package/dist/templates/icon.js +0 -20
- package/dist/templates/icons.mdx.d.ts +0 -1
- package/dist/templates/icons.mdx.js +0 -44
- package/dist/templates/image-embeds.mdx.d.ts +0 -1
- package/dist/templates/image-embeds.mdx.js +0 -103
- package/dist/templates/layout.d.ts +0 -1
- package/dist/templates/layout.js +0 -69
- package/dist/templates/list-table.mdx.d.ts +0 -1
- package/dist/templates/list-table.mdx.js +0 -85
- package/dist/templates/mdx/config.mdx.d.ts +0 -1
- package/dist/templates/mdx/config.mdx.js +0 -47
- package/dist/templates/mdx/deployment.mdx.d.ts +0 -1
- package/dist/templates/mdx/deployment.mdx.js +0 -61
- package/dist/templates/mdx/image-embeds.mdx.d.ts +0 -1
- package/dist/templates/mdx/image-embeds.mdx.js +0 -95
- package/dist/templates/mdx/links.mdx.d.ts +0 -1
- package/dist/templates/mdx/links.mdx.js +0 -45
- package/dist/templates/mdx/list-and-tables.mdx.d.ts +0 -1
- package/dist/templates/mdx/list-and-tables.mdx.js +0 -78
- package/dist/templates/mdx/list-table.mdx.d.ts +0 -1
- package/dist/templates/mdx/list-table.mdx.js +0 -78
- package/dist/templates/mdx/platform/deployments.mdx.d.ts +0 -1
- package/dist/templates/mdx/platform/deployments.mdx.js +0 -36
- package/dist/templates/mdx/platform/sections-settings.mdx.d.ts +0 -1
- package/dist/templates/mdx/platform/sections-settings.mdx.js +0 -46
- package/dist/templates/mdx/stepts.mdx.d.ts +0 -1
- package/dist/templates/mdx/stepts.mdx.js +0 -60
- package/dist/templates/mdx/text.mdx.d.ts +0 -1
- package/dist/templates/mdx/text.mdx.js +0 -139
- package/dist/templates/middleware.d.ts +0 -1
- package/dist/templates/middleware.js +0 -28
- package/dist/templates/not-found.d.ts +0 -1
- package/dist/templates/not-found.js +0 -22
- package/dist/templates/pictograms.d.ts +0 -1
- package/dist/templates/pictograms.js +0 -67
- package/dist/templates/shared-styles.d.ts +0 -1
- package/dist/templates/shared-styles.js +0 -792
- package/dist/templates/structures.d.ts +0 -2
- package/dist/templates/structures.js +0 -208
- package/dist/templates/tabs.mdx.d.ts +0 -1
- package/dist/templates/tabs.mdx.js +0 -59
- package/dist/templates/text.mdx.d.ts +0 -1
- package/dist/templates/text.mdx.js +0 -142
- package/dist/templates/theme-toggle.d.ts +0 -1
- package/dist/templates/theme-toggle.js +0 -111
- package/dist/templates/theme.d.ts +0 -1
- package/dist/templates/theme.js +0 -307
- package/dist/templates/typography.d.ts +0 -1
- package/dist/templates/typography.js +0 -52
- package/dist/templates/update.mdx.d.ts +0 -1
- package/dist/templates/update.mdx.js +0 -58
package/dist/index.test.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { generateSlug, escapeTemplateContent } from "./index.js";
|
|
3
|
-
describe("generateSlug", () => {
|
|
4
|
-
it("returns empty string for index.mdx", () => {
|
|
5
|
-
expect(generateSlug("index.mdx")).toBe("");
|
|
6
|
-
expect(generateSlug("./index.mdx")).toBe("");
|
|
7
|
-
});
|
|
8
|
-
it("strips .mdx extension", () => {
|
|
9
|
-
expect(generateSlug("getting-started.mdx")).toBe("getting-started");
|
|
10
|
-
});
|
|
11
|
-
it("lowercases the slug", () => {
|
|
12
|
-
expect(generateSlug("MyPage.mdx")).toBe("mypage");
|
|
13
|
-
});
|
|
14
|
-
it("replaces special characters with hyphens", () => {
|
|
15
|
-
expect(generateSlug("hello world.mdx")).toBe("hello-world");
|
|
16
|
-
});
|
|
17
|
-
it("preserves forward slashes for nested paths", () => {
|
|
18
|
-
expect(generateSlug("guides/setup.mdx")).toBe("guides/setup");
|
|
19
|
-
});
|
|
20
|
-
it("converts backslashes to forward slashes", () => {
|
|
21
|
-
expect(generateSlug("guides\\setup.mdx")).toBe("guides/setup");
|
|
22
|
-
});
|
|
23
|
-
it("preserves underscores and hyphens", () => {
|
|
24
|
-
expect(generateSlug("my_page-name.mdx")).toBe("my_page-name");
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe("escapeTemplateContent", () => {
|
|
28
|
-
it("escapes backticks", () => {
|
|
29
|
-
expect(escapeTemplateContent("hello `world`")).toBe("hello \\`world\\`");
|
|
30
|
-
});
|
|
31
|
-
it("escapes template literal expressions", () => {
|
|
32
|
-
expect(escapeTemplateContent("${variable}")).toBe("\\${variable}");
|
|
33
|
-
});
|
|
34
|
-
it("escapes backslashes", () => {
|
|
35
|
-
expect(escapeTemplateContent("path\\to\\file")).toBe("path\\\\to\\\\file");
|
|
36
|
-
});
|
|
37
|
-
it("escapes all dangerous characters together", () => {
|
|
38
|
-
const input = "Use `${process.env.SECRET}` here";
|
|
39
|
-
const result = escapeTemplateContent(input);
|
|
40
|
-
expect(result).toBe("Use \\`\\${process.env.SECRET}\\` here");
|
|
41
|
-
});
|
|
42
|
-
it("handles content with no special characters", () => {
|
|
43
|
-
expect(escapeTemplateContent("plain text")).toBe("plain text");
|
|
44
|
-
});
|
|
45
|
-
it("handles empty string", () => {
|
|
46
|
-
expect(escapeTemplateContent("")).toBe("");
|
|
47
|
-
});
|
|
48
|
-
});
|
package/dist/metadata.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface MetadataOptions {
|
|
2
|
-
title?: string;
|
|
3
|
-
titleFallback: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
titleOrder: "page-first" | "name-first";
|
|
6
|
-
description?: string;
|
|
7
|
-
icon?: string;
|
|
8
|
-
image?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function generateMetadataBlock(opts: MetadataOptions): string;
|
|
11
|
-
export declare function generateRuntimeOnlyMetadataBlock(): string;
|
package/dist/metadata.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_FAVICON, DEFAULT_META_DESCRIPTION, DEFAULT_OG_IMAGE, DEFAULT_SITE_NAME, } from "./templates/constants.js";
|
|
2
|
-
function buildFieldExpression(staticValue, configKey, defaultValue) {
|
|
3
|
-
if (staticValue)
|
|
4
|
-
return staticValue;
|
|
5
|
-
return `\${config.${configKey} || "${defaultValue}"}`;
|
|
6
|
-
}
|
|
7
|
-
function buildTitleExpression(opts) {
|
|
8
|
-
const title = opts.title || opts.titleFallback;
|
|
9
|
-
if (opts.titleOrder === "page-first") {
|
|
10
|
-
const suffix = opts.name
|
|
11
|
-
? `- ${opts.name}`
|
|
12
|
-
: `\${config.name ? "- " + config.name : "- ${DEFAULT_SITE_NAME}"}`;
|
|
13
|
-
return `${title} ${suffix}`;
|
|
14
|
-
}
|
|
15
|
-
// name-first
|
|
16
|
-
const prefix = opts.name
|
|
17
|
-
? `${opts.name} -`
|
|
18
|
-
: `\${config.name ? config.name + " -" : "${DEFAULT_SITE_NAME} -"}`;
|
|
19
|
-
return `${prefix} ${title}`;
|
|
20
|
-
}
|
|
21
|
-
export function generateMetadataBlock(opts) {
|
|
22
|
-
const title = buildTitleExpression(opts);
|
|
23
|
-
const desc = buildFieldExpression(opts.description, "description", DEFAULT_META_DESCRIPTION);
|
|
24
|
-
const icon = buildFieldExpression(opts.icon, "icon", DEFAULT_FAVICON);
|
|
25
|
-
const image = buildFieldExpression(opts.image, "image", DEFAULT_OG_IMAGE);
|
|
26
|
-
return `export const metadata: Metadata = {
|
|
27
|
-
title: \`${title}\`,
|
|
28
|
-
description: \`${desc}\`,
|
|
29
|
-
icons: \`${icon}\`,
|
|
30
|
-
openGraph: {
|
|
31
|
-
title: \`${title}\`,
|
|
32
|
-
description: \`${desc}\`,
|
|
33
|
-
images: \`${image}\`,
|
|
34
|
-
},
|
|
35
|
-
};`;
|
|
36
|
-
}
|
|
37
|
-
export function generateRuntimeOnlyMetadataBlock() {
|
|
38
|
-
const title = `\${config.name || "${DEFAULT_SITE_NAME}"}`;
|
|
39
|
-
const desc = `\${config.description || "${DEFAULT_META_DESCRIPTION}"}`;
|
|
40
|
-
const icon = `\${config.icon || "${DEFAULT_FAVICON}"}`;
|
|
41
|
-
const image = `\${config.image || "${DEFAULT_OG_IMAGE}"}`;
|
|
42
|
-
return `export const metadata: Metadata = {
|
|
43
|
-
title: \`${title}\`,
|
|
44
|
-
description: \`${desc}\`,
|
|
45
|
-
icons: \`${icon}\`,
|
|
46
|
-
openGraph: {
|
|
47
|
-
title: \`${title}\`,
|
|
48
|
-
description: \`${desc}\`,
|
|
49
|
-
images: \`${image}\`,
|
|
50
|
-
},
|
|
51
|
-
};`;
|
|
52
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const accordionMdxTemplate = "---\ntitle: \"Accordion\"\ndescription: \"Doccupine CLI commands\"\ndate: \"2025-01-15\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 4\n---\n# Accordion\nInteractive panels for toggling visibility of content.\n\nAccordion elements help organize information by letting users show or hide sections as needed. They\u2019re an effective way to manage progressive disclosure and simplify navigation through dense or optional content.\n\n## Accordion Usage\nYou can use the Accordion component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java HelloWorld.java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>\n~~~\n\n<Accordion title=\"What is MDX?\">\n You can put any content in here, including other components, like code:\n\n ```java HelloWorld.java\n class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello, World!\");\n }\n }\n ```\n</Accordion>";
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export const accordionMdxTemplate = `---
|
|
2
|
-
title: "Accordion"
|
|
3
|
-
description: "Doccupine CLI commands"
|
|
4
|
-
date: "2025-01-15"
|
|
5
|
-
category: "Components"
|
|
6
|
-
categoryOrder: 1
|
|
7
|
-
order: 4
|
|
8
|
-
---
|
|
9
|
-
# Accordion
|
|
10
|
-
Interactive panels for toggling visibility of content.
|
|
11
|
-
|
|
12
|
-
Accordion elements help organize information by letting users show or hide sections as needed. They’re an effective way to manage progressive disclosure and simplify navigation through dense or optional content.
|
|
13
|
-
|
|
14
|
-
## Accordion Usage
|
|
15
|
-
You can use the Accordion component directly within your MDX files without any import. The following example shows a basic usage:
|
|
16
|
-
|
|
17
|
-
~~~mdx
|
|
18
|
-
<Accordion title="What is MDX?">
|
|
19
|
-
You can put any content in here, including other components, like code:
|
|
20
|
-
|
|
21
|
-
\`\`\`java HelloWorld.java
|
|
22
|
-
class HelloWorld {
|
|
23
|
-
public static void main(String[] args) {
|
|
24
|
-
System.out.println("Hello, World!");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
\`\`\`
|
|
28
|
-
</Accordion>
|
|
29
|
-
~~~
|
|
30
|
-
|
|
31
|
-
<Accordion title="What is MDX?">
|
|
32
|
-
You can put any content in here, including other components, like code:
|
|
33
|
-
|
|
34
|
-
\`\`\`java HelloWorld.java
|
|
35
|
-
class HelloWorld {
|
|
36
|
-
public static void main(String[] args) {
|
|
37
|
-
System.out.println("Hello, World!");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
\`\`\`
|
|
41
|
-
</Accordion>`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const routesTemplate = "import { NextResponse } from \"next/server\";\nimport { cookies } from \"next/headers\";\n\nexport async function POST(request: Request) {\n try {\n const { theme } = await request.json();\n if (theme !== \"light\" && theme !== \"dark\") {\n return NextResponse.json(\n { ok: false, error: \"Invalid theme\" },\n { status: 400 },\n );\n }\n\n const cookieStore = await cookies();\n cookieStore.set(\"theme\", theme, {\n path: \"/\",\n maxAge: 60 * 60 * 24 * 365,\n sameSite: \"lax\",\n });\n\n return NextResponse.json({ ok: true });\n } catch (e) {\n return NextResponse.json(\n { ok: false, error: \"Bad Request\" },\n { status: 400 },\n );\n }\n}";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const routesTemplate = `import { NextResponse } from "next/server";
|
|
2
|
-
import { cookies } from "next/headers";
|
|
3
|
-
|
|
4
|
-
export async function POST(request: Request) {
|
|
5
|
-
try {
|
|
6
|
-
const { theme } = await request.json();
|
|
7
|
-
if (theme !== "light" && theme !== "dark") {
|
|
8
|
-
return NextResponse.json(
|
|
9
|
-
{ ok: false, error: "Invalid theme" },
|
|
10
|
-
{ status: 400 },
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const cookieStore = await cookies();
|
|
15
|
-
cookieStore.set("theme", theme, {
|
|
16
|
-
path: "/",
|
|
17
|
-
maxAge: 60 * 60 * 24 * 365,
|
|
18
|
-
sameSite: "lax",
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
return NextResponse.json({ ok: true });
|
|
22
|
-
} catch (e) {
|
|
23
|
-
return NextResponse.json(
|
|
24
|
-
{ ok: false, error: "Bad Request" },
|
|
25
|
-
{ status: 400 },
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
}`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const routesTemplate = "import { NextResponse } from \"next/server\";\nimport { cookies } from \"next/headers\";\n\nexport async function POST(request: Request) {\n try {\n const { theme } = await request.json();\n if (theme !== \"light\" && theme !== \"dark\") {\n return NextResponse.json(\n { ok: false, error: \"Invalid theme\" },\n { status: 400 },\n );\n }\n\n const cookieStore = await cookies();\n cookieStore.set(\"theme\", theme, {\n path: \"/\",\n maxAge: 60 * 60 * 24 * 365,\n sameSite: \"lax\",\n });\n\n return NextResponse.json({ ok: true });\n } catch {\n return NextResponse.json(\n { ok: false, error: \"Bad Request\" },\n { status: 400 },\n );\n }\n}\n";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const routesTemplate = `import { NextResponse } from "next/server";
|
|
2
|
-
import { cookies } from "next/headers";
|
|
3
|
-
|
|
4
|
-
export async function POST(request: Request) {
|
|
5
|
-
try {
|
|
6
|
-
const { theme } = await request.json();
|
|
7
|
-
if (theme !== "light" && theme !== "dark") {
|
|
8
|
-
return NextResponse.json(
|
|
9
|
-
{ ok: false, error: "Invalid theme" },
|
|
10
|
-
{ status: 400 },
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const cookieStore = await cookies();
|
|
15
|
-
cookieStore.set("theme", theme, {
|
|
16
|
-
path: "/",
|
|
17
|
-
maxAge: 60 * 60 * 24 * 365,
|
|
18
|
-
sameSite: "lax",
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
return NextResponse.json({ ok: true });
|
|
22
|
-
} catch {
|
|
23
|
-
return NextResponse.json(
|
|
24
|
-
{ ok: false, error: "Bad Request" },
|
|
25
|
-
{ status: 400 },
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const errorTemplate = "\"use client\";\n\nimport { useEffect } from \"react\";\n\nexport default function Error({\n error,\n reset,\n}: {\n error: Error & { digest?: string };\n reset: () => void;\n}) {\n useEffect(() => {\n console.error(\"Unhandled error:\", error);\n }, [error]);\n\n return (\n <div\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minHeight: \"50vh\",\n padding: \"2rem\",\n textAlign: \"center\",\n }}\n >\n <h2 style={{ marginBottom: \"1rem\" }}>Something went wrong</h2>\n <button\n onClick={reset}\n style={{\n padding: \"0.5rem 1rem\",\n borderRadius: \"6px\",\n border: \"1px solid #ccc\",\n background: \"#fff\",\n cursor: \"pointer\",\n fontSize: \"1rem\",\n }}\n >\n Try again\n </button>\n </div>\n );\n}\n";
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const errorTemplate = `"use client";
|
|
2
|
-
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
|
|
5
|
-
export default function Error({
|
|
6
|
-
error,
|
|
7
|
-
reset,
|
|
8
|
-
}: {
|
|
9
|
-
error: Error & { digest?: string };
|
|
10
|
-
reset: () => void;
|
|
11
|
-
}) {
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
console.error("Unhandled error:", error);
|
|
14
|
-
}, [error]);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
style={{
|
|
19
|
-
display: "flex",
|
|
20
|
-
flexDirection: "column",
|
|
21
|
-
alignItems: "center",
|
|
22
|
-
justifyContent: "center",
|
|
23
|
-
minHeight: "50vh",
|
|
24
|
-
padding: "2rem",
|
|
25
|
-
textAlign: "center",
|
|
26
|
-
}}
|
|
27
|
-
>
|
|
28
|
-
<h2 style={{ marginBottom: "1rem" }}>Something went wrong</h2>
|
|
29
|
-
<button
|
|
30
|
-
onClick={reset}
|
|
31
|
-
style={{
|
|
32
|
-
padding: "0.5rem 1rem",
|
|
33
|
-
borderRadius: "6px",
|
|
34
|
-
border: "1px solid #ccc",
|
|
35
|
-
background: "#fff",
|
|
36
|
-
cursor: "pointer",
|
|
37
|
-
fontSize: "1rem",
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
Try again
|
|
41
|
-
</button>
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface SectionConfig {
|
|
2
|
-
label: string;
|
|
3
|
-
slug: string;
|
|
4
|
-
directory?: string;
|
|
5
|
-
}
|
|
6
|
-
interface PageData {
|
|
7
|
-
slug: string;
|
|
8
|
-
title: string;
|
|
9
|
-
description: string;
|
|
10
|
-
date: string | null;
|
|
11
|
-
category: string;
|
|
12
|
-
path: string;
|
|
13
|
-
categoryOrder: number;
|
|
14
|
-
order: number;
|
|
15
|
-
section: string;
|
|
16
|
-
}
|
|
17
|
-
interface GoogleFontConfig {
|
|
18
|
-
fontName?: string;
|
|
19
|
-
subsets?: string[];
|
|
20
|
-
weight?: string | string[];
|
|
21
|
-
}
|
|
22
|
-
interface LocalFontSrc {
|
|
23
|
-
path: string;
|
|
24
|
-
weight: string;
|
|
25
|
-
style: string;
|
|
26
|
-
}
|
|
27
|
-
interface FontConfig {
|
|
28
|
-
googleFont?: GoogleFontConfig;
|
|
29
|
-
localFonts?: string | {
|
|
30
|
-
src?: LocalFontSrc[];
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export declare const layoutTemplate: (pages: PageData[], fontConfig: FontConfig | null, sectionsConfig?: SectionConfig[] | null) => string;
|
|
34
|
-
export {};
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_DESCRIPTION, DEFAULT_FAVICON, DEFAULT_OG_IMAGE, DEFAULT_SITE_NAME, } from "../../lib/constants.js";
|
|
2
|
-
function formatObjectArray(items) {
|
|
3
|
-
const MAX_WIDTH = 80;
|
|
4
|
-
const formatted = items.map((item) => {
|
|
5
|
-
const lines = [" {"];
|
|
6
|
-
const entries = Object.entries(item);
|
|
7
|
-
for (const [key, value] of entries) {
|
|
8
|
-
const valueStr = JSON.stringify(value);
|
|
9
|
-
const line = ` ${key}: ${valueStr},`;
|
|
10
|
-
if (line.length > MAX_WIDTH) {
|
|
11
|
-
lines.push(` ${key}:`);
|
|
12
|
-
lines.push(` ${valueStr},`);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
lines.push(line);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
lines.push(" },");
|
|
19
|
-
return lines.join("\n");
|
|
20
|
-
});
|
|
21
|
-
return "[\n" + formatted.join("\n") + "\n]";
|
|
22
|
-
}
|
|
23
|
-
function isGoogleFont(fc) {
|
|
24
|
-
return !!fc?.googleFont?.fontName;
|
|
25
|
-
}
|
|
26
|
-
function isLocalFont(fc) {
|
|
27
|
-
if (!fc?.localFonts)
|
|
28
|
-
return false;
|
|
29
|
-
if (typeof fc.localFonts === "string")
|
|
30
|
-
return true;
|
|
31
|
-
return !!fc.localFonts.src?.length;
|
|
32
|
-
}
|
|
33
|
-
function getLocalFontSrc(fc) {
|
|
34
|
-
if (typeof fc.localFonts === "string")
|
|
35
|
-
return `"${fc.localFonts}"`;
|
|
36
|
-
return JSON.stringify(fc.localFonts?.src, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
37
|
-
}
|
|
38
|
-
export const layoutTemplate = (pages, fontConfig, sectionsConfig = null) => {
|
|
39
|
-
const hasSections = sectionsConfig !== null && sectionsConfig.length > 0;
|
|
40
|
-
return `import type { Metadata } from "next";
|
|
41
|
-
${isGoogleFont(fontConfig) ? `import { ${fontConfig.googleFont.fontName} } from "next/font/google";` : isLocalFont(fontConfig) ? 'import localFont from "next/font/local";' : 'import { Inter } from "next/font/google";'}
|
|
42
|
-
import dynamic from "next/dynamic";
|
|
43
|
-
import { StyledComponentsRegistry } from "cherry-styled-components";
|
|
44
|
-
import { theme, themeDark } from "@/app/theme";
|
|
45
|
-
import { CherryThemeProvider } from "@/components/layout/CherryThemeProvider";
|
|
46
|
-
import { ChtProvider } from "@/components/Chat";
|
|
47
|
-
${hasSections
|
|
48
|
-
? ""
|
|
49
|
-
: `import { Footer } from "@/components/layout/Footer";
|
|
50
|
-
`}import { Header } from "@/components/layout/Header";
|
|
51
|
-
import {
|
|
52
|
-
DocsWrapper,
|
|
53
|
-
SectionBarProvider,
|
|
54
|
-
} from "@/components/layout/DocsComponents";
|
|
55
|
-
${hasSections
|
|
56
|
-
? ""
|
|
57
|
-
: `import { SideBar } from "@/components/SideBar";
|
|
58
|
-
import { DocsNavigation } from "@/components/layout/DocsNavigation";
|
|
59
|
-
`}import {
|
|
60
|
-
transformPagesToGroupedStructure,
|
|
61
|
-
type PagesProps,
|
|
62
|
-
} from "@/utils/orderNavItems";
|
|
63
|
-
${hasSections
|
|
64
|
-
? ""
|
|
65
|
-
: `import { StaticLinks } from "@/components/layout/StaticLinks";
|
|
66
|
-
`}import { config } from "@/utils/config";
|
|
67
|
-
import { verifyBrandingKey } from "@/utils/branding";
|
|
68
|
-
import navigation from "@/navigation.json";
|
|
69
|
-
${hasSections
|
|
70
|
-
? `import { SectionBar } from "@/components/layout/SectionBar";
|
|
71
|
-
import { SectionNavProvider } from "@/components/SectionNavProvider";
|
|
72
|
-
`
|
|
73
|
-
: ""}const Chat = dynamic(() => import("@/components/Chat").then((mod) => mod.Chat));
|
|
74
|
-
|
|
75
|
-
${isGoogleFont(fontConfig)
|
|
76
|
-
? `const font = ${fontConfig.googleFont.fontName}({ ${[fontConfig.googleFont.subsets?.length ? `subsets: ${JSON.stringify(fontConfig.googleFont.subsets)}` : "", fontConfig.googleFont.weight?.length ? `weight: ${Array.isArray(fontConfig.googleFont.weight) ? JSON.stringify(fontConfig.googleFont.weight) : `"${fontConfig.googleFont.weight}"`}` : ""].filter(Boolean).join(", ")} });`
|
|
77
|
-
: isLocalFont(fontConfig)
|
|
78
|
-
? `const font = localFont({
|
|
79
|
-
src: ${getLocalFontSrc(fontConfig)},
|
|
80
|
-
});`
|
|
81
|
-
: 'const font = Inter({ subsets: ["latin"] });'}
|
|
82
|
-
|
|
83
|
-
export const metadata: Metadata = {
|
|
84
|
-
title: config.name || "${DEFAULT_SITE_NAME}",
|
|
85
|
-
description:
|
|
86
|
-
config.description ||
|
|
87
|
-
"${DEFAULT_DESCRIPTION}",
|
|
88
|
-
icons: config.icon || "${DEFAULT_FAVICON}",
|
|
89
|
-
openGraph: {
|
|
90
|
-
title: config.name || "${DEFAULT_SITE_NAME}",
|
|
91
|
-
description:
|
|
92
|
-
config.description ||
|
|
93
|
-
"${DEFAULT_DESCRIPTION}",
|
|
94
|
-
images: config.image || "${DEFAULT_OG_IMAGE}",
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const doccupinePages = ${formatObjectArray(pages)};${hasSections ? `\nconst doccupineSections = ${formatObjectArray(sectionsConfig)};` : ""}
|
|
99
|
-
|
|
100
|
-
export default async function RootLayout({
|
|
101
|
-
children,
|
|
102
|
-
}: Readonly<{
|
|
103
|
-
children: React.ReactNode;
|
|
104
|
-
}>) {
|
|
105
|
-
const hideBranding = verifyBrandingKey();
|
|
106
|
-
${hasSections
|
|
107
|
-
? `
|
|
108
|
-
const pages: PagesProps[] = doccupinePages;
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<html lang="en">
|
|
112
|
-
<body className={font.className}>
|
|
113
|
-
<StyledComponentsRegistry>
|
|
114
|
-
<CherryThemeProvider theme={theme} themeDark={themeDark}>
|
|
115
|
-
<ChtProvider isChatActive={process.env.LLM_PROVIDER ? true : false}>
|
|
116
|
-
<Header>
|
|
117
|
-
<SectionBar sections={doccupineSections} />
|
|
118
|
-
</Header>
|
|
119
|
-
{process.env.LLM_PROVIDER && <Chat />}
|
|
120
|
-
<DocsWrapper>
|
|
121
|
-
<SectionNavProvider
|
|
122
|
-
sections={doccupineSections}
|
|
123
|
-
allPages={pages}
|
|
124
|
-
hideBranding={hideBranding}
|
|
125
|
-
>
|
|
126
|
-
{children}
|
|
127
|
-
</SectionNavProvider>
|
|
128
|
-
</DocsWrapper>
|
|
129
|
-
</ChtProvider>
|
|
130
|
-
</CherryThemeProvider>
|
|
131
|
-
</StyledComponentsRegistry>
|
|
132
|
-
</body>
|
|
133
|
-
</html>
|
|
134
|
-
);
|
|
135
|
-
}`
|
|
136
|
-
: `
|
|
137
|
-
const defaultPages = [
|
|
138
|
-
{
|
|
139
|
-
slug: "",
|
|
140
|
-
title: "Getting Started",
|
|
141
|
-
description:
|
|
142
|
-
"${DEFAULT_DESCRIPTION}",
|
|
143
|
-
date: "2025-01-15",
|
|
144
|
-
category: "Introduction",
|
|
145
|
-
categoryOrder: 0,
|
|
146
|
-
order: 0,
|
|
147
|
-
},
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
const pages: PagesProps[] = doccupinePages;
|
|
151
|
-
const result =
|
|
152
|
-
Array.isArray(navigation) && navigation.length
|
|
153
|
-
? navigation
|
|
154
|
-
: transformPagesToGroupedStructure(pages);
|
|
155
|
-
const defaultResults = transformPagesToGroupedStructure(defaultPages);
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<html lang="en">
|
|
159
|
-
<body className={font.className}>
|
|
160
|
-
<StyledComponentsRegistry>
|
|
161
|
-
<CherryThemeProvider theme={theme} themeDark={themeDark}>
|
|
162
|
-
<ChtProvider isChatActive={process.env.LLM_PROVIDER ? true : false}>
|
|
163
|
-
<Header />
|
|
164
|
-
{process.env.LLM_PROVIDER && <Chat />}
|
|
165
|
-
<SectionBarProvider hasSectionBar={false}>
|
|
166
|
-
<DocsWrapper>
|
|
167
|
-
<SideBar result={result.length ? result : defaultResults} />
|
|
168
|
-
{children}
|
|
169
|
-
<DocsNavigation
|
|
170
|
-
result={result.length ? result : defaultResults}
|
|
171
|
-
/>
|
|
172
|
-
<StaticLinks />
|
|
173
|
-
<Footer hideBranding={hideBranding} />
|
|
174
|
-
</DocsWrapper>
|
|
175
|
-
</SectionBarProvider>
|
|
176
|
-
</ChtProvider>
|
|
177
|
-
</CherryThemeProvider>
|
|
178
|
-
</StyledComponentsRegistry>
|
|
179
|
-
</body>
|
|
180
|
-
</html>
|
|
181
|
-
);
|
|
182
|
-
}`}
|
|
183
|
-
`;
|
|
184
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const calloutsMdxTemplate = "---\ntitle: \"Callouts\"\ndescription: \"Doccupine CLI commands\"\ndate: \"2025-01-15\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 7\n---\n# Callouts\nMake your content stand out by using callouts for extra emphasis.\n\nYou can format them as Note, Warning, Info, Danger and Success.\n\n## Callouts Usage\nYou can use the Callouts component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Callout type=\"note\">\n This is a note callout\n</Callout>\n\n<Callout type=\"warning\">\n This is a warning callout\n</Callout>\n\n<Callout type=\"info\">\n This is an info callout\n</Callout>\n\n<Callout type=\"danger\">\n This is a danger callout\n</Callout>\n\n<Callout type=\"success\">\n This is a success callout\n</Callout>\n~~~\n\n<Callout type=\"note\">\n This is a note callout\n</Callout>\n\n<Callout type=\"warning\">\n This is a warning callout\n</Callout>\n\n<Callout type=\"info\">\n This is an info callout\n</Callout>\n\n<Callout type=\"danger\">\n This is a danger callout\n</Callout>\n\n<Callout type=\"success\">\n This is a success callout\n</Callout>";
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export const calloutsMdxTemplate = `---
|
|
2
|
-
title: "Callouts"
|
|
3
|
-
description: "Doccupine CLI commands"
|
|
4
|
-
date: "2025-01-15"
|
|
5
|
-
category: "Components"
|
|
6
|
-
categoryOrder: 1
|
|
7
|
-
order: 7
|
|
8
|
-
---
|
|
9
|
-
# Callouts
|
|
10
|
-
Make your content stand out by using callouts for extra emphasis.
|
|
11
|
-
|
|
12
|
-
You can format them as Note, Warning, Info, Danger and Success.
|
|
13
|
-
|
|
14
|
-
## Callouts Usage
|
|
15
|
-
You can use the Callouts component directly within your MDX files without any import. The following example shows a basic usage:
|
|
16
|
-
|
|
17
|
-
~~~mdx
|
|
18
|
-
<Callout type="note">
|
|
19
|
-
This is a note callout
|
|
20
|
-
</Callout>
|
|
21
|
-
|
|
22
|
-
<Callout type="warning">
|
|
23
|
-
This is a warning callout
|
|
24
|
-
</Callout>
|
|
25
|
-
|
|
26
|
-
<Callout type="info">
|
|
27
|
-
This is an info callout
|
|
28
|
-
</Callout>
|
|
29
|
-
|
|
30
|
-
<Callout type="danger">
|
|
31
|
-
This is a danger callout
|
|
32
|
-
</Callout>
|
|
33
|
-
|
|
34
|
-
<Callout type="success">
|
|
35
|
-
This is a success callout
|
|
36
|
-
</Callout>
|
|
37
|
-
~~~
|
|
38
|
-
|
|
39
|
-
<Callout type="note">
|
|
40
|
-
This is a note callout
|
|
41
|
-
</Callout>
|
|
42
|
-
|
|
43
|
-
<Callout type="warning">
|
|
44
|
-
This is a warning callout
|
|
45
|
-
</Callout>
|
|
46
|
-
|
|
47
|
-
<Callout type="info">
|
|
48
|
-
This is an info callout
|
|
49
|
-
</Callout>
|
|
50
|
-
|
|
51
|
-
<Callout type="danger">
|
|
52
|
-
This is a danger callout
|
|
53
|
-
</Callout>
|
|
54
|
-
|
|
55
|
-
<Callout type="success">
|
|
56
|
-
This is a success callout
|
|
57
|
-
</Callout>`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const cardsMdxTemplate = "---\ntitle: \"Cards\"\ndescription: \"Doccupine CLI commands\"\ndate: \"2025-01-15\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 6\n---\n# Cards\nDuplicate a page or section with ease, then emphasize important information or links using customizable layouts and icons.\n\nCards act as visual containers for your content, giving you flexibility to combine text, icons, images, and links in a clean and organized way.\n\n## Cards Usage\nYou can use the Cards component directly within your MDX files without any import. The following example shows a basic usage:\n\n~~~mdx\n<Card title=\"Note\" icon=\"BadgeInfo\">\n Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.\n</Card>\n~~~\n\n<Card title=\"Note\" icon=\"BadgeInfo\">\n Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.\n</Card>";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const cardsMdxTemplate = `---
|
|
2
|
-
title: "Cards"
|
|
3
|
-
description: "Doccupine CLI commands"
|
|
4
|
-
date: "2025-01-15"
|
|
5
|
-
category: "Components"
|
|
6
|
-
categoryOrder: 1
|
|
7
|
-
order: 6
|
|
8
|
-
---
|
|
9
|
-
# Cards
|
|
10
|
-
Duplicate a page or section with ease, then emphasize important information or links using customizable layouts and icons.
|
|
11
|
-
|
|
12
|
-
Cards act as visual containers for your content, giving you flexibility to combine text, icons, images, and links in a clean and organized way.
|
|
13
|
-
|
|
14
|
-
## Cards Usage
|
|
15
|
-
You can use the Cards component directly within your MDX files without any import. The following example shows a basic usage:
|
|
16
|
-
|
|
17
|
-
~~~mdx
|
|
18
|
-
<Card title="Note" icon="BadgeInfo">
|
|
19
|
-
Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.
|
|
20
|
-
</Card>
|
|
21
|
-
~~~
|
|
22
|
-
|
|
23
|
-
<Card title="Note" icon="BadgeInfo">
|
|
24
|
-
Doccupine CLI is a command-line tool that helps you create and manage your Doccupine project. It provides a simple and intuitive interface for creating and configuring your project.
|
|
25
|
-
</Card>`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const clickOutsideTemplate = "\nimport { RefObject, useEffect } from \"react\";\n\nexport function useOnClickOutside(\n refs: RefObject<HTMLElement | null>[],\n cb: () => void,\n) {\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (\n refs &&\n refs\n .map(\n (ref) =>\n ref && ref.current && ref.current.contains(event.target as Node),\n )\n .every((i) => i === false)\n ) {\n cb();\n }\n }\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [refs, cb]);\n}\n";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const clickOutsideTemplate = `
|
|
2
|
-
import { RefObject, useEffect } from "react";
|
|
3
|
-
|
|
4
|
-
export function useOnClickOutside(
|
|
5
|
-
refs: RefObject<HTMLElement | null>[],
|
|
6
|
-
cb: () => void,
|
|
7
|
-
) {
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
function handleClickOutside(event: MouseEvent) {
|
|
10
|
-
if (
|
|
11
|
-
refs &&
|
|
12
|
-
refs
|
|
13
|
-
.map(
|
|
14
|
-
(ref) =>
|
|
15
|
-
ref && ref.current && ref.current.contains(event.target as Node),
|
|
16
|
-
)
|
|
17
|
-
.every((i) => i === false)
|
|
18
|
-
) {
|
|
19
|
-
cb();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
23
|
-
return () => {
|
|
24
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
25
|
-
};
|
|
26
|
-
}, [refs, cb]);
|
|
27
|
-
}
|
|
28
|
-
`;
|
package/dist/templates/code.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const codeTemplate = "\"use client\";\n\"use client\";\nimport styled from \"styled-components\";\nimport { Theme, styledCode } from \"cherry-styled-components/src/lib\";\nimport { rgba } from \"polished\";\nimport { unified } from \"unified\";\nimport rehypeParse from \"rehype-parse\";\nimport rehypeHighlight from \"rehype-highlight\";\nimport rehypeStringify from \"rehype-stringify\";\nimport { editableContent } from \"@/app/components/layout/SharedStyled\";\n\ninterface CodeProps extends React.HTMLAttributes<HTMLDivElement> {\n code: string;\n language?: string;\n theme?: Theme;\n}\n\nconst CodeWrapper = styled.span<{ theme: Theme }>`\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n border: solid 1px\n ${({ theme }) =>\n theme.isDark ? rgba(theme.colors.dark, 0.2) : rgba(theme.colors.dark, 0)};\n`;\n\nconst TopBar = styled.div<{ theme: Theme }>`\n background: #0d1117;\n border-top-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-top-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom: solid 1px ${rgba(\"#ffffff\", 0.1)};\n height: 33px;\n width: 100%;\n display: flex;\n justify-content: flex-start;\n gap: 5px;\n padding: 10px;\n`;\n\nconst Dot = styled.span<{ theme: Theme }>`\n margin: auto 0;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: ${rgba(\"#ffffff\", 0.1)};\n`;\n\nconst Body = styled.div<{ theme: Theme }>`\n background: #0d1117;\n border-bottom-left-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom-right-radius: ${({ theme }) => theme.spacing.radius.lg};\n color: #ffffff;\n padding: 20px;\n font-family: ${({ theme }) => theme.fonts.mono};\n text-align: left;\n overflow-x: auto;\n overflow-y: auto;\n max-height: calc(100svh - 400px);\n ${({ theme }) => styledCode(theme)};\n\n &[contenteditable=\"true\"] {\n ${editableContent};\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n\n & .hljs {\n color: #c9d1d9;\n background: #0d1117;\n }\n\n & .hljs-doctag,\n & .hljs-keyword,\n & .hljs-meta .hljs-keyword,\n & .hljs-template-tag,\n & .hljs-template-variable,\n & .hljs-type,\n & .hljs-variable.language_ {\n color: #ff7b72;\n }\n\n & .hljs-title,\n & .hljs-title.class_,\n & .hljs-title.class_.inherited__,\n & .hljs-title.function_ {\n color: #d2a8ff;\n }\n\n & .hljs-attr,\n & .hljs-attribute,\n & .hljs-literal,\n & .hljs-meta,\n & .hljs-number,\n & .hljs-operator,\n & .hljs-selector-attr,\n & .hljs-selector-class,\n & .hljs-selector-id,\n & .hljs-variable {\n color: #79c0ff;\n }\n\n & .hljs-meta .hljs-string,\n & .hljs-regexp,\n & .hljs-string {\n color: #a5d6ff;\n }\n\n & .hljs-built_in,\n & .hljs-symbol {\n color: #ffa657;\n }\n\n & .hljs-code,\n & .hljs-comment,\n & .hljs-formula {\n color: #8b949e;\n }\n\n & .hljs-name,\n & .hljs-quote,\n & .hljs-selector-pseudo,\n & .hljs-selector-tag {\n color: #7ee787;\n }\n\n & .hljs-subst {\n color: #c9d1d9;\n }\n\n & .hljs-section {\n color: #1f6feb;\n font-weight: 700;\n }\n\n & .hljs-bullet {\n color: #f2cc60;\n }\n\n & .hljs-emphasis {\n color: #c9d1d9;\n font-style: italic;\n }\n\n & .hljs-strong {\n color: #c9d1d9;\n font-weight: 700;\n }\n\n & .hljs-addition {\n color: #aff5b4;\n background-color: #033a16;\n }\n\n & .hljs-deletion {\n color: #ffdcd7;\n background-color: #67060c;\n }\n`;\n\nconst highlightCode = (code: string, language: string): string => {\n const result = unified()\n .use(rehypeParse, { fragment: true })\n .use(rehypeHighlight, {\n detect: true,\n ignoreMissing: true,\n })\n .use(rehypeStringify)\n .processSync(\n `<pre><code class=\"language-${language}\">${code}</code></pre>`,\n );\n\n return String(result);\n};\n\nfunction Code({ code, language = \"javascript\", ...props }: CodeProps) {\n const highlightedCode = highlightCode(code, language);\n return (\n <CodeWrapper>\n <TopBar>\n <Dot />\n <Dot />\n <Dot />\n </TopBar>\n <Body dangerouslySetInnerHTML={{ __html: highlightedCode }} {...props} />\n </CodeWrapper>\n );\n}\n\nexport { Code };\n";
|