Skip to content

Commit 9faa187

Browse files
committed
added syntex hightling with rehype
1 parent 9f4641b commit 9faa187

File tree

7 files changed

+409
-43
lines changed

7 files changed

+409
-43
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2-
"cSpell.words": ["clsx"],
2+
"cSpell.words": [
3+
"clsx",
4+
"rehype"
5+
],
36
"tailwindCSS.experimental.classRegex": [
47
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
58
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]

components/ComponentShowcase.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function ComponentShowcase({ name, children }: IComponentShowcase) {
2121

2222
<div>
2323
<H5>Code</H5>
24-
<div className="relative rounded overflow-auto">{Code}</div>
24+
<div className="relative rounded overflow-auto">{Code}</div>
2525
</div>
2626
</div>
2727
);

components/MDX.tsx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { H1, H2, H3, H4, H5, H6 } from "@/packages/ui";
22
import { useMDXComponent } from "next-contentlayer/hooks";
33
import React, { HTMLAttributes } from "react";
44
import { ComponentShowcase } from "./ComponentShowcase";
5-
import dynamic from "next/dynamic";
6-
const Code = dynamic(() => import("bright").then(mod => mod.Code));
5+
import { cn } from "@/lib/utils";
76

87
const components = {
98
h1: H1,
@@ -14,8 +13,37 @@ const components = {
1413
h4: H4,
1514
h5: H5,
1615
h6: H6,
17-
pre: Code,
18-
ComponentShowcase
16+
pre: ({
17+
className,
18+
children,
19+
...props
20+
}: React.HTMLAttributes<HTMLElement>) => (
21+
<pre
22+
className={cn(
23+
"overflow-x-auto rounded bg-[#282A36] mt-3 mb-6 p-4",
24+
className
25+
)}
26+
{...props}
27+
>
28+
{children}
29+
</pre>
30+
),
31+
code: ({
32+
className,
33+
children,
34+
...props
35+
}: React.HTMLAttributes<HTMLElement>) => (
36+
<code
37+
className={cn(
38+
"relative rounded bg-[#282A36] py-1 px-2 text-primary-500 text-sm",
39+
className
40+
)}
41+
{...props}
42+
>
43+
{children}
44+
</code>
45+
),
46+
ComponentShowcase,
1947
};
2048

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

content/docs/index.mdx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
---
22
title: Getting Started
33
description: This guide will help you get started with RetroUI, a retro styled UI library based on Tailwind CSS.
4-
lastUpdated: 29 Sep, 2024
4+
lastUpdated: 08 Oct, 2024
55
---
66

77
### 1. Add the fonts
8-
We are useing `Archivo Black` for headings and `Share Tech` for everything else.
8+
9+
<br />
10+
11+
We are using `Archivo Black` for headings and `Share Tech` for everything else.
912

1013
Installation form Google Fonts:
11-
```
12-
<link rel="preconnect" href="https://fonts.googleapis.com">
13-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
14-
<link href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=Share+Tech&display=swap" rel="stylesheet">
14+
15+
```html
16+
<link rel="preconnect" href="https://fonts.googleapis.com" />
17+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
18+
<link
19+
href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=Share+Tech&display=swap"
20+
rel="stylesheet"
21+
/>
1522
```
1623

1724
Save the fonts in `global.css`:
1825

19-
```
26+
```css
2027
:root {
2128
--font-head: "Archivo Black", sans-serif;
2229
--font-sans: "Share Tech", sans-serif;
@@ -27,7 +34,7 @@ Save the fonts in `global.css`:
2734

2835
### 2. Add the theme to your tailwind.config.js file.
2936

30-
```
37+
```ts
3138
import type { Config } from "tailwindcss";
3239

3340
const config = {
@@ -38,8 +45,8 @@ const config = {
3845
sans: ["var(--font-sans)"],
3946
},
4047
boxShadow: {
41-
"xs": "1px 1px 0 0 #000",
42-
"md": "3px 3px 0 0 #000",
48+
xs: "1px 1px 0 0 #000",
49+
md: "3px 3px 0 0 #000",
4350
"3xl": "10px 10px 0 0 #000",
4451
},
4552
colors: {
@@ -63,5 +70,4 @@ export default config;
6370
```
6471

6572
<br />
66-
67-
### 3. Now start copy-pasting the components!
73+
### 3. Now start copy-pasting the components!

contentlayer.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ 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 rehypePrettyCode from "rehype-pretty-code";
6+
import rehypeSlug from "rehype-slug";
57
import { u } from "unist-builder";
68
import { UnistNode } from "./types/unist";
79
import { componentConfig } from "./config";
@@ -25,6 +27,7 @@ export const Doc = defineDocumentType(() => ({
2527

2628
export default makeSource({
2729
mdx: {
30+
remarkPlugins: [],
2831
rehypePlugins: [
2932
() => (tree) => {
3033
visit(tree, (node: UnistNode) => {
@@ -75,6 +78,13 @@ export default makeSource({
7578
});
7679
return null;
7780
},
81+
rehypeSlug,
82+
[
83+
rehypePrettyCode as any,
84+
{
85+
theme: "dracula-soft",
86+
},
87+
],
7888
],
7989
},
8090
contentDirPath: "./content",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"bright": "^0.8.5",
1312
"class-variance-authority": "^0.7.0",
1413
"clsx": "^2.1.1",
1514
"contentlayer": "^0.3.4",
@@ -19,6 +18,8 @@
1918
"next-contentlayer": "^0.3.4",
2019
"react": "^18",
2120
"react-dom": "^18",
21+
"rehype-pretty-code": "^0.14.0",
22+
"rehype-slug": "^6.0.0",
2223
"tailwind-merge": "^2.5.3",
2324
"unist-builder": "^4.0.0",
2425
"unist-util-visit": "^5.0.0"

0 commit comments

Comments
 (0)