Skip to content

Commit 899d837

Browse files
committed
content: generatePageLayout: fix missing json+oembed link
1 parent dd841e8 commit 899d837

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/content/dependencies/generatePageLayout.js

+27-14
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ export default {
1616
'html',
1717
'language',
1818
'pagePath',
19+
'pagePathStringFromRoot',
1920
'to',
2021
'wikiData',
2122
],
2223

23-
sprawl({wikiInfo}) {
24-
return {
25-
enableSearch: wikiInfo.enableSearch,
26-
footerContent: wikiInfo.footerContent,
27-
wikiColor: wikiInfo.color,
28-
wikiName: wikiInfo.nameShort,
29-
};
30-
},
24+
sprawl: ({wikiInfo}) => ({
25+
enableSearch: wikiInfo.enableSearch,
26+
footerContent: wikiInfo.footerContent,
27+
wikiColor: wikiInfo.color,
28+
wikiName: wikiInfo.nameShort,
29+
canonicalBase: wikiInfo.canonicalBase,
30+
}),
3131

32-
data({wikiColor, wikiName}) {
33-
return {
34-
wikiColor,
35-
wikiName,
36-
};
37-
},
32+
data: (sprawl) => ({
33+
wikiColor: sprawl.wikiColor,
34+
wikiName: sprawl.wikiName,
35+
canonicalBase: sprawl.canonicalBase,
36+
}),
3837

3938
relations(relation, sprawl) {
4039
const relations = {};
@@ -228,6 +227,7 @@ export default {
228227
html,
229228
language,
230229
pagePath,
230+
pagePathStringFromRoot,
231231
to,
232232
}) {
233233
const colors = getColors(slots.color ?? data.wikiColor);
@@ -241,6 +241,13 @@ export default {
241241
const mainContentHTML = html.tags([slots.mainContent]).toString();
242242
const hasID = id => mainContentHTML.includes(`id="${id}"`);
243243

244+
const oEmbedJSONHref =
245+
(hasSocialEmbed && data.canonicalBase
246+
? data.canonicalBase +
247+
pagePathStringFromRoot +
248+
'oembed.json'
249+
: null);
250+
244251
const titleContentsHTML =
245252
(html.isBlank(slots.title)
246253
? null
@@ -649,6 +656,12 @@ export default {
649656
.clone()
650657
.slot('mode', 'html'),
651658

659+
oEmbedJSONHref &&
660+
html.tag('link', {
661+
type: 'application/json+oembed',
662+
href: oEmbedJSONHref,
663+
}),
664+
652665
html.tag('link', {
653666
rel: 'stylesheet',
654667
href: to('staticCSS.path', 'site.css'),

0 commit comments

Comments
 (0)