1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
export default {
extraDependencies: ['html', 'language', 'wikiData'],
sprawl({wikiInfo}) {
return {
canonicalBase: wikiInfo.canonicalBase,
shortWikiName: wikiInfo.nameShort,
};
},
data(sprawl) {
return {
canonicalBase: sprawl.canonicalBase,
shortWikiName: sprawl.shortWikiName,
};
},
slots: {
mode: {validate: v => v.is('html', 'json')},
title: {type: 'string'},
description: {type: 'string'},
headingContent: {type: 'string'},
headingLink: {type: 'string'},
imagePath: {type: 'string'},
},
generate(data, slots, {html, language}) {
switch (slots.mode) {
case 'html':
return html.tags([
slots.title &&
html.tag('meta', {property: 'og:title', content: slots.title}),
slots.description &&
html.tag('meta', {
property: 'og:description',
content: slots.description,
}),
slots.imagePath &&
html.tag('meta', {property: 'og:image', content: slots.imagePath}),
]);
case 'json':
return JSON.stringify({
author_name:
(slots.headingContent
? html.resolve(
language.$('misc.socialEmbed.heading', {
wikiName: data.shortWikiName,
heading: slots.headingContent,
}),
{normalize: 'string'})
: undefined),
author_url:
(slots.headingLink && data.canonicalBase
? data.canonicalBase.replace(/\/$/, '') +
'/' +
slots.headingLink.replace(/^\//, '')
: undefined),
});
}
},
};
|