[APP-2160] Build new standard.site link card UI (#10468)

Co-authored-by: vineyardbovines <spencer@thepope.dev>
Co-authored-by: Eric Bailey <git@esb.lol>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Spence Pope
2026-05-22 18:36:06 -04:00
committed by GitHub
parent 6159cd7777
commit 5db37729bb
28 changed files with 1265 additions and 38 deletions
@@ -0,0 +1,52 @@
import {type AppBskyEmbedExternal} from '@atproto/api'
import {Leaflet} from '#/components/icons/community/Leaflet'
import {Offprint} from '#/components/icons/community/Offprint'
import {Pckt} from '#/components/icons/community/Pckt'
export type StandardSitePublisher = {
host: string
name: string
Icon: typeof Leaflet
}
const STANDARD_SITE_PUBLISHERS: StandardSitePublisher[] = [
{host: 'leaflet.pub', name: 'Leaflet', Icon: Leaflet},
{host: 'pckt.blog', name: 'pckt', Icon: Pckt},
{host: 'offprint.app', name: 'Offprint', Icon: Offprint},
]
function hostFromUri(uri: string | undefined): string | null {
try {
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)
}
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))
}