your personal website on atproto - mirror
blento.app
1export type PostEmbedImage = {
2 type: 'images';
3
4 images: {
5 alt: string;
6 thumb: string;
7 fullsize: string;
8 aspectRatio?: {
9 width: number;
10 height: number;
11 };
12 }[];
13};
14
15export type PostEmbedExternal = {
16 type: 'external';
17
18 external: {
19 href: string;
20 thumb: string;
21 title: string;
22 description: string;
23 };
24};
25
26export type PostEmbedVideo = {
27 type: 'video';
28
29 video: {
30 playlist: string;
31
32 thumb: string;
33 alt: string;
34
35 aspectRatio?: {
36 width: number;
37 height: number;
38 };
39 };
40};
41
42export type UnknownEmbed = {
43 type: 'unknown';
44} & Record<string, unknown>;
45
46export type PostEmbed = PostEmbedImage | PostEmbedExternal | PostEmbedVideo | UnknownEmbed;
47
48export type PostData = {
49 href?: string;
50 id?: string;
51
52 reposted?: { handle: string; href: string };
53 replyTo?: { handle: string; href: string };
54
55 author: {
56 displayName: string;
57 handle: string;
58 avatar?: string;
59 href?: string;
60 };
61
62 replyCount: number;
63 repostCount: number;
64 likeCount: number;
65
66 createdAt: string;
67
68 embed?: PostEmbed;
69
70 htmlContent?: string;
71
72 replies?: PostData[];
73
74 labels?: string[];
75};
76
77export const nsfwLabels = ['porn', 'sexual', 'graphic-media', 'nudity'];
78
79export function hasNSFWLabel(post: PostData): boolean {
80 if (!post.labels) return false;
81
82 return post.labels.some((label) => nsfwLabels.includes(label));
83}
84
85export { default as Post } from './Post.svelte';