- Restore heading/list typography in the editor: MDXEditor relies on the browser's default styles for <h1>/<ul> sizing, which Tailwind's Preflight resets. Markdown shortcuts fired but the block looked unchanged. Style the editor content explicitly, mirroring the rendered display. - Keep pasted/typed URLs as plain text (linkPlugin disableAutoLink) so they don't become `[url](url)`, which duplicated both the URL and its preview card. Also dedupe extractUrls defensively so a repeated URL yields one card. https://claude.ai/code/session_019DU6V5z6Nr4Vu7b1fBDnq4
17 lines
479 B
TypeScript
17 lines
479 B
TypeScript
export interface LinkMetadata {
|
|
url: string;
|
|
title: string | null;
|
|
description: string | null;
|
|
image: string | null;
|
|
favicon: string | null;
|
|
domain: string;
|
|
}
|
|
|
|
const URL_REGEX = /https?:\/\/[^\s<>"')\]]+/g;
|
|
|
|
export function extractUrls(text: string): string[] {
|
|
// Dedupe: a URL repeated in the text (e.g. a `[url](url)` markdown link)
|
|
// should only yield a single preview card.
|
|
return Array.from(new Set(Array.from(text.matchAll(URL_REGEX), (m) => m[0])));
|
|
}
|