From c4c679446ce32fa4b2c78c971b887dc5ded46778 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 22 May 2026 17:04:45 -0500 Subject: [PATCH] [APP-2160] Use publisher icon for known hosts in PublicationMetaRow Co-Authored-By: Claude Opus 4.7 --- .../StandardSiteEmbed/PublicationMetaRow.tsx | 9 ++++-- .../Embed/StandardSiteEmbed/publishers.ts | 29 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/components/Post/Embed/StandardSiteEmbed/PublicationMetaRow.tsx b/src/components/Post/Embed/StandardSiteEmbed/PublicationMetaRow.tsx index 5b63e34062..e5a5cf5415 100644 --- a/src/components/Post/Embed/StandardSiteEmbed/PublicationMetaRow.tsx +++ b/src/components/Post/Embed/StandardSiteEmbed/PublicationMetaRow.tsx @@ -8,7 +8,10 @@ import {toNiceDomain} from '#/lib/strings/url-helpers' import {atoms as a, useTheme} from '#/alf' import {StandardSite} from '#/components/icons/community/StandardSite' import {InlineLinkText} from '#/components/Link' -import {matchStandardSitePublisher} from '#/components/Post/Embed/StandardSiteEmbed/publishers' +import { + matchStandardSitePublisher, + matchStandardSitePublisherByUri, +} from '#/components/Post/Embed/StandardSiteEmbed/publishers' import {isStandardSiteDocumentUri} from '#/components/Post/Embed/StandardSiteEmbed/utils' import {Text} from '#/components/Typography' @@ -34,6 +37,8 @@ export function PublicationMetaRow({ ? view.associatedProfiles?.find(p => p.did === authorDid) : undefined const articleDomain = toNiceDomain(view.uri) + const articlePublisher = matchStandardSitePublisherByUri(view.uri) + const DomainIcon = articlePublisher?.Icon ?? StandardSite const metaTextStyle = [ a.text_xs, a.leading_snug, @@ -47,7 +52,7 @@ export function PublicationMetaRow({ key: 'domain', node: ( - + {articleDomain} diff --git a/src/components/Post/Embed/StandardSiteEmbed/publishers.ts b/src/components/Post/Embed/StandardSiteEmbed/publishers.ts index 7976f24c1b..aba3e28cc2 100644 --- a/src/components/Post/Embed/StandardSiteEmbed/publishers.ts +++ b/src/components/Post/Embed/StandardSiteEmbed/publishers.ts @@ -16,24 +16,37 @@ const STANDARD_SITE_PUBLISHERS: StandardSitePublisher[] = [ {host: 'offprint.app', name: 'Offprint', Icon: Offprint}, ] -export function getStandardSitePublisherHost( - view: AppBskyEmbedExternal.ViewExternal, -): string | null { +function hostFromUri(uri: string | undefined): string | null { try { - return new URL(view.source?.uri || '').host + return new URL(uri || '').host } catch { return null } } +export function getStandardSitePublisherHost( + view: AppBskyEmbedExternal.ViewExternal, +): string | null { + return hostFromUri(view.source?.uri) +} + export function hostMatches(host: string, target: string): boolean { return host === target || host.endsWith('.' + target) } -export function matchStandardSitePublisher( - view: AppBskyEmbedExternal.ViewExternal, -): StandardSitePublisher | null { - const host = getStandardSitePublisherHost(view) +function matchByHost(host: string | null): StandardSitePublisher | null { if (!host) return null return STANDARD_SITE_PUBLISHERS.find(p => hostMatches(host, p.host)) ?? null } + +export function matchStandardSitePublisher( + view: AppBskyEmbedExternal.ViewExternal, +): StandardSitePublisher | null { + return matchByHost(getStandardSitePublisherHost(view)) +} + +export function matchStandardSitePublisherByUri( + uri: string | undefined, +): StandardSitePublisher | null { + return matchByHost(hostFromUri(uri)) +}