forked from HSLdevcom/digitransit-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeta.js
118 lines (114 loc) · 2.72 KB
/
meta.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
export default function getMetadata(lang, host, url, config) {
const root = config.URL.ASSET_URL || config.APP_PATH;
const path = config.iconPath || 'icons';
const iconPath = `${root}/${path}`;
const imageHost = config.URL.ASSET_URL || `https://${host}`;
const baseData = {
title: config.title,
meta: [
{
'http-equiv': 'x-ua-compatible',
content: 'ie=edge',
},
{
'http-equiv': 'Content-Language',
content: lang,
},
{
name: 'charset',
content: 'utf-8',
},
{
name: 'description',
content: config.meta.description,
},
{
name: 'keywords',
content: config.meta.keywords,
},
{
name: 'viewport',
content:
'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1 user-scalable=no, minimal-ui',
},
{
name: 'referrer',
content: 'origin',
},
{
property: 'og:url',
content: url,
},
{
property: 'og:type',
content: 'website',
},
{
property: 'og:title',
content: config.socialMedia.title,
},
{
property: 'og:site_name',
content: config.socialMedia.title,
},
{
property: 'og:description',
content: config.socialMedia.description,
},
{
property: 'og:image',
content: `${imageHost}${config.socialMedia.image.url}`,
},
{
property: 'og:image:width',
content: config.socialMedia.image.width,
},
{
property: 'og:image:height',
content: config.socialMedia.image.height,
},
{
property: 'og:locale',
content: config.socialMedia.locale,
},
{
property: 'twitter:card',
content: config.socialMedia.twitter.card,
},
{
property: 'twitter:site',
content: config.socialMedia.twitter.site,
},
{
property: 'twitter:creator',
content: config.socialMedia.twitter.site,
},
{
property: 'twitter:title',
content: config.socialMedia.title,
},
{
property: 'twitter:description',
content: config.socialMedia.description,
},
{
property: 'twitter:image',
content: `${imageHost}${config.socialMedia.image.url}`,
},
],
link: [
{
rel: 'yandex-tableaou-widget',
href: `${iconPath}yandex-browser-manifest.json`,
},
],
};
if (config.metaData) {
return {
meta: baseData.meta.concat(config.metaData.meta),
link: baseData.link.concat(config.metaData.link),
title: config.title,
};
}
return baseData;
}