Skip to content

Commit 0c9bb4f

Browse files
committed
Add alert
1 parent 13a2a23 commit 0c9bb4f

6 files changed

Lines changed: 488 additions & 25 deletions

File tree

apps/docs/source.config.ts

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import remarkDirective from 'remark-directive';
1+
import remarkDirective from "remark-directive";
22
import {
33
remarkDirectiveAdmonition,
44
remarkMdxFiles,
5-
} from 'fumadocs-core/mdx-plugins';
6-
import { remarkImage } from 'fumadocs-core/mdx-plugins';
5+
} from "fumadocs-core/mdx-plugins";
6+
import { remarkImage } from "fumadocs-core/mdx-plugins";
77
import {
88
defineConfig,
99
defineDocs,
1010
frontmatterSchema,
1111
metaSchema,
12-
} from 'fumadocs-mdx/config';
13-
import lastModified from 'fumadocs-mdx/plugins/last-modified';
14-
import { z } from 'zod';
15-
import convert from 'npm-to-yarn';
12+
} from "fumadocs-mdx/config";
13+
import lastModified from "fumadocs-mdx/plugins/last-modified";
14+
import { z } from "zod";
15+
import convert from "npm-to-yarn";
1616

1717
// You can customise Zod schemas for frontmatter and `meta.json` here
1818
// see https://fumadocs.dev/docs/mdx/collections
1919
export const docs = defineDocs({
20-
dir: 'content/docs',
20+
dir: "content/docs",
2121
docs: {
2222
schema: frontmatterSchema.extend({
2323
image: z.string().optional(),
24-
badge: z.enum(['early-access', 'deprecated', 'preview']).optional(),
24+
badge: z.enum(["early-access", "deprecated", "preview"]).optional(),
2525
url: z.string(),
2626
metaTitle: z.string(),
2727
metaDescription: z.string(),
@@ -37,11 +37,11 @@ export const docs = defineDocs({
3737

3838
// v6 docs collection
3939
export const docsV6 = defineDocs({
40-
dir: 'content/docs.v6',
40+
dir: "content/docs.v6",
4141
docs: {
4242
schema: frontmatterSchema.extend({
4343
image: z.string().optional(),
44-
badge: z.enum(['early-access', 'deprecated', 'preview']).optional(),
44+
badge: z.enum(["early-access", "deprecated", "preview"]).optional(),
4545
url: z.string(),
4646
metaTitle: z.string().optional(),
4747
metaDescription: z.string().optional(),
@@ -60,7 +60,22 @@ export default defineConfig({
6060
mdxOptions: {
6161
remarkPlugins: [
6262
remarkDirective,
63-
remarkDirectiveAdmonition,
63+
[
64+
remarkDirectiveAdmonition,
65+
{
66+
types: {
67+
note: "info",
68+
tip: "info",
69+
info: "info",
70+
warn: "warning",
71+
warning: "warning",
72+
danger: "error",
73+
success: "success",
74+
ppg: "ppg",
75+
error: "error",
76+
},
77+
},
78+
],
6479
[remarkImage, { useImport: false }],
6580
remarkMdxFiles,
6681
],
@@ -69,19 +84,19 @@ export default defineConfig({
6984
},
7085
remarkNpmOptions: {
7186
persist: {
72-
id: 'package-manager',
87+
id: "package-manager",
7388
},
7489
packageManagers: [
75-
{ command: (cmd: string) => convert(cmd, 'npm'), name: 'npm' },
76-
{ command: (cmd: string) => convert(cmd, 'pnpm'), name: 'pnpm' },
77-
{ command: (cmd: string) => convert(cmd, 'yarn'), name: 'yarn' },
90+
{ command: (cmd: string) => convert(cmd, "npm"), name: "npm" },
91+
{ command: (cmd: string) => convert(cmd, "pnpm"), name: "pnpm" },
92+
{ command: (cmd: string) => convert(cmd, "yarn"), name: "yarn" },
7893
{
7994
command: (cmd: string) => {
80-
const converted = convert(cmd, 'bun');
95+
const converted = convert(cmd, "bun");
8196
if (!converted) return undefined;
82-
return converted.replace(/^bun x /, 'bunx --bun ');
97+
return converted.replace(/^bun x /, "bunx --bun ");
8398
},
84-
name: 'bun',
99+
name: "bun",
85100
},
86101
],
87102
},

apps/docs/src/mdx-components.tsx

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ import {
2727
TableCell,
2828
TableCaption,
2929
Input,
30+
Alert,
3031
} from "@prisma-docs/eclipse";
3132

3233
export function getMDXComponents(components?: MDXComponents): MDXComponents {
33-
const mdxComponents = {
34+
const pageContext = (components as any)?._pageContext;
35+
36+
return {
3437
...(icons as unknown as MDXComponents),
3538
...defaultMdxComponents,
3639
// Fumadocs tabs for manual usage (with items prop)
@@ -50,11 +53,6 @@ export function getMDXComponents(components?: MDXComponents): MDXComponents {
5053
APIPage,
5154
img: (props: any) => <ImageZoom {...(props as any)} />,
5255
input: (props: any) => <Input {...props} />,
53-
};
54-
55-
const pageContext = (components as any)?._pageContext;
56-
57-
return {
5856
...mdxComponents,
5957
pre: ({ ref: _ref, ...props }) => (
6058
<CodeBlock {...props}>
@@ -69,5 +67,29 @@ export function getMDXComponents(components?: MDXComponents): MDXComponents {
6967
th: ({ ref: _ref, ...props }) => <TableHead {...props} />,
7068
td: ({ ref: _ref, ...props }) => <TableCell {...props} />,
7169
caption: ({ ref: _ref, ...props }) => <TableCaption {...props} />,
70+
// Override Fumadocs Callout components with Eclipse Alert for admonitions (:::ppg, :::error, :::success, :::warning)
71+
CalloutTitle: ({ children }: any) => <>{children}</>,
72+
CalloutDescription: ({ children }: any) => <>{children}</>,
73+
CalloutContainer: ({ type, children, icon, ...props }: any) => {
74+
const variantMap: Record<
75+
string,
76+
"ppg" | "error" | "success" | "warning"
77+
> = {
78+
ppg: "ppg",
79+
error: "error",
80+
success: "success",
81+
warning: "warning",
82+
info: "ppg",
83+
note: "ppg",
84+
tip: "success",
85+
danger: "error",
86+
};
87+
88+
return (
89+
<Alert variant={variantMap[type] || "ppg"} icon={icon} {...props}>
90+
{children}
91+
</Alert>
92+
);
93+
},
7294
};
7395
}

0 commit comments

Comments
 (0)