diff --git a/components/tcmd/index.tsx b/components/tcmd/index.tsx index 31d1a6d..3ac6992 100644 --- a/components/tcmd/index.tsx +++ b/components/tcmd/index.tsx @@ -2,7 +2,7 @@ import { createElements } from "@/lib/tcmd"; import Link from "next/link"; -import React, { FC, ReactNode, use, useMemo } from "react"; +import React, { FC, Fragment, ReactNode, use, useMemo } from "react"; export const TCMD: FC<{ body: Promise }> = ({ body }) => { const text = use(body); @@ -27,10 +27,12 @@ const renderBlock = (block: BlockChildren): ReactNode => { style={{ "--grid-cols": block.metadata.columns, } as React.CSSProperties} - className="grid grid-cols-dynamic gap-x-8 gap-y-6" + className="grid grid-cols-dynamic gap-x-8 gap-y-6 mb-6" > {block.children.map((c, i) => ( -
{renderBlock(c)}
+ + {renderBlock(c)} + ))} ); @@ -66,19 +68,37 @@ const renderToken = (t: Token) => { switch (t.type) { case "h1": return ( -

+

{renderInlineToken(t.line)}

); case "h2": return ( -

+

{renderInlineToken(t.line)}

); case "h3": return ( -

+

{renderInlineToken(t.line)}

); @@ -124,6 +144,9 @@ const renderInlineToken = (l: Line) => { {token.content} ); + case "image": + // eslint-disable-next-line @next/next/no-img-element + return {token.content}; default: return ( diff --git a/lib/tcmd/inlineTokens.ts b/lib/tcmd/inlineTokens.ts index 48fc3f4..a6543fe 100644 --- a/lib/tcmd/inlineTokens.ts +++ b/lib/tcmd/inlineTokens.ts @@ -24,7 +24,7 @@ export const inlineTokens: { }, }, { - rx: /\[(.*?)\]\((.*?)\)/g, + rx: /(?