···5import {
6 normalizePublicationRecord,
7 isLeafletPublication,
8- hasLeafletContent,
9 type NormalizedDocument,
10 type NormalizedPublication,
11} from "src/utils/normalizeRecords";
···22 const normalized = normalizePublicationRecord(pub.record);
2324 // If we have a normalized record with a URL (site.standard format), use it
25- if (normalized?.url && isProductionDomain()) {
26 return normalized.url;
27 }
28···50/**
51 * Gets the full URL for a document.
52 * 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 */
56export function getDocumentURL(
57 doc: NormalizedDocument,
···60): string {
61 let path = doc.path || "/" + new AtUri(docUri).rkey;
62 if (path[0] !== "/") path = "/" + path;
63- const aturi = new AtUri(docUri);
6465- 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;
81 }
8283- // For leaflet documents, use getPublicationURL (may return /lish/ internal paths)
84- if (pubInput) {
85- return getPublicationURL(pubInput) + path;
00086 }
8788- // 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}`;
95}
···5import {
6 normalizePublicationRecord,
7 isLeafletPublication,
08 type NormalizedDocument,
9 type NormalizedPublication,
10} from "src/utils/normalizeRecords";
···21 const normalized = normalizePublicationRecord(pub.record);
2223 // If we have a normalized record with a URL (site.standard format), use it
24+ if (normalized?.url) {
25 return normalized.url;
26 }
27···49/**
50 * Gets the full URL for a document.
51 * Always appends the document's path property.
0052 */
53export function getDocumentURL(
54 doc: NormalizedDocument,
···57): string {
58 let path = doc.path || "/" + new AtUri(docUri).rkey;
59 if (path[0] !== "/") path = "/" + path;
06061+ if (!publication) {
62+ return doc.site + path;
0000000000000063 }
6465+ // 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;
71 }
7273+ // Raw publication input: delegate to getPublicationURL for full resolution
74+ return getPublicationURL(publication as PublicationInput) + path;
0000075}