- {publication.documents_in_publications
- .filter((d) => !!d?.documents)
- .sort((a, b) => {
- const aRecord = normalizeDocumentRecord(a.documents?.data);
- const bRecord = normalizeDocumentRecord(b.documents?.data);
- const aDate = aRecord?.publishedAt
- ? new Date(aRecord.publishedAt)
- : new Date(0);
- const bDate = bRecord?.publishedAt
- ? new Date(bRecord.publishedAt)
- : new Date(0);
- return bDate.getTime() - aDate.getTime(); // Sort by most recent first
- })
- .map((doc) => {
- if (!doc.documents) return null;
- const doc_record = normalizeDocumentRecord(
- doc.documents.data,
- );
- if (!doc_record) return null;
- let uri = new AtUri(doc.documents.uri);
- let quotes =
- doc.documents.document_mentions_in_bsky[0].count || 0;
- let comments =
- record?.preferences?.showComments === false
- ? 0
- : doc.documents.comments_on_documents[0].count || 0;
- let recommends =
- doc.documents.recommends_on_documents?.[0]?.count || 0;
- let tags = doc_record.tags || [];
+
+ {publication.documents_in_publications
+ .filter((d) => !!d?.documents)
+ .sort((a, b) => {
+ const aRecord = normalizeDocumentRecord(a.documents?.data);
+ const bRecord = normalizeDocumentRecord(b.documents?.data);
+ const aDate = aRecord?.publishedAt
+ ? new Date(aRecord.publishedAt)
+ : new Date(0);
+ const bDate = bRecord?.publishedAt
+ ? new Date(bRecord.publishedAt)
+ : new Date(0);
+ return bDate.getTime() - aDate.getTime(); // Sort by most recent first
+ })
+ .map((doc) => {
+ if (!doc.documents) return null;
+ const doc_record = normalizeDocumentRecord(
+ doc.documents.data,
+ );
+ if (!doc_record) return null;
+ let uri = new AtUri(doc.documents.uri);
+ let quotes =
+ doc.documents.document_mentions_in_bsky[0].count || 0;
+ let comments =
+ record?.preferences?.showComments === false
+ ? 0
+ : doc.documents.comments_on_documents[0].count || 0;
+ let recommends =
+ doc.documents.recommends_on_documents?.[0]?.count || 0;
+ let tags = doc_record.tags || [];
- const docUrl = getDocumentURL(doc_record, doc.documents.uri, publication);
- return (
-
-
-
- {doc_record.title && (
- {doc_record.title}
- )}
-
- {doc_record.description || getFirstParagraph(doc_record)}
-
-
+ const docUrl = getDocumentURL(
+ doc_record,
+ doc.documents.uri,
+ publication,
+ );
+ return (
+
+
+
+ {doc_record.title && (
+
+ {doc_record.title}
+
+ )}
+
+ {doc_record.description ||
+ getFirstParagraph(doc_record)}
+
+
-
-
- {doc_record.publishedAt && (
-
- )}{" "}
-
+
+
+ {doc_record.publishedAt && (
+
+ )}{" "}
+
-
+
+
-
-
-
- );
- })}
-
-
-
-
+
+
+ );
+ })}
+
+
+
+
>
);
} catch (e) {