a tool for shared writing and social publishing

fix links in interaction drawer preview

+20 -32
+1
app/(home-pages)/reader/InteractionDrawers.tsx
··· 60 60 const postUrl = getDocumentURL( 61 61 props.selectedPost.document, 62 62 props.selectedPost.document_uri, 63 + props.selectedPost.publication, 63 64 ); 64 65 65 66 const drawerTitle =
+11 -31
app/lish/createPub/getPublicationURL.ts
··· 5 5 import { 6 6 normalizePublicationRecord, 7 7 isLeafletPublication, 8 - hasLeafletContent, 9 8 type NormalizedDocument, 10 9 type NormalizedPublication, 11 10 } from "src/utils/normalizeRecords"; ··· 22 21 const normalized = normalizePublicationRecord(pub.record); 23 22 24 23 // If we have a normalized record with a URL (site.standard format), use it 25 - if (normalized?.url && isProductionDomain()) { 24 + if (normalized?.url) { 26 25 return normalized.url; 27 26 } 28 27 ··· 50 49 /** 51 50 * Gets the full URL for a document. 52 51 * Always appends the document's path property. 53 - * For non-leaflet documents (content.$type !== "pub.leaflet.content"), 54 - * always uses the full publication site URL, not internal /lish/ URLs. 55 52 */ 56 53 export function getDocumentURL( 57 54 doc: NormalizedDocument, ··· 60 57 ): string { 61 58 let path = doc.path || "/" + new AtUri(docUri).rkey; 62 59 if (path[0] !== "/") path = "/" + path; 63 - const aturi = new AtUri(docUri); 64 60 65 - const isNormalized = 66 - !!publication && 67 - (publication as NormalizedPublication).$type === 68 - "site.standard.publication"; 69 - const normPub = isNormalized 70 - ? (publication as NormalizedPublication) 71 - : publication 72 - ? normalizePublicationRecord((publication as PublicationInput).record) 73 - : null; 74 - const pubInput = isNormalized 75 - ? null 76 - : (publication as PublicationInput | null); 77 - 78 - // Non-leaflet documents always use the full publication site URL 79 - if (doc.content && !hasLeafletContent(doc) && normPub?.url) { 80 - return normPub.url + path; 61 + if (!publication) { 62 + return doc.site + path; 81 63 } 82 64 83 - // For leaflet documents, use getPublicationURL (may return /lish/ internal paths) 84 - if (pubInput) { 85 - return getPublicationURL(pubInput) + path; 65 + // Already-normalized publications: use URL directly 66 + if ( 67 + (publication as NormalizedPublication).$type === 68 + "site.standard.publication" 69 + ) { 70 + return ((publication as NormalizedPublication).url || doc.site) + path; 86 71 } 87 72 88 - // When we only have a normalized publication, use its URL directly 89 - if (normPub?.url) { 90 - return normPub.url + path; 91 - } 92 - 93 - // Standalone document fallback 94 - return `/p/${aturi.host}${path}`; 73 + // Raw publication input: delegate to getPublicationURL for full resolution 74 + return getPublicationURL(publication as PublicationInput) + path; 95 75 }
+3
components/PostListing.tsx
··· 168 168 showMentions={mergedPrefs.showMentions !== false} 169 169 documentUri={props.documents.uri} 170 170 document={postRecord} 171 + publication={pubRecord} 171 172 /> 172 173 <Share postUrl={postUrl} /> 173 174 </div> ··· 229 230 showMentions: boolean; 230 231 documentUri: string; 231 232 document: NormalizedDocument; 233 + publication?: NormalizedPublication; 232 234 }) => { 233 235 let setSelectedPostListing = useSelectedPostListing( 234 236 (s) => s.setSelectedPostListing, ··· 237 239 setSelectedPostListing({ 238 240 document_uri: props.documentUri, 239 241 document: props.document, 242 + publication: props.publication, 240 243 drawer, 241 244 }); 242 245 };
+5 -1
src/useSelectedPostState.ts
··· 1 1 import { create } from "zustand"; 2 - import type { NormalizedDocument } from "src/utils/normalizeRecords"; 2 + import type { 3 + NormalizedDocument, 4 + NormalizedPublication, 5 + } from "src/utils/normalizeRecords"; 3 6 4 7 export type SelectedPostListing = { 5 8 document_uri: string; 6 9 document: NormalizedDocument; 10 + publication?: NormalizedPublication; 7 11 drawer: "quotes" | "comments"; 8 12 }; 9 13