From f6fd56833d6cc6412584e049790dbed05cf28ca2 Mon Sep 17 00:00:00 2001 From: Lio Date: Thu, 25 Jul 2024 20:45:07 +0200 Subject: [PATCH] put nsfw behind a searchParam --- src/components/Image.astro | 80 +++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/src/components/Image.astro b/src/components/Image.astro index 8425f21..c7ff86e 100644 --- a/src/components/Image.astro +++ b/src/components/Image.astro @@ -1,40 +1,68 @@ --- -const { src, alt, nsfw } = Astro.props; +const { src, alt, nsfw, artist } = Astro.props; +const showNsfw = Astro.url.searchParams.has('nsfw') || false; --- -
-
- {alt} - { - alt && ( +
+ { (nsfw && showNsfw) ? ( +
+
+ {`${alt` : ""} ${artist ? `by ${artist}` : ""}`} loading="lazy" /> + { + alt && ( +
+ {alt} +
+ ) + } +
+
+ ): null } + + { !nsfw ? ( +
- {alt} + {`${alt` : ""} ${artist ? `by ${artist}` : ""}`} loading="lazy" /> + { + alt && ( +
+ {alt} +
+ ) + }
- ) - } -
+
+ ): null } +