diff --git a/app/api/rpc/[command]/get_leaflet_data.ts b/app/api/rpc/[command]/get_leaflet_data.ts index 654a0f74..19779b39 100644 --- a/app/api/rpc/[command]/get_leaflet_data.ts +++ b/app/api/rpc/[command]/get_leaflet_data.ts @@ -19,7 +19,7 @@ export const get_leaflet_data = makeRoute({ .from("permission_tokens") .select( `*, - permission_token_rights(*, entity_sets(permission_tokens(${leaflets_in_publications_query}))), + permission_token_rights(*, entity_sets(permission_tokens(${leaflets_in_publications_query}, ${leaflets_to_documents_query}))), custom_domain_routes!custom_domain_routes_edit_permission_token_fkey(*), ${leaflets_in_publications_query}, ${leaflets_to_documents_query}`, diff --git a/components/PageSWRDataProvider.tsx b/components/PageSWRDataProvider.tsx index e9d3abe5..53bdd4f8 100644 --- a/components/PageSWRDataProvider.tsx +++ b/components/PageSWRDataProvider.tsx @@ -75,9 +75,13 @@ export function useLeafletPublicationData() { )?.leaflets_in_publications?.[0]; // If not found, check for standalone documents - if (!pubData && data?.leaflets_to_documents?.[0]) { + let standaloneDoc = + data?.leaflets_to_documents?.[0] || + data?.permission_token_rights[0].entity_sets?.permission_tokens.find( + (p) => p.leaflets_to_documents.length, + )?.leaflets_to_documents?.[0]; + if (!pubData && standaloneDoc) { // Transform standalone document data to match the expected format - let standaloneDoc = data.leaflets_to_documents[0]; pubData = { ...standaloneDoc, publications: null, // No publication for standalone docs diff --git a/components/Pages/PublicationMetadata.tsx b/components/Pages/PublicationMetadata.tsx index 99274bed..40b2f932 100644 --- a/components/Pages/PublicationMetadata.tsx +++ b/components/Pages/PublicationMetadata.tsx @@ -86,7 +86,7 @@ export const PublicationMetadata = () => { href={ pub.publications ? `${getPublicationURL(pub.publications)}/${new AtUri(pub.doc).rkey}` - : `/p/${identity?.atp_did}/${new AtUri(pub.doc).rkey}` + : `/p/${new AtUri(pub.doc).host}/${new AtUri(pub.doc).rkey}` } > View Post