From 53c37fecad7342e84d6c620c2fdf730a2b92e13c Mon Sep 17 00:00:00 2001 From: mrboxs Date: Mon, 9 Nov 2026 05:24:09 +0700 Subject: [PATCH 01/10] feat(web): add favicons to Markdown links - Show site favicons on ordinary internal and external links - Keep image links undecorated and hide favicons that fail to load --- .../public-content/content-link.tsx | 40 +++++++++- apps/web/tests/admin-blog-editor.test.tsx | 38 +++++++++ apps/web/tests/public-content.test.tsx | 78 ++++++++++++++++++- 3 files changed, 152 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/public-content/content-link.tsx b/apps/web/src/components/public-content/content-link.tsx index e1b92de..505921a 100644 --- a/apps/web/src/components/public-content/content-link.tsx +++ b/apps/web/src/components/public-content/content-link.tsx @@ -1,6 +1,7 @@ import { IconExternalLink, IconFolders } from '@tabler/icons-react' import { Link, useRouter } from '@tanstack/react-router' import type { Element, ElementContent } from 'hast' +import { useState } from 'react' import type { ReactNode } from 'react' import { env } from '@altstack/env/web' @@ -47,10 +48,20 @@ export function ContentLink({ ) } + const imageLink = node && containsImage(node) + const faviconSrc = target.internal + ? '/favicon.svg' + : `https://www.google.com/s2/favicons?domain=${encodeURIComponent(target.url.hostname)}&sz=32` + const linkContent = ( + <> + {!imageLink && } + {children} + + ) if (!target.internal) { return ( - {children} + {linkContent}