diff --git a/src/components/cite.tsx b/src/components/cite.tsx index ca80ce05..a38fd357 100644 --- a/src/components/cite.tsx +++ b/src/components/cite.tsx @@ -1,9 +1,11 @@ +import type { HTMLAttributes } from "react"; + const Cite = ({ children, ...props }: { children: React.ReactNode; -} & React.HTMLAttributes) => ( +} & HTMLAttributes) => ( {children} + + ); +}; + +export default Img; diff --git a/src/components/p.tsx b/src/components/p.tsx index d2f2c7e8..320fa63a 100644 --- a/src/components/p.tsx +++ b/src/components/p.tsx @@ -1,9 +1,11 @@ +import type { HTMLAttributes } from "react"; + const Paragraph = ({ children, ...props }: { children: React.ReactNode; -} & React.HTMLAttributes) => ( +} & HTMLAttributes) => (

{children} - + ); }; @@ -334,7 +303,7 @@ const hyperlinkMap: NodeToElementMapper = (context, node) => { "/" + node.url } - title={node.title.replace(/^🎧\s*/u, '').trim()} + title={node.title.replace(/^🎧\s*/u, "").trim()} /> ) : youtubeURL && node?.title?.startsWith("📺") ? ( @@ -344,7 +313,7 @@ const hyperlinkMap: NodeToElementMapper = (context, node) => { src={`https://www.youtube.com/embed/${youtubeURL.videoId}${ youtubeURL.startTime ? "?start=" + youtubeURL.startTime : "" }`} - title={node.title.replace(/^📺\s*/u, '').trim()} + title={node.title.replace(/^📺\s*/u, "").trim()} frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen @@ -511,3 +480,28 @@ function eventuallyConvertHTMLNodes(rootNode: MarkdownRootNode): MarkdownNode { return rootNode; } + +function parseImageProps(node: MarkdownImageNode): { + title: string; + float?: "left" | "right"; + src: string; +} { + const title = (node.title || "").replace(/^🖼(➡️|⬅️)\s*/u, ""); + const float = node.title?.includes("➡️") + ? "right" + : node.title?.includes("⬅️") + ? "left" + : undefined; + const src = node.url.startsWith("http") + ? node.url + : publicRuntimeConfig.baseURL + + publicRuntimeConfig.buildPrefix + + "/" + + node.url.replace(/^(\.\/)?(\.\.\/)*public\//, ""); + + return { + title, + float, + src, + }; +}