digitransit-ui/app/meta.js
Joona Olkkola dcaa78239f Added a manifest for the IndexPage component.
Removed global manifest generation.
2018-11-29 17:08:47 +02:00

118 lines
2.7 KiB
JavaScript

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;
}