From bccd5502758d13e57736df556762aa86a31bc52f Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Thu, 11 Apr 2024 22:52:24 +0700 Subject: [PATCH] Add switch between markdown or raw files on rich preview and readme --- src/app/@markdown.tsx | 83 +++++++++++++++---------- src/app/@preview.layout.tsx | 75 ++++++++++++++++++++++ src/app/@preview.rich.tsx | 37 +++++++---- src/app/@readme.tsx | 37 +++++++++++ src/app/@rich-header.tsx | 39 ++++++++++++ src/app/[...rest]/page.tsx | 120 +++++++++++++----------------------- src/app/page.tsx | 34 +++++----- 7 files changed, 290 insertions(+), 135 deletions(-) create mode 100644 src/app/@preview.layout.tsx create mode 100644 src/app/@readme.tsx create mode 100644 src/app/@rich-header.tsx diff --git a/src/app/@markdown.tsx b/src/app/@markdown.tsx index 041763d..f70a7e5 100644 --- a/src/app/@markdown.tsx +++ b/src/app/@markdown.tsx @@ -10,6 +10,7 @@ import remarkGfm from "remark-gfm"; import remarkMath from "remark-math"; import remarkSlug from "remark-slug"; import remarkToc from "remark-toc"; +import { cn } from "~/utils"; import Icon from "~/components/Icon"; @@ -17,41 +18,59 @@ import "./highlight.css"; type Props = { content: string; + view: "markdown" | "raw"; }; -export default function Markdown({ content }: Props) { +export default function Markdown({ content, view }: Props) { return ( -
- {children} -
- ), - pre: PreComponent, - code: ({ node, inline, className, children, ...props }) => ( -
- {children}
-
- ),
- }}
+
+ {content}
+
+ + {children} +
+ ), + pre: PreComponent, + code: ({ node, inline, className, children, ...props }) => ( +
+ {children}
+
+ ),
+ }}
+ >
+ {content}
+