Skip to content

Commit 8d45da1

Browse files
committed
simplify clipboard handling, remove unused frontmatter parser
1 parent c601442 commit 8d45da1

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

src/components/store.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,6 @@ export function pathFromFilename(filename: string): string {
6262
.toLowerCase();
6363
}
6464

65-
function parseFrontMatter(content: string) {
66-
if (typeof content !== 'string') return { data: {}, content: '' };
67-
const frontMatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
68-
if (!frontMatterMatch) return { data: {}, content };
69-
70-
const frontMatter = frontMatterMatch[1];
71-
const data: Record<string, any> = {};
72-
73-
frontMatter.split('\n').forEach(line => {
74-
const [key, ...valueParts] = line.split(':');
75-
if (key && valueParts.length) {
76-
const value = valueParts.join(':').trim();
77-
data[key.trim()] = value.replace(/^["']|["']$/g, ''); // Remove quotes if present
78-
}
79-
});
80-
81-
return { data, content: content.slice(frontMatterMatch[0].length) };
82-
}
8365

8466
export let completeFrontMatter: Record<string, any>[] = [];
8567
export function isFrontmatterReady() { return preloadedFrontMatter !== null; }

src/ui/layout.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ export default function Layout({ children }: LayoutProps) {
3636
}, [pathname]);
3737

3838
const handleCopyMDX = useCallback(() => {
39-
ALL_PAGES[pathFromFilename(pathname)]().then((mdx) => {
40-
navigator.clipboard.writeText(mdx.default.toString());
41-
});
39+
const mod = ALL_PAGES[pathFromFilename(pathname)];
40+
if (mod) navigator.clipboard.writeText((mod as any).default.toString());
4241
showNotification('Copied to clipboard');
4342
}, []);
4443
const handleOpenChatGPT = useCallback(() => {

0 commit comments

Comments
 (0)