Skip to content

Commit ce41faa

Browse files
committed
added syntex hightlighting
1 parent 68dbd2e commit ce41faa

File tree

10 files changed

+109
-44
lines changed

10 files changed

+109
-44
lines changed

app/(docs)/docs/[[...slug]]/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import MDX from "@/components/MDX";
66
import { H2 } from "@/packages/ui";
77

88
function getDocParams(slug: string) {
9-
console.log(slug);
109
const doc = allDocs.find((doc) => doc.url === slug);
1110

1211
if (!doc) {

app/global.css

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,69 @@
1212
text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000,
1313
2px 2px 0 #000; /* Black outline */
1414
}
15+
16+
/* Syntax Highlighting stuff */
17+
18+
pre code.hljs {
19+
display: block;
20+
overflow-x: auto;
21+
padding: 1em
22+
}
23+
code.hljs {
24+
padding: 3px 5px
25+
}
26+
27+
.hljs {
28+
background: #222;
29+
color: #aaa
30+
}
31+
.hljs-subst {
32+
color: #aaa
33+
}
34+
.hljs-section {
35+
color: #fff
36+
}
37+
.hljs-comment,
38+
.hljs-quote,
39+
.hljs-meta {
40+
color: #444
41+
}
42+
.hljs-string,
43+
.hljs-symbol,
44+
.hljs-bullet,
45+
.hljs-regexp {
46+
color: #ffcc33
47+
}
48+
.hljs-number,
49+
.hljs-addition {
50+
color: #00cc66
51+
}
52+
.hljs-built_in,
53+
.hljs-literal,
54+
.hljs-type,
55+
.hljs-template-variable,
56+
.hljs-attribute,
57+
.hljs-link {
58+
color: #32aaee
59+
}
60+
.hljs-keyword,
61+
.hljs-selector-tag,
62+
.hljs-name,
63+
.hljs-selector-id,
64+
.hljs-selector-class {
65+
color: #6644aa
66+
}
67+
.hljs-title,
68+
.hljs-variable,
69+
.hljs-deletion,
70+
.hljs-template-tag {
71+
color: #bb1166
72+
}
73+
.hljs-section,
74+
.hljs-doctag,
75+
.hljs-strong {
76+
font-weight: bold
77+
}
78+
.hljs-emphasis {
79+
font-style: italic
80+
}

components/ComponentShowcase.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
// import { Code } from "bright";
12
import { componentConfig } from "@/config";
3+
import dynamic from "next/dynamic";
24
import { H5 } from "@/packages/ui";
3-
import React, { HTMLAttributes } from "react";
5+
import React, { HTMLAttributes, Suspense } from "react";
6+
const Code = dynamic(() => import("bright").then(mod => mod.Code));
47

58
interface IComponentShowcase extends HTMLAttributes<HTMLDivElement> {
69
name: keyof typeof componentConfig.registry;
@@ -19,10 +22,10 @@ export function ComponentShowcase({ name }: IComponentShowcase) {
1922

2023
<div>
2124
<H5>Code</H5>
22-
<div className="mt-2 border relative rounded p-6 bg-[#222222] text-zinc-200 overflow-auto">
23-
<code>
24-
<pre>{codeHtml}</pre>
25-
</code>
25+
<div className="relative rounded overflow-auto">
26+
<Suspense fallback={<div>Loading...</div>}>
27+
<Code lang="html" theme="dracula-soft">{codeHtml}</Code>
28+
</Suspense>
2629
</div>
2730
</div>
2831
</div>

components/MDX.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { H1, H2, H3, H4, H5, H6 } from "@/packages/ui";
22
import { useMDXComponent } from "next-contentlayer/hooks";
33
import React, { HTMLAttributes } from "react";
4+
import { ComponentShowcase } from "./ComponentShowcase";
5+
import dynamic from "next/dynamic";
6+
const Code = dynamic(() => import("bright").then(mod => mod.Code));
47

58
const components = {
69
h1: H1,
@@ -11,6 +14,8 @@ const components = {
1114
h4: H4,
1215
h5: H5,
1316
h6: H6,
17+
pre: Code,
18+
ComponentShowcase
1419
};
1520

1621
export default function MDX({ code }: { code: string }) {

components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * from "./ComponentShowcase";
2-
export * from "./JoinNewsletter";
2+
export * from "./JoinNewsletter";

content/docs/components/accordion.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ description: This collapsible component let's your users read only the content t
44
lastUpdated: 30 Sep, 2024
55
---
66

7-
import {ComponentShowcase} from "@/components"
8-
9-
<ComponentShowcase name="accordion-style-default" />
7+
<ComponentShowcase name="accordion-style-default" />

content/docs/components/button.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ title: Default Button
33
description: This bold button makes sure your users click on it and perform the actions you want! 🚀
44
lastUpdated: 30 Sep, 2024
55
---
6+
"use client"
67

78
import {ComponentShowcase} from "@/components"
89

9-
<ComponentShowcase name="button-style-default" />
10+
<ComponentShowcase name="button-style-default" />

content/docs/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Installation form Google Fonts:
1515
```
1616

1717
Save the fonts in `global.css`:
18+
1819
```
1920
:root {
2021
--font-head: "Archivo Black", sans-serif;
@@ -25,6 +26,7 @@ Save the fonts in `global.css`:
2526
<br />
2627

2728
### 2. Add the theme to your tailwind.config.js file.
29+
2830
```
2931
import type { Config } from "tailwindcss";
3032

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"bright": "^0.8.5",
1213
"contentlayer": "^0.3.4",
1314
"date-fns": "^4.1.0",
1415
"lucide-react": "^0.445.0",
1516
"next": "14.2.7",
1617
"next-contentlayer": "^0.3.4",
1718
"react": "^18",
18-
"react-dom": "^18",
19-
"react-element-to-jsx-string": "^15.0.0"
19+
"react-dom": "^18"
2020
},
2121
"devDependencies": {
2222
"@types/node": "^20",

pnpm-lock.yaml

Lines changed: 22 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)