« get me outta code hell

content: generatePageLayout: fix missing json+oembed link - 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>2024-09-11 20:24:52 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-09-11 20:24:52 -0300
commit899d837193c169e59dfb8503a00493bdbc4d460e (patch)
tree52856213d845d7164d3b6917fc6dc0aa71824802
parentdd841e85e0f2cbd6b4a57fb9741111ed7c88df9f (diff)
content: generatePageLayout: fix missing json+oembed link
-rw-r--r--src/content/dependencies/generatePageLayout.js41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js
index 4e4df5ec..67a44b2b 100644
--- a/src/content/dependencies/generatePageLayout.js
+++ b/src/content/dependencies/generatePageLayout.js
@@ -16,25 +16,24 @@ export default {
     'html',
     'language',
     'pagePath',
+    'pagePathStringFromRoot',
     'to',
     'wikiData',
   ],
 
-  sprawl({wikiInfo}) {
-    return {
-      enableSearch: wikiInfo.enableSearch,
-      footerContent: wikiInfo.footerContent,
-      wikiColor: wikiInfo.color,
-      wikiName: wikiInfo.nameShort,
-    };
-  },
+  sprawl: ({wikiInfo}) => ({
+    enableSearch: wikiInfo.enableSearch,
+    footerContent: wikiInfo.footerContent,
+    wikiColor: wikiInfo.color,
+    wikiName: wikiInfo.nameShort,
+    canonicalBase: wikiInfo.canonicalBase,
+  }),
 
-  data({wikiColor, wikiName}) {
-    return {
-      wikiColor,
-      wikiName,
-    };
-  },
+  data: (sprawl) => ({
+    wikiColor: sprawl.wikiColor,
+    wikiName: sprawl.wikiName,
+    canonicalBase: sprawl.canonicalBase,
+  }),
 
   relations(relation, sprawl) {
     const relations = {};
@@ -228,6 +227,7 @@ export default {
     html,
     language,
     pagePath,
+    pagePathStringFromRoot,
     to,
   }) {
     const colors = getColors(slots.color ?? data.wikiColor);
@@ -241,6 +241,13 @@ export default {
     const mainContentHTML = html.tags([slots.mainContent]).toString();
     const hasID = id => mainContentHTML.includes(`id="${id}"`);
 
+    const oEmbedJSONHref =
+      (hasSocialEmbed && data.canonicalBase
+        ? data.canonicalBase +
+          pagePathStringFromRoot +
+          'oembed.json'
+        : null);
+
     const titleContentsHTML =
       (html.isBlank(slots.title)
         ? null
@@ -649,6 +656,12 @@ export default {
                 .clone()
                 .slot('mode', 'html'),
 
+            oEmbedJSONHref &&
+              html.tag('link', {
+                type: 'application/json+oembed',
+                href: oEmbedJSONHref,
+              }),
+
             html.tag('link', {
               rel: 'stylesheet',
               href: to('staticCSS.path', 'site.css'),