From c97c456fe2bbc57954e7e939170bdfffe787fb6d Mon Sep 17 00:00:00 2001 From: Tynan Purdy Date: Wed, 18 Jun 2025 21:42:30 -0400 Subject: [PATCH] minimum prototype of simplified handle page --- src/components/repoIcons.tsx | 25 +++++++++++---- src/routes/at:/$handle.index.tsx | 54 +++++++++++++++++++------------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/src/components/repoIcons.tsx b/src/components/repoIcons.tsx index ac84193..5f14acc 100644 --- a/src/components/repoIcons.tsx +++ b/src/components/repoIcons.tsx @@ -68,6 +68,11 @@ function getIconForCollection(collection: string) { return matchingKey ? iconMappings[matchingKey] : null; } +function reverseDomain(collection: string) { + // Split by dot, reverse, join with dot + return collection.split(".").reverse().join("."); +} + function RepoIcons({ collections, did, @@ -79,12 +84,18 @@ function RepoIcons({ }) { let uniqueTypes = Array.from( collections - .map((collection) => ({ - id: collection, - Icon: getIconForCollection(collection)?.icon ?? , - displayName: getIconForCollection(collection)?.label ?? "Unknown", - linkTemplate: getIconForCollection(collection)?.linkTemplate, - })) + .map((collection) => { + const iconObj = getIconForCollection(collection); + return { + id: collection, + Icon: iconObj?.icon ?? , + displayName: iconObj?.label ?? "Unknown", + // If linkTemplate exists, use it; else generate URL from reversed domain + linkTemplate: + iconObj?.linkTemplate ?? + `https://${reverseDomain(collection)}/{did}`, + }; + }) .reduce((acc, current) => { if ( !Array.from(acc.values()).some( @@ -107,6 +118,8 @@ function RepoIcons({
{typeof Icon === "string" ? ( diff --git a/src/routes/at:/$handle.index.tsx b/src/routes/at:/$handle.index.tsx index 826f73b..f6ab68b 100644 --- a/src/routes/at:/$handle.index.tsx +++ b/src/routes/at:/$handle.index.tsx @@ -252,32 +252,44 @@ function RouteComponent() {

Collections

    - {data.collections.map((c, i) => ( - - {c.split(".").slice(0, 2).join(".") != - (i > 0 && - data.collections[i - 1] - .split(".") - .slice(0, 2) - .join(".")) && ( -
    - {c.split(".").slice(0, 2).join(".")}{" "} -
    - )} -
  • + {Array.from( + data.collections + .reduce((map, c) => { + const prefix = c.split(".").slice(0, 2).join("."); + if (!map.has(prefix)) { + map.set(prefix, prefix); + } + return map; + }, new Map()) + .values(), + ).map((prefix) => { + const domain = prefix.split(".").reverse().join("."); + const faviconUrl = `https://www.google.com/s2/favicons?sz=64&domain=${domain}`; + return ( +
  • + {`${domain} { + // Hide image if favicon not found + (e.target as HTMLImageElement).style.display = "none"; + }} + /> - {c} + {`https://${domain}`}
  • -
    - ))} + ); + })}
)} @@ -309,11 +321,11 @@ function RouteComponent() { )} {/* Backlinks Section */} - {data?.did && ( + {/* {data?.did && (
- )} + )} */}
); -- 2.51.2