diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte
index e8f9836a..7d459d40 100644
--- a/src/lib/components/lemmy/post/Post.svelte
+++ b/src/lib/components/lemmy/post/Post.svelte
@@ -5,7 +5,10 @@
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
import { userSettings } from '$lib/settings.js'
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
- import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
+ import PostMeta, {
+ parseTags,
+ type Tag,
+ } from '$lib/components/lemmy/post/PostMeta.svelte'
import { Badge, Material, toast } from 'mono-svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
@@ -34,6 +37,10 @@
export let view = $userSettings.view
$: type = mediaType(post.post.url, view)
+
+ $: tags = parseTags(post.post.name)
+ $: rule = getTagRule(tags.tags)
+
$: hideTitle =
$userSettings.posts.deduplicateEmbed &&
post.post.embed_title == post.post.name &&
@@ -45,6 +52,19 @@
post.post.embed_description == post.post.body &&
view != 'compact'
+ function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined {
+ const tagContent = tags.map((t) => t.content.toLowerCase())
+
+ let rule: 'blur' | 'hide' | undefined
+ tagContent.forEach((tag) => {
+ if ($userSettings.tagRules?.[tag])
+ rule = $userSettings.tagRules?.[tag] ?? rule
+ if (rule == 'hide') return rule
+ })
+
+ return rule
+ }
+
function onClick(e: any) {
const event = e as MouseEvent
const parent = document.getElementById(post.post.id.toString())
@@ -77,7 +97,8 @@
}}
>
@@ -107,13 +129,20 @@
style="grid-area:embed;"
class={view == 'list' || view == 'compact' ? '' : 'contents'}
>
-
+ {#if rule != 'hide'}
+
+ {/if}
{#if view == 'list' || view == 'compact'}
+ export interface Tag {
+ content: string
+ color?: string
+ icon?: IconSource
+ }
+
+ export const textToTag: Map = new Map([
+ ['OC', { content: 'OC', color: '#03A8F240' }],
+ ['NSFL', { content: 'NSFL', color: '#ff000040' }],
+ ['CW', { content: 'CW', color: '#ff000040' }],
+ ])
+
+ export const parseTags = (
+ title?: string
+ ): { tags: Tag[]; title?: string } => {
+ if (!title) return { tags: [] }
+
+ let extracted: Tag[] = []
+
+ title = title.replace(/\[(.*?)\]/g, (match, content) => {
+ extracted.push(
+ textToTag.get(content) ?? {
+ content: content,
+ }
+ )
+ return ''
+ })
+
+ return {
+ tags: extracted,
+ title: title,
+ }
+ }
+
+
@@ -74,7 +75,7 @@
transition-opacity duration-300 object-contain mx-auto"
width={512}
height={300}
- class:blur-3xl={post.nsfw && $userSettings.nsfwBlur}
+ class:blur-3xl={blur}
alt={post.alt_text ?? ''}
/>
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 0f409453..0dc284c1 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -636,6 +636,10 @@
"title": "Translation",
"description": "The LibreTranslate instance to use for translation.",
"instance": "Domain"
+ },
+ "titleTags": {
+ "title": "Parse tags in title",
+ "description": "Take text in [brackets] and turn it into tags that you can click to search for."
}
},
"embeds": {
diff --git a/src/lib/settings.ts b/src/lib/settings.ts
index a452db39..d86ce9b0 100644
--- a/src/lib/settings.ts
+++ b/src/lib/settings.ts
@@ -91,6 +91,9 @@ interface Settings {
language: string | null
useRtl: boolean
translator: string | undefined
+ tagRules: {
+ [key: string]: 'hide' | 'blur'
+ }
}
export const defaultSettings: Settings = {
@@ -159,6 +162,10 @@ export const defaultSettings: Settings = {
language: env.PUBLIC_LANGUAGE ?? null,
useRtl: false,
translator: env.PUBLIC_TRANSLATOR ?? undefined,
+ tagRules: {
+ cw: 'blur',
+ nsfl: 'blur',
+ },
}
export const userSettings = writable(defaultSettings)
diff --git a/src/routes/post/[instance]/[id=integer]/+page.svelte b/src/routes/post/[instance]/[id=integer]/+page.svelte
index da241904..08bbe20e 100644
--- a/src/routes/post/[instance]/[id=integer]/+page.svelte
+++ b/src/routes/post/[instance]/[id=integer]/+page.svelte
@@ -190,6 +190,7 @@
moderator: post.post_view.creator_is_moderator,
}}
published={publishedToDate(post.post_view.post.published)}
+ bind:title={post.post_view.post.name}
/>