diff options
| author | MohamedBassem <me@mbassem.com> | 2025-08-03 23:35:06 -0700 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2025-08-03 23:59:45 -0700 |
| commit | c68e5099797d5b49ed6441ce04d7c77105327f73 (patch) | |
| tree | 296fe5f473f46d802fcf94fa203ca37672112c30 /apps/web/components/dashboard/preview/LinkContentSection.tsx | |
| parent | 03aa17200ed80c2978bf496991c6afbb5a04258b (diff) | |
| download | karakeep-c68e5099797d5b49ed6441ce04d7c77105327f73.tar.zst | |
feat(web): Add special cards for specific websites. Fixes #1344
Diffstat (limited to 'apps/web/components/dashboard/preview/LinkContentSection.tsx')
| -rw-r--r-- | apps/web/components/dashboard/preview/LinkContentSection.tsx | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/apps/web/components/dashboard/preview/LinkContentSection.tsx b/apps/web/components/dashboard/preview/LinkContentSection.tsx index eefec701..3855cb2a 100644 --- a/apps/web/components/dashboard/preview/LinkContentSection.tsx +++ b/apps/web/components/dashboard/preview/LinkContentSection.tsx @@ -25,6 +25,7 @@ import { ZBookmarkedLink, } from "@karakeep/shared/types/bookmarks"; +import { contentRendererRegistry } from "./content-renderers"; import ReaderView from "./ReaderView"; function FullPageArchiveSection({ link }: { link: ZBookmarkedLink }) { @@ -74,14 +75,23 @@ export default function LinkContentSection({ bookmark: ZBookmark; }) { const { t } = useTranslation(); - const [section, setSection] = useState<string>("cached"); + const availableRenderers = contentRendererRegistry.getRenderers(bookmark); + const defaultSection = + availableRenderers.length > 0 ? availableRenderers[0].id : "cached"; + const [section, setSection] = useState<string>(defaultSection); if (bookmark.content.type != BookmarkTypes.LINK) { throw new Error("Invalid content type"); } let content; - if (section === "cached") { + + // Check if current section is a custom renderer + const customRenderer = availableRenderers.find((r) => r.id === section); + if (customRenderer) { + const RendererComponent = customRenderer.component; + content = <RendererComponent bookmark={bookmark} />; + } else if (section === "cached") { content = ( <ScrollArea className="h-full"> <ReaderView @@ -109,6 +119,20 @@ export default function LinkContentSection({ </SelectTrigger> <SelectContent> <SelectGroup> + {/* Custom renderers first */} + {availableRenderers.map((renderer) => { + const IconComponent = renderer.icon; + return ( + <SelectItem key={renderer.id} value={renderer.id}> + <div className="flex items-center"> + <IconComponent className="mr-2 h-4 w-4" /> + {renderer.name} + </div> + </SelectItem> + ); + })} + + {/* Default renderers */} <SelectItem value="cached"> <div className="flex items-center"> <BookOpen className="mr-2 h-4 w-4" /> |
