diff --git a/src/components/Markdown.tsx b/src/components/Markdown.tsx deleted file mode 100644 index 703d1b2..0000000 --- a/src/components/Markdown.tsx +++ /dev/null @@ -1,233 +0,0 @@ -import ReactMarkdown from "react-markdown"; -import type { Components } from "react-markdown"; -import { useMemo } from "react"; -import { useGrimoire } from "@/core/state"; -import { MediaEmbed } from "@/components/nostr/MediaEmbed"; -import remarkGfm from "remark-gfm"; - -interface MarkdownProps { - content: string; - className?: string; -} - -export function Markdown({ content, className = "" }: MarkdownProps) { - const { addWindow } = useGrimoire(); - - const components: Components = useMemo( - () => ({ - // Headings - h1: ({ children }) => ( -
- {children} -
- ), - - // Links - a: ({ href, children }) => { - console.log("[Markdown Link]", { href, children }); - - // Check if it's a relative NIP link (e.g., "./01.md" or "01.md" or "30.md") - // Must be relative (not start with http:// or https://) - const isRelativeLink = - href && !href.startsWith("http://") && !href.startsWith("https://"); - if (isRelativeLink && (href.endsWith(".md") || href.includes(".md#"))) { - console.log("[Markdown] Detected relative .md link:", href); - - // Extract NIP number from various formats (numeric 1-3 digits or hex A0-FF) - const nipMatch = href.match(/([0-9A-F]{1,3})\.md/i); - console.log("[Markdown] Regex match result:", nipMatch); - - if (nipMatch) { - const nipNumber = nipMatch[1].toUpperCase(); - console.log("[Markdown] Creating NIP link for NIP-" + nipNumber); - - return ( - { - e.preventDefault(); - e.stopPropagation(); - console.log("[Markdown] NIP link clicked! NIP-" + nipNumber); - console.log("[Markdown] Calling addWindow directly"); - addWindow("nip", { number: nipNumber }, `NIP ${nipNumber}`); - console.log("[Markdown] addWindow called"); - }} - className="text-accent underline decoration-dotted cursor-crosshair hover:text-accent/80 transition-colors" - > - {children} - - ); - } - } - - // Regular external link - console.log("[Markdown] Creating regular external link for:", href); - return ( - - {children} - - ); - }, - - // Lists - ul: ({ children }) => ( -- {children} -- ), - - // Code - code: (props) => { - const { children, className } = props; - const inline = !className?.includes("language-"); - - return inline ? ( -
- {children}
-
- ) : (
-
- {children}
-
- );
- },
- pre: ({ children }) => {children},
-
- // Horizontal rule
- hr: () =>