mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-03 21:02:40 +02:00
Merge pull request #1321 from guangyang1206/perf/lucide-explicit-icons-whitelist
perf(docs): replace full lucide barrel import with explicit icon whit…
This commit is contained in:
commit
cc6da08346
1 changed files with 29 additions and 2 deletions
|
|
@ -1,12 +1,39 @@
|
|||
import { loader } from "fumadocs-core/source";
|
||||
import { icons } from "lucide-react";
|
||||
import {
|
||||
BookOpen,
|
||||
ClipboardCheck,
|
||||
Compass,
|
||||
Container,
|
||||
Download,
|
||||
FlaskConical,
|
||||
Heart,
|
||||
Unplug,
|
||||
Wrench,
|
||||
} from "lucide-react";
|
||||
import { createElement } from "react";
|
||||
import { docs } from "@/.source/server";
|
||||
|
||||
/** Explicit whitelist of Lucide icons used in docs frontmatter / meta.json.
|
||||
* Importing the full `icons` barrel would pull every Lucide icon (~1 400 SVGs)
|
||||
* into the docs bundle even though only a handful are referenced. Add new icons
|
||||
* here as docs pages are added.
|
||||
*/
|
||||
const DOCS_ICONS: Record<string, React.ComponentType> = {
|
||||
BookOpen,
|
||||
ClipboardCheck,
|
||||
Compass,
|
||||
Container,
|
||||
Download,
|
||||
FlaskConical,
|
||||
Heart,
|
||||
Unplug,
|
||||
Wrench,
|
||||
};
|
||||
|
||||
export const source = loader({
|
||||
baseUrl: "/docs",
|
||||
source: docs.toFumadocsSource(),
|
||||
icon(icon) {
|
||||
if (icon && icon in icons) return createElement(icons[icon as keyof typeof icons]);
|
||||
if (icon && icon in DOCS_ICONS) return createElement(DOCS_ICONS[icon]);
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue