Skip to content

Commit 9f4641b

Browse files
committed
updated all docs with new code gen arc
1 parent f66e8d9 commit 9f4641b

23 files changed

+52
-72
lines changed

components/ComponentShowcase.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface IComponentShowcase extends HTMLAttributes<HTMLDivElement> {
77
}
88

99
export function ComponentShowcase({ name, children }: IComponentShowcase) {
10-
const { preview: Preview, codeHtml } = componentConfig.registry[name];
10+
const { preview: Preview } = componentConfig.registry[name];
1111
const Code = React.Children.toArray(children)[0];
1212

1313
return (

config/components.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ export const componentConfig = {
8888
name: "button-style-default",
8989
filePath: "preview/components/button-style-default.tsx",
9090
preview: lazy(() => import("@/preview/components/button-style-default")),
91-
codeHtml: `<button className="bg-primary-400 text-black px-6 py-2 text-base font-head border-2 border-black shadow-md hover:shadow-xs hover:bg-primary-500 transition-all">
92-
Click Me!
93-
</button>`,
9491
},
9592
"card-style-default": {
9693
name: "card-style-default",

content/docs/components/accordion.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Default Accordion
33
description: This collapsible component let's your users read only the content they care about. 😌
4-
lastUpdated: 30 Sep, 2024
4+
lastUpdated: 7 Oct, 2024
55
---
66

77
<ComponentShowcase name="accordion-style-default" />

content/docs/components/avatar.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Default Avatar
33
description: Default rounded avatar that can show your users profile picture. ✨
4-
lastUpdated: 30 Sep, 2024
4+
lastUpdated: 7 Oct, 2024
55
---
66

77
<ComponentShowcase name="avatar-style-circle" />

content/docs/components/badge.mdx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
---
22
title: Badge
33
description: The component that looks like a button but isn't clickable!
4-
lastUpdated: 4 Oct, 2024
4+
lastUpdated: 7 Oct, 2024
55
---
66

77
## Default
8-
<hr/>
9-
<br/>
8+
9+
<hr />
10+
<br />
1011
<ComponentShowcase name="badge-style-default" />
11-
<br/>
12-
<br/>
12+
<br />
13+
<br />
1314

1415
## Success
15-
<hr/>
16-
<br/>
16+
17+
<hr />
18+
<br />
1719
<ComponentShowcase name="badge-style-success" />
18-
<br/>
19-
<br/>
20+
<br />
21+
<br />
2022

2123
## Error
22-
<hr/>
23-
<br/>
24+
25+
<hr />
26+
<br />
2427
<ComponentShowcase name="badge-style-error" />
25-
<br/>
26-
<br/>
28+
<br />
29+
<br />
2730

2831
## Filled
32+
2933
<hr />
3034
<br />
3135
<ComponentShowcase name="badge-style-filled" />

content/docs/components/card.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Default Card
33
description: A customizable card component to visualize your content. 📝
4-
lastUpdated: 30 Sep, 2024
4+
lastUpdated: 7 Oct, 2024
55
---
66

7-
<ComponentShowcase name="card-style-default" />
7+
<ComponentShowcase name="card-style-default" />

content/docs/components/input.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Default Input
33
description: This pretty input makes your users want to type stuff! ⌨️
4-
lastUpdated: 30 Sep, 2024
4+
lastUpdated: 07 Oct, 2024
55
---
66

77
<ComponentShowcase name="input-style-default" />

content/docs/components/textarea.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Default Textarea
33
description: This pretty input makes your users want to type lots of stuff! ⌨️ ⌨️
4-
lastUpdated: 30 Sep, 2024
4+
lastUpdated: 07 Oct, 2024
55
---
66

77
<ComponentShowcase name="textarea-style-default" />

content/docs/components/typography.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Typography
33
description: Show your texts in different styles. 💅
4-
lastUpdated: 30 Sep, 2024
4+
lastUpdated: 7 Oct, 2024
55
---
66

77
## Headings

contentlayer.config.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from "path";
22
import fs from "fs";
33
import { defineDocumentType, makeSource } from "contentlayer/source-files";
44
import { visit } from "unist-util-visit";
5-
import { u } from "unist-builder"
5+
import { u } from "unist-builder";
66
import { UnistNode } from "./types/unist";
77
import { componentConfig } from "./config";
88

@@ -29,7 +29,6 @@ export default makeSource({
2929
() => (tree) => {
3030
visit(tree, (node: UnistNode) => {
3131
if (node.name === "ComponentShowcase" && node.attributes) {
32-
console.log(JSON.stringify(node));
3332
const name = getNodeAttributeByName(node, "name")
3433
?.value as keyof typeof componentConfig.registry;
3534

@@ -40,6 +39,15 @@ export default makeSource({
4039
const component = componentConfig.registry[name];
4140
const filePath = path.join(process.cwd(), component.filePath);
4241
const source = fs.readFileSync(filePath, "utf8");
42+
const cleanedJSX = source
43+
.replace(/export default function \w+\(\) \{\n?/g, "") // removes function wrapper
44+
.replace(/return\s*\(\s*/g, "") // removes return statement
45+
.replace(/\n\s*\);?\s*\}\s*$/g, "") // Removes closing parenthesis, semicolon, and closing brace at the end of the function
46+
.replace(/\n\s*\n/g, "\n") // removes extra new lines
47+
.trim()
48+
.split("\n")
49+
.map((line) => line.replace(/^ {4}/gm, ""))
50+
.join("\n");
4351

4452
node.children?.push(
4553
u("element", {
@@ -56,15 +64,13 @@ export default makeSource({
5664
children: [
5765
{
5866
type: "text",
59-
value: source,
67+
value: cleanedJSX,
6068
},
6169
],
6270
}),
6371
],
6472
})
6573
);
66-
67-
console.log(JSON.stringify(node));
6874
}
6975
});
7076
return null;

0 commit comments

Comments
 (0)