refacto: use microcosm endpoint and change types

This commit is contained in:
Julien Calixte
2026-02-17 09:26:26 +01:00
parent 8c7503abac
commit 103b23884f
11 changed files with 171 additions and 74 deletions

View File

@@ -1,11 +1,11 @@
export const withATProtoImages = (
markdown: string,
{ endpoint, did }: { endpoint: string; did: string },
{ pds, did }: { pds: string; did: string },
): string => {
const imageLinkPattern = /!\[([^\]]*)\]\((bafkrei[a-z0-9]+)\)/g
return markdown.replace(imageLinkPattern, (_, altText, cid) => {
const imageUrl = new URL("/xrpc/com.atproto.sync.getBlob", endpoint)
const imageUrl = new URL("/xrpc/com.atproto.sync.getBlob", pds)
imageUrl.searchParams.set("did", did)
imageUrl.searchParams.set("cid", cid)
return `![${altText}](${imageUrl.toString()})`