« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateAlbumSocialEmbed.js9
-rw-r--r--src/content/dependencies/generatePageLayout.js12
-rw-r--r--src/content/dependencies/generateSocialEmbed.js11
-rw-r--r--src/content/dependencies/generateTrackSocialEmbed.js14
4 files changed, 26 insertions, 20 deletions
diff --git a/src/content/dependencies/generateAlbumSocialEmbed.js b/src/content/dependencies/generateAlbumSocialEmbed.js
index 54574e45..ad02e180 100644
--- a/src/content/dependencies/generateAlbumSocialEmbed.js
+++ b/src/content/dependencies/generateAlbumSocialEmbed.js
@@ -6,7 +6,7 @@ export default {
     'generateAlbumSocialEmbedDescription',
   ],
 
-  extraDependencies: ['absoluteTo', 'language', 'urls'],
+  extraDependencies: ['absoluteTo', 'language'],
 
   relations(relation, album) {
     return {
@@ -41,7 +41,7 @@ export default {
     return data;
   },
 
-  generate: (data, relations, {absoluteTo, language, urls}) =>
+  generate: (data, relations, {absoluteTo, language}) =>
     language.encapsulate('albumPage.socialEmbed', embedCapsule =>
       relations.socialEmbed.slots({
         title:
@@ -65,10 +65,7 @@ export default {
 
         imagePath:
           (data.hasImage
-            ? '/' +
-              urls
-                .from('shared.root')
-                .to('media.albumCover', data.coverArtDirectory, data.coverArtFileExtension)
+            ? ['media.albumCover', data.coverArtDirectory, data.coverArtFileExtension]
             : null),
       })),
 };
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,
             ]),
 
diff --git a/src/content/dependencies/generateSocialEmbed.js b/src/content/dependencies/generateSocialEmbed.js
index 85a0f4d3..513ea518 100644
--- a/src/content/dependencies/generateSocialEmbed.js
+++ b/src/content/dependencies/generateSocialEmbed.js
@@ -1,5 +1,5 @@
 export default {
-  extraDependencies: ['html', 'language', 'wikiData'],
+  extraDependencies: ['absoluteTo', 'html', 'language', 'wikiData'],
 
   sprawl({wikiInfo}) {
     return {
@@ -23,10 +23,10 @@ export default {
 
     headingContent: {type: 'string'},
     headingLink: {type: 'string'},
-    imagePath: {type: 'string'},
+    imagePath: {validate: v => v.strictArrayOf(v.isString)},
   },
 
-  generate(data, slots, {html, language}) {
+  generate(data, slots, {absoluteTo, html, language}) {
     switch (slots.mode) {
       case 'html':
         return html.tags([
@@ -40,7 +40,10 @@ export default {
             }),
 
           slots.imagePath &&
-            html.tag('meta', {property: 'og:image', content: slots.imagePath}),
+            html.tag('meta', {
+              property: 'og:image',
+              content: absoluteTo(...slots.imagePath),
+            }),
         ]);
 
       case 'json':
diff --git a/src/content/dependencies/generateTrackSocialEmbed.js b/src/content/dependencies/generateTrackSocialEmbed.js
index d8e21e38..7cb37af2 100644
--- a/src/content/dependencies/generateTrackSocialEmbed.js
+++ b/src/content/dependencies/generateTrackSocialEmbed.js
@@ -4,7 +4,7 @@ export default {
     'generateTrackSocialEmbedDescription',
   ],
 
-  extraDependencies: ['absoluteTo', 'language', 'urls'],
+  extraDependencies: ['absoluteTo', 'language'],
 
   relations(relation, track) {
     return {
@@ -39,7 +39,7 @@ export default {
     return data;
   },
 
-  generate: (data, relations, {absoluteTo, language, urls}) =>
+  generate: (data, relations, {absoluteTo, language}) =>
     language.encapsulate('trackPage.socialEmbed', embedCapsule =>
       relations.socialEmbed.slots({
         title:
@@ -60,15 +60,9 @@ export default {
 
         imagePath:
           (data.imageSource === 'album'
-            ? '/' +
-              urls
-                .from('shared.root')
-                .to('media.albumCover', data.albumDirectory, data.coverArtFileExtension)
+            ? ['media.albumCover', data.albumDirectory, data.coverArtFileExtension]
          : data.imageSource === 'track'
-            ? '/' +
-              urls
-                .from('shared.root')
-                .to('media.trackCover', data.albumDirectory, data.trackDirectory, data.coverArtFileExtension)
+            ? ['media.trackCover', data.albumDirectory, data.trackDirectory, data.coverArtFileExtension]
             : null),
       })),
 };