nicolium: the same but for events

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-02-26 14:16:27 +01:00
parent f2d602a8fe
commit 531df09182
2 changed files with 83 additions and 16 deletions

View File

@ -342,6 +342,45 @@ const Thread = ({
return children;
}, [thread, linear, status, isModal]);
const meta = useMemo(() => {
const firstAttachment = status.media_attachments && status.media_attachments[0];
return (
<Helmet>
{status.spoiler_text && <meta property='og:title' content={status.spoiler_text} />}
{(firstAttachment?.type === 'image' || firstAttachment?.type === 'gifv') && (
<>
<meta property='og:image' content={firstAttachment.preview_url} />
<meta property='og:image:alt' content={firstAttachment.description || ''} />
{firstAttachment.mime_type && (
<meta property='og:type' content={firstAttachment.mime_type} />
)}
{firstAttachment.meta.original && (
<meta
property='og:image:width'
content={firstAttachment.meta.original.width.toString()}
/>
)}
{firstAttachment.meta.original && (
<meta
property='og:image:height'
content={firstAttachment.meta.original.height.toString()}
/>
)}
</>
)}
<meta property='og:url' content={status.url} />
<meta name='author' content={status.account.display_name || status.account.acct} />
<meta property='article:author' content={status.account.url} />
<meta property='article:published_time' content={status.created_at} />
<meta property='fediverse.creator' name='fediverse.creator' content={status.account.acct} />
{status.edited_at && <meta property='article:modified_time' content={status.edited_at} />}
{status.account.local === false && <meta content='noindex, noarchive' name='robots' />}
</Helmet>
);
}, [status]);
useEffect(() => {
setExpandAllStatuses?.(() => {
expandStatuses(thread);
@ -357,16 +396,7 @@ const Thread = ({
'mt-2': !isModal,
})}
>
<Helmet>
{status.spoiler_text && <meta property='og:title' content={status.spoiler_text} />}
<meta property='og:url' content={status.url} />
<meta name='author' content={status.account.display_name || status.account.acct} />
<meta property='article:author' content={status.account.url} />
<meta property='article:published_time' content={status.created_at} />
{status.edited_at && <meta property='article:modified_time' content={status.edited_at} />}
{status.account.local === false && <meta content='noindex, noarchive' name='robots' />}
</Helmet>
{meta}
<div
ref={node}

View File

@ -1,5 +1,5 @@
import { Outlet, useLocation, useNavigate } from '@tanstack/react-router';
import React from 'react';
import React, { useMemo } from 'react';
import { Helmet } from 'react-helmet-async';
import { FormattedMessage } from 'react-intl';
@ -66,13 +66,50 @@ const EventLayout = () => {
pathname.endsWith(path),
);
const meta = useMemo(() => {
if (!status) return null;
const firstAttachment = status.media_attachments && status.media_attachments[0];
return (
<Helmet>
{status.spoiler_text && <meta property='og:title' content={status.spoiler_text} />}
{(firstAttachment?.type === 'image' || firstAttachment?.type === 'gifv') && (
<>
<meta property='og:image' content={firstAttachment.preview_url} />
<meta property='og:image:alt' content={firstAttachment.description || ''} />
{firstAttachment.mime_type && (
<meta property='og:type' content={firstAttachment.mime_type} />
)}
{firstAttachment.meta.original && (
<meta
property='og:image:width'
content={firstAttachment.meta.original.width.toString()}
/>
)}
{firstAttachment.meta.original && (
<meta
property='og:image:height'
content={firstAttachment.meta.original.height.toString()}
/>
)}
</>
)}
<meta property='og:url' content={status.url} />
<meta name='author' content={status.account.display_name || status.account.acct} />
<meta property='article:author' content={status.account.url} />
<meta property='article:published_time' content={status.created_at} />
<meta property='fediverse.creator' name='fediverse.creator' content={status.account.acct} />
{status.edited_at && <meta property='article:modified_time' content={status.edited_at} />}
{status.account.local === false && <meta content='noindex, noarchive' name='robots' />}
</Helmet>
);
}, [status]);
return (
<>
{status?.account.local === false && (
<Helmet>
<meta content='noindex, noarchive' name='robots' />
</Helmet>
)}
{meta}
<Layout.Main>
<Column label={event?.name} withHeader={false}>
<div className='space-y-4'>