From 6fd3f9cc2eccf4f63dd55c20ccd8855d808bf0d9 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Wed, 3 Dec 2025 12:53:13 +0100 Subject: [PATCH] fix asciidoc book:: cards --- src/components/Bookstr/BookstrContent.tsx | 23 ++++++++++++++-- .../Note/AsciidocArticle/AsciidocArticle.tsx | 2 +- src/components/WebPreview/index.tsx | 27 +------------------ 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/components/Bookstr/BookstrContent.tsx b/src/components/Bookstr/BookstrContent.tsx index a3b6f62..f837994 100644 --- a/src/components/Bookstr/BookstrContent.tsx +++ b/src/components/Bookstr/BookstrContent.tsx @@ -20,6 +20,7 @@ interface BookstrContentProps { wikilink: string sourceUrl?: string className?: string + skipWebPreview?: boolean // If true, show simple button instead of WebPreview } interface BookSection { @@ -213,7 +214,7 @@ function buildExternalUrl(reference: BookReference, bookType: string, version?: } } -export function BookstrContent({ wikilink, sourceUrl, className }: BookstrContentProps) { +export function BookstrContent({ wikilink, sourceUrl, className, skipWebPreview = false }: BookstrContentProps) { const [sections, setSections] = useState([]) const [isLoading, setIsLoading] = useState(false) // Start as false, only set to true when actually fetching const [error, setError] = useState(null) @@ -958,7 +959,7 @@ export function BookstrContent({ wikilink, sourceUrl, className }: BookstrConten )} - {/* OG Preview Card for bible/torah/quran external URLs */} + {/* External URL preview/button for bible/torah/quran */} {(() => { // Get bookType from parsed wikilink (defaults to 'bible') const bookType = parsed?.bookType || 'bible' @@ -973,6 +974,24 @@ export function BookstrContent({ wikilink, sourceUrl, className }: BookstrConten if (!externalUrl) return null + // If skipWebPreview is true (e.g., in AsciiDoc), show simple button + if (skipWebPreview) { + return ( +
+ + + View on external site + +
+ ) + } + + // Otherwise, use WebPreview (for markdown articles) return (
diff --git a/src/components/Note/AsciidocArticle/AsciidocArticle.tsx b/src/components/Note/AsciidocArticle/AsciidocArticle.tsx index 05b493b..493aba8 100644 --- a/src/components/Note/AsciidocArticle/AsciidocArticle.tsx +++ b/src/components/Note/AsciidocArticle/AsciidocArticle.tsx @@ -1102,7 +1102,7 @@ export default function AsciidocArticle({ // Check if this container already has a root to avoid re-rendering if (!reactRootsRef.current.has(container)) { const root = createRoot(container) - root.render() + root.render() reactRootsRef.current.set(container, root) } }) diff --git a/src/components/WebPreview/index.tsx b/src/components/WebPreview/index.tsx index fc7b97b..bfa19d4 100644 --- a/src/components/WebPreview/index.tsx +++ b/src/components/WebPreview/index.tsx @@ -58,31 +58,6 @@ function getEventTypeName(kind: number): string { } } -// Helper function to extract and strip markdown/asciidoc for preview -function stripMarkdown(content: string): string { - let text = content - // Remove markdown headers - text = text.replace(/^#{1,6}\s+/gm, '') - // Remove markdown bold/italic - text = text.replace(/\*\*([^*]+)\*\*/g, '$1') - text = text.replace(/\*([^*]+)\*/g, '$1') - // Remove markdown links - text = text.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') - // Remove asciidoc headers - text = text.replace(/^=+\s+/gm, '') - // Remove asciidoc bold/italic - text = text.replace(/\*\*([^*]+)\*\*/g, '$1') - text = text.replace(/_([^_]+)_/g, '$1') - // Remove code blocks - text = text.replace(/```[\s\S]*?```/g, '') - text = text.replace(/`([^`]+)`/g, '$1') - // Remove HTML tags - text = text.replace(/<[^>]+>/g, '') - // Clean up whitespace - text = text.replace(/\n{3,}/g, '\n\n') - return text.trim() -} - export default function WebPreview({ url, className }: { url: string; className?: string }) { const { autoLoadMedia } = useContentPolicy() const { isSmallScreen } = useScreenSize() @@ -464,7 +439,7 @@ export default function WebPreview({ url, className }: { url: string; className?
{eventSummary}
)} {previewEvent && previewEvent.content && ( -
+