Skip to content

Commit 80c620d

Browse files
authored
Update code.tsx (#62)
1 parent 212d244 commit 80c620d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

components/code.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,23 @@ import { wordWrap } from "./annotations/word-wrap";
1919
export async function Code({ codeblock }: { codeblock: RawCode }) {
2020
const highlighted = await highlight(codeblock, "min-dark");
2121

22+
// Extract the filename/title from meta value, handling cases with docci commands
23+
const displayMeta = highlighted.meta ? (() => {
24+
// Split by spaces to handle both formats:
25+
// "docci-ignore filename" or "filename docci-ignore"
26+
const parts = highlighted.meta.split(' ');
27+
28+
// Find the part that doesn't start with 'docci'
29+
const title = parts.find(part => !part.startsWith('docci'));
30+
31+
return title || null;
32+
})() : null;
33+
2234
return (
2335
<div className="border rounded relative">
24-
{highlighted.meta && (
36+
{displayMeta && (
2537
<div className="text-center text-zinc-400 text-sm min-h-[2rem] flex items-center justify-center">
26-
{highlighted.meta}
38+
{displayMeta}
2739
</div>
2840
)}
2941
<Pre

0 commit comments

Comments
 (0)