From c7b295c65af032e17de9a4386e00f5997940ef03 Mon Sep 17 00:00:00 2001
From: Adrian Föder <adrian@foeder.de>
Date: Wed, 07 Aug 2024 06:33:35 +0000
Subject: [PATCH] feat: allow hiding of images and videos

---
 layouts/_default/baseof.html                   |    4 ++--
 tests/exampleSiteWithVideo/urls.txt            |    1 +
 tests/exampleSiteWithImage/urls.txt            |    1 +
 tests/exampleSiteWithVideo/content/no-video.md |    6 ++++++
 README.md                                      |   11 +++++++++++
 tests/exampleSiteWithImage/content/no-image.md |    6 ++++++
 6 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index f38a0a0..1ea7849 100644
--- a/README.md
+++ b/README.md
@@ -76,6 +76,15 @@
   position = "center center"
 ```
 
+You can control displaying of the image on a per-page basis by configuring `visual.image.enable` on each respective page's FrontMatter:
+
+```markdown
++++
+visual.image.enable = false
++++
+
+# Privacy statement
+```
 
 ### Use a video
 
@@ -85,6 +94,8 @@
 
 You can either use a video that you host or one that is on YouTube.
 
+Just like with [an image](#use-an-image) you can not display a video altogether on particular pages by setting `visual.video.enable = false` in the page's FrontMatter.
+
 ##### Use your own video
 
 Add your video to the `static` folder and change `file` to the location of your video accordingly. Make sure you delete `youtubeId` or comment it out.
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 5784276..b1023e9 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -10,14 +10,14 @@
   <div class="fs-split">
 
     <!-- Image -->
-    {{ if .Site.Params.visual.image.enable }}
+    {{ if .Params.visual.image.enable | default .Site.Params.visual.image.enable }}
 
       <div class="split-image">
 
       </div>
 
     <!-- Video -->
-    {{ else if .Site.Params.visual.video.enable }}
+    {{ else if .Params.visual.video.enable | default .Site.Params.visual.video.enable }}
 
       {{ partial "video" . }}
 
diff --git a/tests/exampleSiteWithImage/content/no-image.md b/tests/exampleSiteWithImage/content/no-image.md
new file mode 100644
index 0000000..6dbee28
--- /dev/null
+++ b/tests/exampleSiteWithImage/content/no-image.md
@@ -0,0 +1,6 @@
++++
+title = "No image"
+visual.image.enable = false
++++
+
+Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci.
diff --git a/tests/exampleSiteWithImage/urls.txt b/tests/exampleSiteWithImage/urls.txt
index 8350113..3c5e691 100644
--- a/tests/exampleSiteWithImage/urls.txt
+++ b/tests/exampleSiteWithImage/urls.txt
@@ -1,3 +1,4 @@
 http://hugo:1313/index.html
 http://hugo:1313/commonmark.html
 http://hugo:1313/long-text.html
+http://hugo:1313/no-image.html
diff --git a/tests/exampleSiteWithVideo/content/no-video.md b/tests/exampleSiteWithVideo/content/no-video.md
new file mode 100644
index 0000000..4d02a67
--- /dev/null
+++ b/tests/exampleSiteWithVideo/content/no-video.md
@@ -0,0 +1,6 @@
++++
+title = "No video"
+visual.video.enable = false
++++
+
+Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci.
diff --git a/tests/exampleSiteWithVideo/urls.txt b/tests/exampleSiteWithVideo/urls.txt
index 8350113..dfe6cf4 100644
--- a/tests/exampleSiteWithVideo/urls.txt
+++ b/tests/exampleSiteWithVideo/urls.txt
@@ -1,3 +1,4 @@
 http://hugo:1313/index.html
 http://hugo:1313/commonmark.html
 http://hugo:1313/long-text.html
+http://hugo:1313/no-video.html

--
Gitblit v1.10.0