tangled
alpha
login
or
join now
flo-bit.dev
/
blento
your personal website on atproto - mirror
blento.app
16
fork
atom
overview
issues
pulls
pipelines
hide nsfw labeled posts
Florian
1 week ago
80f9972f
ee481ff6
+38
-4
4 changed files
expand all
collapse all
unified
split
src
lib
components
bluesky-post
index.ts
post
Post.svelte
PostEmbed.svelte
index.ts
+3
-1
src/lib/components/bluesky-post/index.ts
···
26
26
// const reason = data.reason;
27
27
// const reply = data.reply?.parent;
28
28
// const replyId = reply?.uri?.split('/').pop();
29
29
+
console.log(JSON.parse(JSON.stringify(data)));
29
30
30
31
const id = post.uri.split('/').pop();
31
32
···
87
88
} as PostEmbed)
88
89
: undefined,
89
90
90
90
-
htmlContent: blueskyPostToHTML(post, baseUrl)
91
91
+
htmlContent: blueskyPostToHTML(post, baseUrl),
92
92
+
labels: post.labels ? post.labels.map((label) => label.val) : undefined
91
93
};
92
94
}
93
95
+2
-3
src/lib/components/post/Post.svelte
···
8
8
import type { Snippet } from 'svelte';
9
9
import { numberToHumanReadable } from '..';
10
10
import { RelativeTime } from '@foxui/time';
11
11
+
import PostEmbed from './PostEmbed.svelte';
11
12
12
13
let {
13
14
ref = $bindable(),
···
181
182
{/if}
182
183
</Prose>
183
184
184
184
-
{#if data.embed}
185
185
-
<Embed embed={data.embed} />
186
186
-
{/if}
185
185
+
<PostEmbed {data} />
187
186
188
187
{#if showReply || showRepost || showLike || showBookmark || customActions}
189
188
<div
+23
src/lib/components/post/PostEmbed.svelte
···
1
1
+
<script lang="ts">
2
2
+
import { hasNSFWLabel, type PostData } from '.';
3
3
+
import Embed from './embeds/Embed.svelte';
4
4
+
5
5
+
let {
6
6
+
data
7
7
+
}: {
8
8
+
data: PostData;
9
9
+
} = $props();
10
10
+
11
11
+
let showNSFW = $state(false);
12
12
+
</script>
13
13
+
14
14
+
{#if hasNSFWLabel(data) && !showNSFW}
15
15
+
<button
16
16
+
onclick={() => (showNSFW = true)}
17
17
+
class="border-base-500/20 bg-base-200/50 text-base-600 dark:border-base-400/20 dark:bg-base-800/50 dark:text-base-400 accent:border-accent-900 mt-4 flex h-18 w-full cursor-pointer items-center justify-center rounded-2xl border text-center text-sm"
18
18
+
>
19
19
+
NSFW content, click to show.
20
20
+
</button>
21
21
+
{:else if data.embed}
22
22
+
<Embed embed={data.embed} />
23
23
+
{/if}
+10
src/lib/components/post/index.ts
···
70
70
htmlContent?: string;
71
71
72
72
replies?: PostData[];
73
73
+
74
74
+
labels?: string[];
73
75
};
76
76
+
77
77
+
export const nsfwLabels = ['porn', 'sexual', 'graphic-media', 'nudity'];
78
78
+
79
79
+
export function hasNSFWLabel(post: PostData): boolean {
80
80
+
if (!post.labels) return false;
81
81
+
82
82
+
return post.labels.some((label) => nsfwLabels.includes(label));
83
83
+
}
74
84
75
85
export { default as Post } from './Post.svelte';