mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-07-30 19:35:55 +02:00
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
import { generateManifestUrl } from './manifestUtils';
|
|
|
|
/**
|
|
* This helper function generates a manifest and some social media meta tags
|
|
* based on the given parameters.
|
|
*
|
|
* @param {{ title: string, description: string}} props The title and description to apply to the meta data.
|
|
* @param {*} config The configuration for the software installation.
|
|
* @param {{ pathname: string }} location The current location.
|
|
*/
|
|
export const generateMetaData = (
|
|
{ title, description },
|
|
config,
|
|
{ pathname } = {},
|
|
) => ({
|
|
title,
|
|
meta: [
|
|
{
|
|
name: 'description',
|
|
content: description,
|
|
},
|
|
{
|
|
property: 'og:title',
|
|
content: title,
|
|
},
|
|
{
|
|
property: 'og:description',
|
|
content: description,
|
|
},
|
|
{
|
|
property: 'twitter:title',
|
|
content: title,
|
|
},
|
|
{
|
|
property: 'twitter:description',
|
|
content: description,
|
|
},
|
|
],
|
|
...(config && {
|
|
link: [
|
|
{
|
|
rel: 'manifest',
|
|
href: generateManifestUrl(
|
|
config,
|
|
{
|
|
host: window.location.host,
|
|
pathname: pathname || window.location.pathname,
|
|
protocol: window.location.protocol,
|
|
},
|
|
{
|
|
title,
|
|
description,
|
|
},
|
|
),
|
|
},
|
|
],
|
|
}),
|
|
});
|
|
|
|
export default generateMetaData;
|