your personal website on atproto - mirror blento.app
at copy-page 115 lines 1.8 kB view raw
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 QuotedPostData = { 43 author: { 44 displayName: string; 45 handle: string; 46 avatar?: string; 47 href?: string; 48 }; 49 href?: string; 50 htmlContent?: string; 51 createdAt?: string; 52 embed?: PostEmbed; 53}; 54 55export type PostEmbedRecord = { 56 type: 'record'; 57 record: QuotedPostData; 58}; 59 60export type PostEmbedRecordWithMedia = { 61 type: 'recordWithMedia'; 62 record: QuotedPostData; 63 media: PostEmbed; 64}; 65 66export type UnknownEmbed = { 67 type: 'unknown'; 68} & Record<string, unknown>; 69 70export type PostEmbed = 71 | PostEmbedImage 72 | PostEmbedExternal 73 | PostEmbedVideo 74 | PostEmbedRecord 75 | PostEmbedRecordWithMedia 76 | UnknownEmbed; 77 78export type PostData = { 79 href?: string; 80 id?: string; 81 82 reposted?: { handle: string; href: string }; 83 replyTo?: { handle: string; href: string }; 84 85 author: { 86 displayName: string; 87 handle: string; 88 avatar?: string; 89 href?: string; 90 }; 91 92 replyCount: number; 93 repostCount: number; 94 likeCount: number; 95 96 createdAt: string; 97 98 embed?: PostEmbed; 99 100 htmlContent?: string; 101 102 replies?: PostData[]; 103 104 labels?: string[]; 105}; 106 107export const nsfwLabels = ['porn', 'sexual', 'graphic-media', 'nudity']; 108 109export function hasNSFWLabel(post: PostData): boolean { 110 if (!post.labels) return false; 111 112 return post.labels.some((label) => nsfwLabels.includes(label)); 113} 114 115export { default as Post } from './Post.svelte';