mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
refactor: extract duplicate TYPE_ICONS into shared module
Both citation.tsx and citation-list.tsx defined identical TYPE_ICONS maps. Extract into a shared type-icons.ts to eliminate duplication and reduce bundle size from duplicate Lucide icon imports. Fixes #1190
This commit is contained in:
parent
7c61668823
commit
32af45bbbd
3 changed files with 18 additions and 24 deletions
|
|
@ -1,22 +1,13 @@
|
|||
"use client";
|
||||
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
import { Code2, Database, ExternalLink, File, FileText, Globe, Newspaper } from "lucide-react";
|
||||
import { ExternalLink, Globe } from "lucide-react";
|
||||
import NextImage from "next/image";
|
||||
import * as React from "react";
|
||||
import { openSafeNavigationHref, resolveSafeNavigationHref } from "../shared/media";
|
||||
import { cn, Popover, PopoverContent, PopoverTrigger } from "./_adapter";
|
||||
import { Citation } from "./citation";
|
||||
import type { CitationType, CitationVariant, SerializableCitation } from "./schema";
|
||||
|
||||
const TYPE_ICONS: Record<CitationType, LucideIcon> = {
|
||||
webpage: Globe,
|
||||
document: FileText,
|
||||
article: Newspaper,
|
||||
api: Database,
|
||||
code: Code2,
|
||||
other: File,
|
||||
};
|
||||
import type { CitationVariant, SerializableCitation } from "./schema";
|
||||
import { TYPE_ICONS } from "./type-icons";
|
||||
|
||||
function useHoverPopover(delay = 100) {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
|
|
|||
|
|
@ -1,24 +1,15 @@
|
|||
"use client";
|
||||
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
import { Code2, Database, ExternalLink, File, FileText, Globe, Newspaper } from "lucide-react";
|
||||
import { ExternalLink, Globe } from "lucide-react";
|
||||
import NextImage from "next/image";
|
||||
import * as React from "react";
|
||||
import { openSafeNavigationHref, sanitizeHref } from "../shared/media";
|
||||
import { cn, Popover, PopoverContent, PopoverTrigger } from "./_adapter";
|
||||
import type { CitationType, CitationVariant, SerializableCitation } from "./schema";
|
||||
import type { CitationVariant, SerializableCitation } from "./schema";
|
||||
import { TYPE_ICONS } from "./type-icons";
|
||||
|
||||
const FALLBACK_LOCALE = "en-US";
|
||||
|
||||
const TYPE_ICONS: Record<CitationType, LucideIcon> = {
|
||||
webpage: Globe,
|
||||
document: FileText,
|
||||
article: Newspaper,
|
||||
api: Database,
|
||||
code: Code2,
|
||||
other: File,
|
||||
};
|
||||
|
||||
function extractDomain(url: string): string | undefined {
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
|
|
|
|||
12
surfsense_web/components/tool-ui/citation/type-icons.ts
Normal file
12
surfsense_web/components/tool-ui/citation/type-icons.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import type { LucideIcon } from "lucide-react";
|
||||
import { Code2, Database, File, FileText, Globe, Newspaper } from "lucide-react";
|
||||
import type { CitationType } from "./schema";
|
||||
|
||||
export const TYPE_ICONS: Record<CitationType, LucideIcon> = {
|
||||
webpage: Globe,
|
||||
document: FileText,
|
||||
article: Newspaper,
|
||||
api: Database,
|
||||
code: Code2,
|
||||
other: File,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue