fix: crashes when docs appear in the discover result (#494)

This commit is contained in:
Kaffi Y. 2024-09-19 11:03:26 +08:00 committed by GitHub
parent eb1dce0976
commit 0c470bed3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -150,7 +150,7 @@ export function FeedIcon({
ImageElement = (
<PlatformIcon
url={feed?.siteUrl!}
url={feed?.siteUrl || fallbackUrl}
style={sizeStyle}
className={cn("center mr-2", className)}
>

View File

@ -16,17 +16,17 @@ const IconMap = Object.values(LinkParsers).reduce(
const shouldAddWhiteBgUrls = ["1x.com"]
export const PlatformIcon: FC<{
url: string
url?: string
children: React.JSX.Element
className?: string
style?: React.CSSProperties
}> = ({ className, url, children, style, ...rest }) => {
const iconName = getSupportedPlatformIconName(url)
const iconName = url && getSupportedPlatformIconName(url)
if (!iconName || !IconMap[iconName]) {
if (!iconName || !IconMap[iconName] || !url) {
return (
<Slot
className={`${shouldAddWhiteBgUrls.some((_) => url.includes(_)) ? "bg-white" : ""} ${className}`}
className={`${url && shouldAddWhiteBgUrls.some((_) => url.includes(_)) ? "bg-white" : ""} ${className}`}
style={style}
{...rest}
>