« get me outta code hell

content: genreateSocialEmbed: use absoluteTo - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-01-26 18:49:25 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-26 18:49:25 -0400
commit270a6d0dc04198f9135be4955fd124720ab536bb (patch)
treea6faf8015f1c8dfa6af2a501135c3db7b0381e01
parent689d49f28a258a985e2ce7ec9c2d3a876a0845d0 (diff)
content: genreateSocialEmbed: use absoluteTo
-rw-r--r--src/content/dependencies/generateSocialEmbed.js20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/content/dependencies/generateSocialEmbed.js b/src/content/dependencies/generateSocialEmbed.js
index 115dc262..513ea518 100644
--- a/src/content/dependencies/generateSocialEmbed.js
+++ b/src/content/dependencies/generateSocialEmbed.js
@@ -1,7 +1,5 @@
-import {getOrigin} from '#urls';
-
 export default {
-  extraDependencies: ['html', 'language', 'urls', 'wikiData'],
+  extraDependencies: ['absoluteTo', 'html', 'language', 'wikiData'],
 
   sprawl({wikiInfo}) {
     return {
@@ -28,7 +26,7 @@ export default {
     imagePath: {validate: v => v.strictArrayOf(v.isString)},
   },
 
-  generate(data, slots, {html, language, urls}) {
+  generate(data, slots, {absoluteTo, html, language}) {
     switch (slots.mode) {
       case 'html':
         return html.tags([
@@ -44,19 +42,7 @@ export default {
           slots.imagePath &&
             html.tag('meta', {
               property: 'og:image',
-              content:
-                (() => {
-                  const toResult =
-                    urls
-                      .from('shared.root')
-                      .to(...slots.imagePath);
-
-                  if (getOrigin(toResult)) {
-                    return toResult;
-                  } else {
-                    return '/' + toResult;
-                  }
-                })(),
+              content: absoluteTo(...slots.imagePath),
             }),
         ]);