From 899d837193c169e59dfb8503a00493bdbc4d460e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 11 Sep 2024 20:24:52 -0300 Subject: content: generatePageLayout: fix missing json+oembed link --- src/content/dependencies/generatePageLayout.js | 41 +++++++++++++++++--------- 1 file 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'), -- cgit 1.3.0-6-gf8a5