-
Last updated
-
+ {!!dateToShow && (
+
+
+ {hasSources && (
+ <>
+
+
+ {numCollectionSources}{' '}
+ {pluralize('source', numCollectionSources)}
+
+ >
+ )}
)}
{image && (
diff --git a/packages/shared/src/graphql/posts.ts b/packages/shared/src/graphql/posts.ts
index 5871afd723e..96da9429755 100644
--- a/packages/shared/src/graphql/posts.ts
+++ b/packages/shared/src/graphql/posts.ts
@@ -92,6 +92,10 @@ export const isPostOrSharedPostTwitter = (
): boolean =>
isSocialTwitterPost(post) || isSocialTwitterPost(post?.sharedPost as Post);
+export const isPostUpdated = (
+ post: Pick
,
+): boolean => !!post.updatedAt && post.updatedAt !== post.createdAt;
+
/**
* For social:twitter quote posts, resolve to the top tweet (the post itself)
* rather than the referenced/shared tweet. For all other post types, fall back
diff --git a/packages/shared/src/lib/dateFormat.ts b/packages/shared/src/lib/dateFormat.ts
index 1c319328e9a..1f73e214458 100644
--- a/packages/shared/src/lib/dateFormat.ts
+++ b/packages/shared/src/lib/dateFormat.ts
@@ -73,6 +73,7 @@ export const publishTimeLiveTimer: typeof publishTimeRelativeShort = (
export enum TimeFormatType {
Post = 'post',
+ PostUpdated = 'postUpdated',
Comment = 'comment',
ReadHistory = 'readHistory',
TopReaderBadge = 'topReaderBadge',
@@ -114,6 +115,20 @@ export function postDateFormat(
return date.toLocaleString('en-US', options);
}
+export function postUpdatedDateFormat(
+ value: Date | number | string,
+ now = new Date(),
+): string {
+ const date = new Date(value);
+
+ if (isSameDay(date, now) || isSameDay(date, subDays(now, 1))) {
+ const relative = publishTimeRelativeShort(value, now);
+ return relative === 'now' ? relative : `${relative} ago`;
+ }
+
+ return postDateFormat(value, now);
+}
+
export function commentDateFormat(
value: Date | number | string,
now = new Date(),
@@ -287,6 +302,10 @@ export const formatDate = ({ value, type, now }: FormatDateProps): string => {
return postDateFormat(date);
}
+ if (type === TimeFormatType.PostUpdated) {
+ return postUpdatedDateFormat(date);
+ }
+
if (type === TimeFormatType.Comment) {
return publishTimeRelativeShort(date);
}