An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
refactor: rely on streamdown defaults for external links
Yoshiki Miurad10cfa1dc46e
diff --git a/bun.lock b/bun.lockindex f7f48a75..6f25d58c 100644--- a/bun.lock+++ b/bun.lock@@ -31,6 +31,7 @@"@radix-ui/react-switch": "^1.0.3","@radix-ui/react-toggle": "^1.1.1","@radix-ui/react-tooltip": "^1.2.4",+ "@streamdown/math": "^1.0.2","@supabase/auth-helpers-nextjs": "^0.10.0","@supabase/auth-ui-react": "^0.4.7","@supabase/auth-ui-shared": "^0.1.8",@@ -64,9 +65,6 @@"react-icons": "^5.0.1","react-textarea-autosize": "^8.5.3","redis": "^4.7.0",- "rehype-external-links": "^3.0.0",- "rehype-katex": "^7.0.1",- "remark-math": "^6.0.0","sonner": "^1.4.41","streamdown": "^2.5.0","tailwind-merge": "^2.6.0",@@ -717,6 +715,8 @@"@stitches/core": ["@stitches/[email protected]", "", {}, "sha512-Gfkvwk9o9kE9r9XNBmJRfV8zONvXThnm1tcuojL04Uy5uRyqg93DC83lDebl0rocZCfKSjUv+fWYtMQmEDJldg=="],+ "@streamdown/math": ["@streamdown/[email protected]", "", { "dependencies": { "katex": "^0.16.27", "rehype-katex": "^7.0.1", "remark-math": "^6.0.0" }, "peerDependencies": { "react": "^18.0.0 || ^19.0.0" } }, "sha512-r8Ur9/lBuFnzZAFdEWrLUF2s/gRwRRRwruqltdZibyjbCBnuW7SJbFm26nXqvpJPW/gzpBUMrBVBzd88z05D5g=="],+"@supabase/auth-helpers-nextjs": ["@supabase/[email protected]", "", { "dependencies": { "@supabase/auth-helpers-shared": "0.7.0", "set-cookie-parser": "^2.6.0" }, "peerDependencies": { "@supabase/supabase-js": "^2.39.8" } }, "sha512-2dfOGsM4yZt0oS4TPiE7bD4vf7EVz7NRz/IJrV6vLg0GP7sMUx8wndv2euLGq4BjN9lUCpu6DG/uCC8j+ylwPg=="],"@supabase/auth-helpers-shared": ["@supabase/[email protected]", "", { "dependencies": { "jose": "^4.14.4" }, "peerDependencies": { "@supabase/supabase-js": "^2.39.8" } }, "sha512-FBFf2ei2R7QC+B/5wWkthMha8Ca2bWHAndN+syfuEUUfufv4mLcAgBCcgNg5nJR8L0gZfyuaxgubtOc9aW3Cpg=="],@@ -1489,8 +1489,6 @@"internmap": ["[email protected]", "", {}, "sha512-lDB5YccMydFBtasVtxnZ3MRBHuaoE8GKsppq+EchKL2U4nK/DmEpPHNH8MZe5HkMtpSiTSOZwfN0tzYjO/lJEw=="],- "is-absolute-url": ["[email protected]", "", {}, "sha512-/51/TKE88Lmm7Gc4/8btclNXWS+g50wXhYJq8HWIBAGUBnoAdRu1aXeh364t/O7wXDAcTJDP8PNuNKWUDWie+A=="],-"is-alphabetical": ["[email protected]", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="],"is-alphanumerical": ["[email protected]", "", { "dependencies": { "is-alphabetical": "^2.0.0", "is-decimal": "^2.0.0" } }, "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw=="],@@ -1907,8 +1905,6 @@"regexp.prototype.flags": ["[email protected]", "", { "dependencies": { "call-bind": "^1.0.8", "define-properties": "^1.2.1", "es-errors": "^1.3.0", "get-proto": "^1.0.1", "gopd": "^1.2.0", "set-function-name": "^2.0.2" } }, "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA=="],- "rehype-external-links": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0", "@ungap/structured-clone": "^1.0.0", "hast-util-is-element": "^3.0.0", "is-absolute-url": "^4.0.0", "space-separated-tokens": "^2.0.0", "unist-util-visit": "^5.0.0" } }, "sha512-yp+e5N9V3C6bwBeAC4n796kc86M4gJCdlVhiMTxIrJG5UHDMh+PJANf9heqORJbt1nrCbDwIlAZKjANIaVBbvw=="],-"rehype-harden": ["[email protected]", "", { "dependencies": { "unist-util-visit": "^5.0.0" } }, "sha512-Qn7vR1xrf6fZCrkm9TDWi/AB4ylrHy+jqsNm1EHOAmbARYA6gsnVJBq/sdBh6kmT4NEZxH5vgIjrscefJAOXcw=="],"rehype-katex": ["[email protected]", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/katex": "^0.16.0", "hast-util-from-html-isomorphic": "^2.0.0", "hast-util-to-text": "^4.0.0", "katex": "^0.16.0", "unist-util-visit-parents": "^6.0.0", "vfile": "^6.0.0" } }, "sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA=="],@@ -2281,6 +2277,8 @@"@radix-ui/react-tooltip/@radix-ui/react-popper": ["@radix-ui/[email protected]", "", { "dependencies": { "@floating-ui/react-dom": "^2.0.0", "@radix-ui/react-arrow": "1.1.7", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-callback-ref": "1.1.1", "@radix-ui/react-use-layout-effect": "1.1.1", "@radix-ui/react-use-rect": "1.1.1", "@radix-ui/react-use-size": "1.1.1", "@radix-ui/rect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-IUFAccz1JyKcf/RjB552PlWwxjeCJB8/4KxT7EhBHOJM+mN7LdW+B3kacJXILm32xawcMMjb2i0cIZpo+f9kiQ=="],+ "@streamdown/math/katex": ["[email protected]", "", { "dependencies": { "commander": "^8.3.0" }, "bin": { "katex": "cli.js" } }, "sha512-EkxoDTk8ufHqHlf9QxGwcxeLkWRR3iOuYfRpfORgYfqc8s13bgb+YtRY59NK5ZpRaCwq1kqA6a5lpX8C/eLphQ=="],+"@supabase/auth-ui-react/react": ["[email protected]", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ=="],"@supabase/auth-ui-react/react-dom": ["[email protected]", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" }, "peerDependencies": { "react": "^18.3.1" } }, "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw=="],diff --git a/components/message.tsx b/components/message.tsxindex 060d6edd..8326bfb0 100644--- a/components/message.tsx+++ b/components/message.tsx@@ -1,14 +1,7 @@'use client'-import rehypeExternalLinks from 'rehype-external-links'-import rehypeKatex from 'rehype-katex'-import remarkMath from 'remark-math'-import {- defaultRehypePlugins,- defaultRemarkPlugins,- Streamdown-} from 'streamdown'-import type { PluggableList } from 'unified'+import { math } from '@streamdown/math'+import { defaultRehypePlugins, Streamdown } from 'streamdown'import type { SearchResultItem } from '@/lib/types'import { cn } from '@/lib/utils'@@ -36,16 +29,7 @@ export function MarkdownMessage({a: Citing}- const rehypePlugins: PluggableList = [- ...Object.values(defaultRehypePlugins),- [rehypeExternalLinks, { target: '_blank' }],- rehypeKatex- ]-- const remarkPlugins: PluggableList = [- ...Object.values(defaultRemarkPlugins),- remarkMath- ]+ const rehypePlugins = Object.values(defaultRehypePlugins)return (<CitationProvider citationMaps={citationMaps}>@@ -56,8 +40,8 @@ export function MarkdownMessage({)}><Streamdown+ plugins={{ math }}rehypePlugins={rehypePlugins}- remarkPlugins={remarkPlugins}components={customComponents}>{processedMessage}diff --git a/package.json b/package.jsonindex 14122b2e..e3c30398 100644--- a/package.json+++ b/package.json@@ -43,6 +43,7 @@"@radix-ui/react-switch": "^1.0.3","@radix-ui/react-toggle": "^1.1.1","@radix-ui/react-tooltip": "^1.2.4",+ "@streamdown/math": "^1.0.2","@supabase/auth-helpers-nextjs": "^0.10.0","@supabase/auth-ui-react": "^0.4.7","@supabase/auth-ui-shared": "^0.1.8",@@ -76,9 +77,6 @@"react-icons": "^5.0.1","react-textarea-autosize": "^8.5.3","redis": "^4.7.0",- "rehype-external-links": "^3.0.0",- "rehype-katex": "^7.0.1",- "remark-math": "^6.0.0","sonner": "^1.4.41","streamdown": "^2.5.0","tailwind-merge": "^2.6.0",