tangled
alpha
login
or
join now
flo-bit.dev
/
blento
your personal website on atproto - mirror
blento.app
20
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
// const reason = data.reason;
27
// const reply = data.reply?.parent;
28
// const replyId = reply?.uri?.split('/').pop();
0
29
30
const id = post.uri.split('/').pop();
31
···
87
} as PostEmbed)
88
: undefined,
89
90
-
htmlContent: blueskyPostToHTML(post, baseUrl)
0
91
};
92
}
93
···
26
// const reason = data.reason;
27
// const reply = data.reply?.parent;
28
// const replyId = reply?.uri?.split('/').pop();
29
+
console.log(JSON.parse(JSON.stringify(data)));
30
31
const id = post.uri.split('/').pop();
32
···
88
} as PostEmbed)
89
: undefined,
90
91
+
htmlContent: blueskyPostToHTML(post, baseUrl),
92
+
labels: post.labels ? post.labels.map((label) => label.val) : undefined
93
};
94
}
95
+2
-3
src/lib/components/post/Post.svelte
···
8
import type { Snippet } from 'svelte';
9
import { numberToHumanReadable } from '..';
10
import { RelativeTime } from '@foxui/time';
0
11
12
let {
13
ref = $bindable(),
···
181
{/if}
182
</Prose>
183
184
-
{#if data.embed}
185
-
<Embed embed={data.embed} />
186
-
{/if}
187
188
{#if showReply || showRepost || showLike || showBookmark || customActions}
189
<div
···
8
import type { Snippet } from 'svelte';
9
import { numberToHumanReadable } from '..';
10
import { RelativeTime } from '@foxui/time';
11
+
import PostEmbed from './PostEmbed.svelte';
12
13
let {
14
ref = $bindable(),
···
182
{/if}
183
</Prose>
184
185
+
<PostEmbed {data} />
0
0
186
187
{#if showReply || showRepost || showLike || showBookmark || customActions}
188
<div
+23
src/lib/components/post/PostEmbed.svelte
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
<script lang="ts">
2
+
import { hasNSFWLabel, type PostData } from '.';
3
+
import Embed from './embeds/Embed.svelte';
4
+
5
+
let {
6
+
data
7
+
}: {
8
+
data: PostData;
9
+
} = $props();
10
+
11
+
let showNSFW = $state(false);
12
+
</script>
13
+
14
+
{#if hasNSFWLabel(data) && !showNSFW}
15
+
<button
16
+
onclick={() => (showNSFW = true)}
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
+
>
19
+
NSFW content, click to show.
20
+
</button>
21
+
{:else if data.embed}
22
+
<Embed embed={data.embed} />
23
+
{/if}
+10
src/lib/components/post/index.ts
···
70
htmlContent?: string;
71
72
replies?: PostData[];
0
0
73
};
0
0
0
0
0
0
0
0
74
75
export { default as Post } from './Post.svelte';
···
70
htmlContent?: string;
71
72
replies?: PostData[];
73
+
74
+
labels?: string[];
75
};
76
+
77
+
export const nsfwLabels = ['porn', 'sexual', 'graphic-media', 'nudity'];
78
+
79
+
export function hasNSFWLabel(post: PostData): boolean {
80
+
if (!post.labels) return false;
81
+
82
+
return post.labels.some((label) => nsfwLabels.includes(label));
83
+
}
84
85
export { default as Post } from './Post.svelte';