aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/preview/content-renderers/README.md
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2025-08-03 23:35:06 -0700
committerMohamedBassem <me@mbassem.com>2025-08-03 23:59:45 -0700
commitc68e5099797d5b49ed6441ce04d7c77105327f73 (patch)
tree296fe5f473f46d802fcf94fa203ca37672112c30 /apps/web/components/dashboard/preview/content-renderers/README.md
parent03aa17200ed80c2978bf496991c6afbb5a04258b (diff)
downloadkarakeep-c68e5099797d5b49ed6441ce04d7c77105327f73.tar.zst
feat(web): Add special cards for specific websites. Fixes #1344
Diffstat (limited to 'apps/web/components/dashboard/preview/content-renderers/README.md')
-rw-r--r--apps/web/components/dashboard/preview/content-renderers/README.md55
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/web/components/dashboard/preview/content-renderers/README.md b/apps/web/components/dashboard/preview/content-renderers/README.md
new file mode 100644
index 00000000..9606b403
--- /dev/null
+++ b/apps/web/components/dashboard/preview/content-renderers/README.md
@@ -0,0 +1,55 @@
+# Content-Aware Renderers
+
+This directory contains the content-aware rendering system for LinkContentPreview. It allows for special rendering of different types of links based on their URL patterns.
+
+## Architecture
+
+The system consists of:
+
+1. **Types** (`types.ts`): Defines the `ContentRenderer` interface
+2. **Registry** (`registry.ts`): Manages registration and retrieval of renderers
+3. **Individual Renderers**: Each renderer handles a specific type of content
+
+## Creating a New Renderer
+
+To add support for a new website or content type:
+
+1. Create a new file (e.g., `MyWebsiteRenderer.tsx`)
+2. Implement the `ContentRenderer` interface:
+
+```typescript
+import { ContentRenderer } from "./types";
+import { BookmarkTypes, ZBookmark } from "@karakeep/shared/types/bookmarks";
+import { MyIcon } from "lucide-react";
+
+function canRenderMyWebsite(bookmark: ZBookmark): boolean {
+ if (bookmark.content.type !== BookmarkTypes.LINK) {
+ return false;
+ }
+
+ // Add your URL pattern matching logic here
+ return bookmark.content.url.includes("mywebsite.com");
+}
+
+function MyWebsiteRendererComponent({ bookmark }: { bookmark: ZBookmark }) {
+ // Your custom rendering logic here
+ return <div>Custom content for MyWebsite</div>;
+}
+
+export const myWebsiteRenderer: ContentRenderer = {
+ id: "mywebsite",
+ name: "My Website",
+ icon: MyIcon,
+ canRender: canRenderMyWebsite,
+ component: MyWebsiteRendererComponent,
+ priority: 10, // Higher priority = appears first in dropdown
+};
+```
+
+3. Register your renderer in `index.ts`:
+
+```typescript
+import { myWebsiteRenderer } from "./MyWebsiteRenderer";
+
+contentRendererRegistry.register(myWebsiteRenderer);
+```