Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/admin-x-activitypub/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tryghost/admin-x-activitypub",
"version": "0.7.0",
"version": "0.7.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion apps/admin-x-activitypub/src/api/activitypub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export interface Notification {
title: string | null;
content: string;
url: string;
}
},
createdAt: string;
}

export interface GetNotificationsResponse {
Expand Down

This file was deleted.

11 changes: 4 additions & 7 deletions apps/admin-x-activitypub/src/components/global/APAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ interface APAvatarProps {
isLoading?: boolean;
onClick?: () => void;
disabled?: boolean;
className?: string;
}

const APAvatar: React.FC<APAvatarProps> = ({author, size, isLoading = false, disabled = false}) => {
const APAvatar: React.FC<APAvatarProps> = ({author, size, isLoading = false, disabled = false, className = ''}) => {
let iconSize = 18;
let containerClass = `shrink-0 items-center justify-center rounded-full overflow-hidden relative z-10 flex bg-black/5 dark:bg-gray-900 ${size === 'lg' || disabled ? '' : 'hover:opacity-80 cursor-pointer'}`;
let containerClass = `shrink-0 items-center justify-center rounded-full overflow-hidden relative z-10 flex bg-black/5 dark:bg-gray-900 ${size === 'lg' || disabled ? '' : 'cursor-pointer'} ${className}`;
let imageClass = 'z-10 object-cover';
const [iconUrl, setIconUrl] = useState(author?.icon?.url);
const navigate = useNavigate();
Expand All @@ -45,7 +46,7 @@ const APAvatar: React.FC<APAvatarProps> = ({author, size, isLoading = false, dis
imageClass = clsx('size-6', imageClass);
break;
case 'notification':
iconSize = 12;
iconSize = 16;
containerClass = clsx('size-9', containerClass);
imageClass = clsx('size-9', imageClass);
break;
Expand All @@ -71,10 +72,6 @@ const APAvatar: React.FC<APAvatarProps> = ({author, size, isLoading = false, dis
return <Skeleton className={imageClass} containerClassName={containerClass} />;
}

if (!iconUrl) {
containerClass = clsx(containerClass, 'bg-gray-100 dark:bg-gray-900');
}

const handle = author?.handle || getUsername(author as ActorProperties);

const handleClick = (e: React.MouseEvent) => {
Expand Down
11 changes: 9 additions & 2 deletions apps/admin-x-activitypub/src/utils/content-formatters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export function stripHtml(html: string): string {
return html.replace(/<[^>]*>/g, '');
// Replace <br> tags with spaces
const withLineBreaks = html.replace(/<br\s*\/?>/gi, ' ');

// Replace tags that should have a space after them
const withSpaces = withLineBreaks.replace(/<\/p>\s*<p>|<\/div>\s*<div>|<\/h[1-6]>\s*<|<\/li>\s*<li>|<\/a>/gi, ' ');

// Remove all remaining HTML tags
return withSpaces.replace(/<[^>]*>/g, '').replace(/\s+/g, ' ').trim();
}

export const formatArticle = (content: string, postUrl?: string) => {
Expand Down Expand Up @@ -67,4 +74,4 @@ export const formatFollowNumber = (n: number) => {
// Round to 1 decimal place if needed
const formatted = kValue % 1 === 0 ? kValue : kValue.toFixed(1);
return `${formatted}K`;
};
};
2 changes: 1 addition & 1 deletion apps/admin-x-activitypub/src/utils/render-timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function formatTimestamp(date: Date): string {
}

export function renderTimestamp(object: ObjectProperties, asLink = true) {
const date = new Date(object?.published ?? new Date());
const date = new Date(object?.published ?? object?.createdAt ?? new Date());
const timestamp = formatTimestamp(date);
const formattedTimestamp = getFormattedTimestamp(date);

Expand Down
Loading