diff --git a/bun.lockb b/bun.lockb index 170e90b..fcf1240 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index c1b8d32..e72f090 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,8 @@ "prepare": "husky" }, "dependencies": { - "bright": "^0.8.5", "clsx": "^2.1.1", - "next": "14.2.6", + "next": "14.2.7", "next-sitemap": "^4.2.3", "next-themes": "^0.3.0", "react": "18.3.1", @@ -24,13 +23,14 @@ "devDependencies": { "@biomejs/biome": "^1.8.3", "@types/bun": "^1.1.8", - "@types/node": "20.11.25", - "@types/react": "18.2.64", - "@types/react-dom": "18.2.21", + "@types/node": "22.5.2", + "@types/react": "18.3.5", + "@types/react-dom": "18.3.0", "autoprefixer": "10.4.20", "husky": "^9.1.5", "lint-staged": "^15.2.9", - "postcss": "8.4.41", + "postcss": "8.4.42", + "shiki": "^1.15.2", "tailwindcss": "3.4.10", "typescript": "5.5.4" }, diff --git a/src/app/globals.css b/src/app/globals.css index 6c864fe..f5255a4 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -5,3 +5,10 @@ body { overscroll-behavior-y: none; } + +html .shiki { + background: #d4d4d411 !important; + @apply sm:!p-4 !p-6; + @apply !text-sm sm:!text-base; + @apply !text-wrap +} \ No newline at end of file diff --git a/src/components/RequestDisplayElement.tsx b/src/components/RequestDisplayElement.tsx index 81feedd..833c03a 100644 --- a/src/components/RequestDisplayElement.tsx +++ b/src/components/RequestDisplayElement.tsx @@ -1,28 +1,29 @@ import { cn } from "@/utils/cn" -import { Code } from "bright" +import { codeToHtml } from "shiki" interface RequestDisplayElementProps { className?: string slug: string } -const RequestDisplayElement = ({ +const RequestDisplayElement = async ({ className, slug, -}: RequestDisplayElementProps): JSX.Element => { +}: RequestDisplayElementProps): Promise => { + const code = await codeToHtml(getRequest(slug), { + lang: "typescript", + theme: "solarized-dark", + }) + return (
-

+

Request:

- */ + dangerouslySetInnerHTML={{ __html: code }} />
) diff --git a/src/components/ResponseDisplayElement.tsx b/src/components/ResponseDisplayElement.tsx index 049d9be..82b2cc1 100644 --- a/src/components/ResponseDisplayElement.tsx +++ b/src/components/ResponseDisplayElement.tsx @@ -1,28 +1,29 @@ import { cn } from "@/utils/cn" -import { Code } from "bright" +import { codeToHtml } from "shiki/bundle-web.mjs" interface ResponseDisplayElementProps { className?: string children: string } -const ResponseDisplayElement = ({ +const ResponseDisplayElement = async ({ className, children, -}: ResponseDisplayElementProps): JSX.Element => { +}: ResponseDisplayElementProps): Promise => { + const code = await codeToHtml(children, { + lang: "json", + theme: "solarized-dark", + }) + return (
-

+

Result:

- */ + dangerouslySetInnerHTML={{ __html: code }} />
)