From 2dd288e9dc2d0e60ddd9c2ee7ce77613d04a0e90 Mon Sep 17 00:00:00 2001 From: Cole Bemis Date: Tue, 3 Oct 2023 16:25:28 +0200 Subject: [PATCH] Add fallback prop to note favicon --- src/components/markdown.tsx | 6 +++++- src/components/note-favicon.tsx | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/markdown.tsx b/src/components/markdown.tsx index a3baf9b6..7c6dc944 100644 --- a/src/components/markdown.tsx +++ b/src/components/markdown.tsx @@ -650,7 +650,11 @@ function NoteLink({ id, text }: NoteLinkProps) { {isFirst && note ? ( - + ) : null} {text} diff --git a/src/components/note-favicon.tsx b/src/components/note-favicon.tsx index e6aa93d5..3c85c77f 100644 --- a/src/components/note-favicon.tsx +++ b/src/components/note-favicon.tsx @@ -6,10 +6,16 @@ import { WebsiteFavicon } from "./website-favicon" type NoteFaviconProps = React.ComponentPropsWithoutRef<"span"> & { note: Note + fallback?: React.ReactNode } -export function NoteFavicon({ note, className, ...props }: NoteFaviconProps) { - let icon = +export function NoteFavicon({ + note, + className, + fallback = , + ...props +}: NoteFaviconProps) { + let icon = fallback // GitHub if (typeof note.frontmatter.github === "string") { @@ -46,6 +52,10 @@ export function NoteFavicon({ note, className, ...props }: NoteFaviconProps) { icon = } + if (!icon) { + return null + } + return (