summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/web/views/flash.tsx
blob: 6942bcd5e04a05e5e20028e79631ba168356072d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * SPDX-FileCopyrightText: syuilo and misskey-project
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import type { Packed } from '@/misc/json-schema.js';
import type { MiUserProfile } from '@/models/UserProfile.js';
import type { CommonProps } from '@/server/web/views/_.js';
import { Layout } from '@/server/web/views/base.js';

export function FlashPage(props: CommonProps<{
	flash: Packed<'Flash'>;
	profile: MiUserProfile;
}>) {
	function ogBlock() {
		return (
			<>
				<meta property="og:type" content="article" />
				<meta property="og:title" content={props.flash.title} />
				<meta property="og:description" content={props.flash.summary} />
				<meta property="og:url" content={`${props.config.webUrl}/play/${props.flash.id}`} />
				{props.flash.user.avatarUrl ? (
					<>
						<meta property="og:image" content={props.flash.user.avatarUrl} />
						<meta property="twitter:card" content="summary" />
					</>
				) : null}
			</>
		);
	}

	function metaBlock() {
		return (
			<>
				{props.profile.noCrawle ? <meta name="robots" content="noindex" /> : null}
				{props.profile.preventAiLearning ? (
					<>
						<meta name="robots" content="noimageai" />
						<meta name="robots" content="noai" />
					</>
				) : null}
				<meta name="misskey:user-username" content={props.flash.user.username} />
				<meta name="misskey:user-id" content={props.flash.user.id} />
				<meta name="misskey:flash-id" content={props.flash.id} />
			</>
		);
	}

	return (
		<Layout
			{...props}
			title={`${props.flash.title} | ${props.instanceName}`}
			desc={props.flash.summary}
			metaSlot={metaBlock()}
			ogSlot={ogBlock()}
		>
		</Layout>
	);
}