« get me outta code hell

content, css: generatePageLayout: fallback background rule - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-01-23 16:00:09 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-23 16:00:09 -0400
commitdd4fc11373c63666f25fa62af7e3a515ee06400a (patch)
tree266176f742725715155e0182c4971e93a475ba82 /src/content
parentb83551a8d10fbbfedb710712cce5adff413fac30 (diff)
content, css: generatePageLayout: fallback background rule
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generatePageLayout.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js
index fa2cdc18..4c37c5af 100644
--- a/src/content/dependencies/generatePageLayout.js
+++ b/src/content/dependencies/generatePageLayout.js
@@ -578,6 +578,16 @@ export default {
           ])),
       ]));
 
+    const styleRulesCSS =
+      html.resolve(slots.styleRules, {normalize: 'string'});
+
+    const fallbackBackgroundStyleRule =
+      (styleRulesCSS.match(/body::before[^}]*background-image:/)
+        ? ''
+        : `body::before {\n` +
+          `    background-image: url("${to('media.path', 'bg.jpg')}");\n` +
+          `}`);
+
     const numWallpaperParts =
       html.resolve(slots.styleRules, {normalize: 'string'})
         .match(/\.wallpaper-part:nth-child/g)
@@ -725,6 +735,8 @@ export default {
             html.tag('style', [
               relations.colorStyleRules
                 .slot('color', slots.color ?? data.wikiColor),
+
+              fallbackBackgroundStyleRule,
               slots.styleRules,
             ]),