diff --git a/server/fixtures/llms/images.html b/server/fixtures/llms/images.html new file mode 100644 index 00000000..40c82429 --- /dev/null +++ b/server/fixtures/llms/images.html @@ -0,0 +1,2 @@ +

Paragraph before image.

Logo +

Paragraph after image.

Diagram \ No newline at end of file diff --git a/server/fixtures/llms/result/images.html b/server/fixtures/llms/result/images.html new file mode 100644 index 00000000..7070ab1e --- /dev/null +++ b/server/fixtures/llms/result/images.html @@ -0,0 +1,2 @@ +

Paragraph before image.

+

Paragraph after image.

\ No newline at end of file diff --git a/server/llms/rehype-prepare-html.test.ts b/server/llms/rehype-prepare-html.test.ts index 2ce7472e..856e4847 100644 --- a/server/llms/rehype-prepare-html.test.ts +++ b/server/llms/rehype-prepare-html.test.ts @@ -146,6 +146,19 @@ describe("server/llms/rehype-prepare-html", () => { ); }); + test("Images: removes all img elements, preserving surrounding content", () => { + const result = transformer( + readFileSync(resolve("server/fixtures/llms/images.html"), "utf-8"), + ); + + expect((result.value as string).trim()).toBe( + readFileSync( + resolve("server/fixtures/llms/result/images.html"), + "utf-8", + ).trim(), + ); + }); + test("Irrelevant components: removes thumbsFeedback and checkpoint components, preserving other content", () => { const result = transformer( readFileSync( diff --git a/server/llms/rehype-prepare-html.ts b/server/llms/rehype-prepare-html.ts index 2ed5a4f6..88565bfb 100644 --- a/server/llms/rehype-prepare-html.ts +++ b/server/llms/rehype-prepare-html.ts @@ -11,6 +11,7 @@ import { visitParents, SKIP } from "unist-util-visit-parents"; * Code blocks: extract text content and replace with clean
 structure
  * Card links: prevent duplicate links in the markdown output
  * Heading anchor links: remove hash-link anchors from headings
+ * Images: remove all image elements from the output
  * Irrelevant components: remove interactive UI components (thumbsFeedback, checkpoint, docsHeader)
  * H1 repositioning: move the h1 heading to the top of the document
  */
@@ -86,6 +87,12 @@ const rehypePrepareHTML: Plugin<[], Root, Root> = function () {
         return SKIP; // don't traverse children (e.g. avoids capturing an h1 inside a removed node)
       }
 
+      // *** Images ***
+      if (element.tagName === "img") {
+        toRemove.push({ node: element, parent });
+        return SKIP;
+      }
+
       // *** Headings ***
       if (/^h[1-6]$/.test(element.tagName)) {
         // Remove hash-link anchor children in-place
diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx
index f55f4fbd..b7199658 100644
--- a/src/components/Button/Button.tsx
+++ b/src/components/Button/Button.tsx
@@ -7,6 +7,7 @@ import type {
 import { clsx } from "clsx";
 
 import styles from "./Button.module.css";
+import Link from "@docusaurus/Link";
 
 export type ButtonVariant =
   | "primary"
@@ -55,7 +56,7 @@ const Button = ({
   };
 
   if (as === "link") {
-    return ;
+    return ;
   }
 
   return