diff --git a/apps/admin-x-activitypub/package.json b/apps/admin-x-activitypub/package.json index a88ecd5c2ea..514e7d82c05 100644 --- a/apps/admin-x-activitypub/package.json +++ b/apps/admin-x-activitypub/package.json @@ -1,6 +1,6 @@ { "name": "@tryghost/admin-x-activitypub", - "version": "0.3.22", + "version": "0.3.23", "license": "MIT", "repository": { "type": "git", diff --git a/apps/admin-x-activitypub/src/components/Inbox.tsx b/apps/admin-x-activitypub/src/components/Inbox.tsx index 629af8ddaec..7a7b0579559 100644 --- a/apps/admin-x-activitypub/src/components/Inbox.tsx +++ b/apps/admin-x-activitypub/src/components/Inbox.tsx @@ -86,7 +86,7 @@ const Inbox: React.FC = ({layout}) => { ) : activities.length > 0 ? ( <> -
+
{layout === 'feed' &&
diff --git a/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx b/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx index f5adf514b09..e69aff0b8e5 100644 --- a/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx +++ b/apps/admin-x-activitypub/src/components/feed/FeedItem.tsx @@ -6,6 +6,7 @@ import APAvatar from '../global/APAvatar'; import FeedItemStats from './FeedItemStats'; import clsx from 'clsx'; +import getReadingTime from '../../utils/get-reading-time'; import getRelativeTimestamp from '../../utils/get-relative-timestamp'; import getUsername from '../../utils/get-username'; import stripHtml from '../../utils/strip-html'; @@ -93,7 +94,7 @@ export function renderFeedAttachment(object: ObjectProperties, layout: string) { function renderInboxAttachment(object: ObjectProperties) { const attachment = getAttachment(object); - const videoAttachmentStyles = 'ml-8 shrink-0 rounded-md h-[80px] w-[120px] relative'; + const videoAttachmentStyles = 'ml-8 shrink-0 rounded-md h-[91px] w-[121px] relative'; const imageAttachmentStyles = clsx('object-cover outline outline-1 -outline-offset-1 outline-black/[0.05]', videoAttachmentStyles); if (!attachment) { @@ -391,34 +392,36 @@ const FeedItem: React.FC = ({actor, object, layout, type, comment return ( <> {object && ( -
-
-
- - {author.name} - {getUsername(author)} - {getRelativeTimestamp(date)} -
- - {object.name ? object.name : ( - - )} - -
+
+
+ + {author.name} + {getRelativeTimestamp(date)}
- {renderInboxAttachment(object)} -
- - +
+
+ + {object.name ? object.name : ( + + )} + +
+ {object.content && `${getReadingTime(object.content)}`} +
+ {renderInboxAttachment(object)} +
+ + +
)} diff --git a/apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx b/apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx index fa15dadcff6..6dadd8f5f3c 100644 --- a/apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx +++ b/apps/admin-x-activitypub/src/components/feed/FeedItemStats.tsx @@ -39,7 +39,7 @@ const FeedItemStats: React.FC = ({ setTimeout(() => setIsClicked(false), 300); }; - return (
+ return (
); }; -export default FeedItemStats; \ No newline at end of file +export default FeedItemStats; diff --git a/apps/admin-x-activitypub/src/utils/get-reading-time.ts b/apps/admin-x-activitypub/src/utils/get-reading-time.ts new file mode 100644 index 00000000000..21506c818e6 --- /dev/null +++ b/apps/admin-x-activitypub/src/utils/get-reading-time.ts @@ -0,0 +1,12 @@ +export default function getReadingTime(content: string): string { + // Average reading speed (words per minute) + const wordsPerMinute = 238; + + const wordCount = content.replace(/<[^>]*>/g, '') + .split(/\s+/) + .filter(word => word.length > 0) + .length; + + const minutes = Math.ceil(wordCount / wordsPerMinute); + return `${minutes} min read`; +}