serve static assets on urls with file extension #538
8 changed files with 211 additions and 313 deletions
|
@ -9,6 +9,8 @@ var _siteConfig = _interopRequireDefault(require("@config/siteConfig.json"));
|
||||||
|
|
||||||
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension"));
|
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension"));
|
||||||
|
|
||||||
|
var _createMetaTagsArray = _interopRequireDefault(require("./createMetaTagsArray"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var _siteConfig$details = _siteConfig.default.details,
|
var _siteConfig$details = _siteConfig.default.details,
|
||||||
|
@ -44,148 +46,59 @@ var determineMediaType = function determineMediaType(contentType) {
|
||||||
var createAssetMetaTags = function createAssetMetaTags(asset) {
|
var createAssetMetaTags = function createAssetMetaTags(asset) {
|
||||||
var claimData = asset.claimData;
|
var claimData = asset.claimData;
|
||||||
var contentType = claimData.contentType;
|
var contentType = claimData.contentType;
|
||||||
var videoEmbedUrl = "".concat(host, "/video-embed/").concat(claimData.name, "/").concat(claimData.claimId);
|
|
||||||
var showUrl = "".concat(host, "/").concat(claimData.claimId, "/").concat(claimData.name);
|
var showUrl = "".concat(host, "/").concat(claimData.claimId, "/").concat(claimData.name);
|
||||||
var source = "".concat(host, "/").concat(claimData.claimId, "/").concat(claimData.name, ".").concat(claimData.fileExt);
|
var serveUrl = "".concat(host, "/").concat(claimData.claimId, "/").concat(claimData.name, ".").concat(claimData.fileExt);
|
||||||
var ogTitle = claimData.title || claimData.name;
|
var ogTitle = claimData.title || claimData.name;
|
||||||
var ogDescription = claimData.description || defaultDescription;
|
var ogDescription = claimData.description || defaultDescription;
|
||||||
var ogThumbnailContentType = (0, _determineContentTypeFromExtension.default)(claimData.thumbnail);
|
var ogThumbnailContentType = (0, _determineContentTypeFromExtension.default)(claimData.thumbnail);
|
||||||
var ogThumbnail = claimData.thumbnail || defaultThumbnail;
|
var ogThumbnail = claimData.thumbnail || defaultThumbnail; // {property: 'og:title'] = ogTitle},
|
||||||
var metaTags = [// page details
|
|
||||||
{
|
var metaTags = {
|
||||||
property: 'og:title',
|
'og:title': ogTitle,
|
||||||
content: ogTitle
|
'twitter:title': ogTitle,
|
||||||
}, {
|
'og:description': ogDescription,
|
||||||
property: 'twitter:title',
|
'twitter:description': ogDescription,
|
||||||
content: ogTitle
|
'og:url': showUrl,
|
||||||
}, {
|
'og:site_name': siteTitle,
|
||||||
property: 'og:description',
|
'twitter:site': twitter,
|
||||||
content: ogDescription
|
'fb:app_id': '1371961932852223'
|
||||||
}, {
|
};
|
||||||
property: 'twitter:description',
|
|
||||||
content: ogDescription
|
|
||||||
}, // url
|
|
||||||
{
|
|
||||||
property: 'og:url',
|
|
||||||
content: showUrl
|
|
||||||
}, // site info
|
|
||||||
{
|
|
||||||
property: 'og:site_name',
|
|
||||||
content: siteTitle
|
|
||||||
}, {
|
|
||||||
property: 'twitter:site',
|
|
||||||
content: twitter
|
|
||||||
}, {
|
|
||||||
property: 'fb:app_id',
|
|
||||||
content: '1371961932852223'
|
|
||||||
}];
|
|
||||||
|
|
||||||
if (determineMediaType(contentType) === VIDEO) {
|
if (determineMediaType(contentType) === VIDEO) {
|
||||||
// card type tags
|
var videoEmbedUrl = "".concat(host, "/video-embed/").concat(claimData.name, "/").concat(claimData.claimId); // card type tags
|
||||||
metaTags.push({
|
|
||||||
property: 'og:type',
|
|
||||||
content: 'video.other'
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:card',
|
|
||||||
content: 'player'
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:player',
|
|
||||||
content: videoEmbedUrl
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:player:width',
|
|
||||||
content: 600
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:text:player_width',
|
|
||||||
content: 600
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:player:height',
|
|
||||||
content: 350
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:player:stream',
|
|
||||||
content: source
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:player:stream:content_type',
|
|
||||||
content: contentType
|
|
||||||
}); // video tags
|
|
||||||
|
|
||||||
metaTags.push({
|
metaTags['og:type'] = 'video.other';
|
||||||
property: 'og:video',
|
metaTags['twitter:card'] = 'player';
|
||||||
content: source
|
metaTags['twitter:player'] = videoEmbedUrl;
|
||||||
});
|
metaTags['twitter:player:width'] = 600;
|
||||||
metaTags.push({
|
metaTags['twitter:text:player_width'] = 600;
|
||||||
property: 'og:video:secure_url',
|
metaTags['twitter:player:height'] = 350;
|
||||||
content: source
|
metaTags['twitter:player:stream'] = serveUrl;
|
||||||
});
|
metaTags['twitter:player:stream:content_type'] = contentType; // video tags
|
||||||
metaTags.push({
|
|
||||||
property: 'og:video:type',
|
|
||||||
content: contentType
|
|
||||||
}); // image tags
|
|
||||||
|
|
||||||
metaTags.push({
|
metaTags['og:video'] = serveUrl;
|
||||||
property: 'og:image',
|
metaTags['og:video:secure_url'] = serveUrl;
|
||||||
content: ogThumbnail
|
metaTags['og:video:type'] = contentType; // image tags
|
||||||
});
|
|
||||||
metaTags.push({
|
metaTags['og:image'] = ogThumbnail;
|
||||||
property: 'og:image:width',
|
metaTags['og:image:width'] = 600;
|
||||||
content: 600
|
metaTags['og:image:height'] = 315;
|
||||||
});
|
metaTags['og:image:type'] = ogThumbnailContentType;
|
||||||
metaTags.push({
|
metaTags['twitter:image'] = ogThumbnail;
|
||||||
property: 'og:image:height',
|
|
||||||
content: 315
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'og:image:type',
|
|
||||||
content: ogThumbnailContentType
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:image',
|
|
||||||
content: ogThumbnail
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
// card type tags
|
// card type tags
|
||||||
metaTags.push({
|
metaTags['og:type'] = 'article';
|
||||||
property: 'og:type',
|
metaTags['twitter:card'] = 'summary_large_image'; // image tags
|
||||||
content: 'article'
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:card',
|
|
||||||
content: 'summary_large_image'
|
|
||||||
}); // image tags
|
|
||||||
|
|
||||||
metaTags.push({
|
metaTags['og:image'] = serveUrl;
|
||||||
property: 'og:image',
|
metaTags['og:image'] = serveUrl;
|
||||||
content: source
|
metaTags['og:image:width'] = 600;
|
||||||
});
|
metaTags['og:image:height'] = 315;
|
||||||
metaTags.push({
|
metaTags['og:image:type'] = contentType;
|
||||||
property: 'og:image',
|
metaTags['twitter:image'] = serveUrl;
|
||||||
content: source
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'og:image:width',
|
|
||||||
content: 600
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'og:image:height',
|
|
||||||
content: 315
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'og:image:type',
|
|
||||||
content: contentType
|
|
||||||
});
|
|
||||||
metaTags.push({
|
|
||||||
property: 'twitter:image',
|
|
||||||
content: source
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return metaTags;
|
return (0, _createMetaTagsArray.default)(metaTags);
|
||||||
};
|
};
|
||||||
|
|
||||||
var _default = createAssetMetaTags;
|
var _default = createAssetMetaTags;
|
||||||
|
|
|
@ -9,6 +9,8 @@ var _siteConfig = _interopRequireDefault(require("@config/siteConfig.json"));
|
||||||
|
|
||||||
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension.js"));
|
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension.js"));
|
||||||
|
|
||||||
|
var _createMetaTagsArray = _interopRequireDefault(require("./createMetaTagsArray"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var _siteConfig$details = _siteConfig.default.details,
|
var _siteConfig$details = _siteConfig.default.details,
|
||||||
|
@ -19,60 +21,30 @@ var _siteConfig$details = _siteConfig.default.details,
|
||||||
thumbnail = _siteConfig.default.assetDefaults.thumbnail;
|
thumbnail = _siteConfig.default.assetDefaults.thumbnail;
|
||||||
|
|
||||||
var createBasicMetaTags = function createBasicMetaTags() {
|
var createBasicMetaTags = function createBasicMetaTags() {
|
||||||
return [// page details
|
var metaTags = {
|
||||||
{
|
// page details
|
||||||
property: 'og:title',
|
'og:title': title,
|
||||||
content: title
|
'twitter:title': title,
|
||||||
}, {
|
'og:description': description,
|
||||||
property: 'twitter:title',
|
'twitter:description': description,
|
||||||
content: title
|
// url
|
||||||
}, {
|
'og:url': host,
|
||||||
property: 'og:description',
|
// site id
|
||||||
content: description
|
'og:site_name': title,
|
||||||
}, {
|
'twitter:site': twitter,
|
||||||
property: 'twitter:description',
|
'fb:app_id': '1371961932852223',
|
||||||
content: description
|
// card type
|
||||||
}, // url
|
'og:type': 'article',
|
||||||
{
|
'twitter:card': 'summary_large_image',
|
||||||
property: 'og:url',
|
// image
|
||||||
content: host
|
'og:image': thumbnail,
|
||||||
}, // site id
|
'og:image:width': 600,
|
||||||
{
|
'og:image:height': 315,
|
||||||
property: 'og:site_name',
|
'og:image:type': (0, _determineContentTypeFromExtension.default)(thumbnail),
|
||||||
content: title
|
'twitter:image': thumbnail,
|
||||||
}, {
|
'twitter:image:alt': 'Spee.ch Logo'
|
||||||
property: 'twitter:site',
|
};
|
||||||
content: twitter
|
return (0, _createMetaTagsArray.default)(metaTags);
|
||||||
}, {
|
|
||||||
property: 'fb:app_id',
|
|
||||||
content: '1371961932852223'
|
|
||||||
}, // card type
|
|
||||||
{
|
|
||||||
property: 'og:type',
|
|
||||||
content: 'article'
|
|
||||||
}, {
|
|
||||||
property: 'twitter:card',
|
|
||||||
content: 'summary_large_image'
|
|
||||||
}, // image
|
|
||||||
{
|
|
||||||
property: 'og:image',
|
|
||||||
content: thumbnail
|
|
||||||
}, {
|
|
||||||
property: 'og:image:width',
|
|
||||||
content: 600
|
|
||||||
}, {
|
|
||||||
property: 'og:image:height',
|
|
||||||
content: 315
|
|
||||||
}, {
|
|
||||||
property: 'og:image:type',
|
|
||||||
content: (0, _determineContentTypeFromExtension.default)(thumbnail)
|
|
||||||
}, {
|
|
||||||
property: 'twitter:image',
|
|
||||||
content: thumbnail
|
|
||||||
}, {
|
|
||||||
property: 'twitter:image:alt',
|
|
||||||
content: 'Spee.ch Logo'
|
|
||||||
}];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var _default = createBasicMetaTags;
|
var _default = createBasicMetaTags;
|
||||||
|
|
|
@ -9,6 +9,8 @@ var _siteConfig = _interopRequireDefault(require("@config/siteConfig.json"));
|
||||||
|
|
||||||
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension"));
|
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension"));
|
||||||
|
|
||||||
|
var _createMetaTagsArray = _interopRequireDefault(require("./createMetaTagsArray"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var _siteConfig$details = _siteConfig.default.details,
|
var _siteConfig$details = _siteConfig.default.details,
|
||||||
|
@ -20,60 +22,30 @@ var _siteConfig$details = _siteConfig.default.details,
|
||||||
var createChannelMetaTags = function createChannelMetaTags(channel) {
|
var createChannelMetaTags = function createChannelMetaTags(channel) {
|
||||||
var name = channel.name,
|
var name = channel.name,
|
||||||
longId = channel.longId;
|
longId = channel.longId;
|
||||||
return [// page detail tags
|
var metaTags = {
|
||||||
{
|
// page detail tags
|
||||||
property: 'og:title',
|
'og:title': "".concat(name, " on ").concat(siteTitle),
|
||||||
content: "".concat(name, " on ").concat(siteTitle)
|
'twitter:title': "".concat(name, " on ").concat(siteTitle),
|
||||||
}, {
|
'og:description': "".concat(name, ", a channel on ").concat(siteTitle),
|
||||||
property: 'twitter:title',
|
'twitter:description': "".concat(name, ", a channel on ").concat(siteTitle),
|
||||||
content: "".concat(name, " on ").concat(siteTitle)
|
// url
|
||||||
}, {
|
'og:url': "".concat(host, "/").concat(name, ":").concat(longId),
|
||||||
property: 'og:description',
|
// site info
|
||||||
content: "".concat(name, ", a channel on ").concat(siteTitle)
|
'og:site_name': siteTitle,
|
||||||
}, {
|
'twitter:site': twitter,
|
||||||
property: 'twitter:description',
|
'fb:app_id': '1371961932852223',
|
||||||
content: "".concat(name, ", a channel on ").concat(siteTitle)
|
// card type tags
|
||||||
}, // url
|
'og:type': 'article',
|
||||||
{
|
'twitter:card': 'summary_large_image',
|
||||||
property: 'og:url',
|
// image tags
|
||||||
content: "".concat(host, "/").concat(name, ":").concat(longId)
|
'og:image': defaultThumbnail,
|
||||||
}, // site info
|
'og:image:width': 600,
|
||||||
{
|
'og:image:height': 315,
|
||||||
property: 'og:site_name',
|
'og:image:type': (0, _determineContentTypeFromExtension.default)(defaultThumbnail),
|
||||||
content: siteTitle
|
'twitter:image': defaultThumbnail,
|
||||||
}, {
|
'twitter:image:alt': 'Spee.ch Logo'
|
||||||
property: 'twitter:site',
|
};
|
||||||
content: twitter
|
return (0, _createMetaTagsArray.default)(metaTags);
|
||||||
}, {
|
|
||||||
property: 'fb:app_id',
|
|
||||||
content: '1371961932852223'
|
|
||||||
}, // card type tags
|
|
||||||
{
|
|
||||||
property: 'og:type',
|
|
||||||
content: 'article'
|
|
||||||
}, {
|
|
||||||
property: 'twitter:card',
|
|
||||||
content: 'summary_large_image'
|
|
||||||
}, // image tags
|
|
||||||
{
|
|
||||||
property: 'og:image',
|
|
||||||
content: defaultThumbnail
|
|
||||||
}, {
|
|
||||||
property: 'og:image:width',
|
|
||||||
content: 600
|
|
||||||
}, {
|
|
||||||
property: 'og:image:height',
|
|
||||||
content: 315
|
|
||||||
}, {
|
|
||||||
property: 'og:image:type',
|
|
||||||
content: (0, _determineContentTypeFromExtension.default)(defaultThumbnail)
|
|
||||||
}, {
|
|
||||||
property: 'twitter:image',
|
|
||||||
content: defaultThumbnail
|
|
||||||
}, {
|
|
||||||
property: 'twitter:image:alt',
|
|
||||||
content: 'Spee.ch Logo'
|
|
||||||
}];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.createChannelMetaTags = createChannelMetaTags;
|
exports.createChannelMetaTags = createChannelMetaTags;
|
||||||
|
|
24
client/build/utils/createMetaTagsArray.js
Normal file
24
client/build/utils/createMetaTagsArray.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.default = void 0;
|
||||||
|
|
||||||
|
var createMetaTagsArray = function createMetaTagsArray(metaTagsObject) {
|
||||||
|
var metaTagsArray = [];
|
||||||
|
|
||||||
|
for (var key in metaTagsObject) {
|
||||||
|
if (metaTagsObject.hasOwnProperty(key)) {
|
||||||
|
metaTagsArray.push({
|
||||||
|
property: key,
|
||||||
|
content: metaTagsObject[key]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return metaTagsArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
var _default = createMetaTagsArray;
|
||||||
|
exports.default = _default;
|
|
@ -1,5 +1,6 @@
|
||||||
import siteConfig from '@config/siteConfig.json';
|
import siteConfig from '@config/siteConfig.json';
|
||||||
import determineContentTypeFromExtension from './determineContentTypeFromExtension';
|
import determineContentTypeFromExtension from './determineContentTypeFromExtension';
|
||||||
|
import createMetaTagsArray from './createMetaTagsArray';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
details: {
|
details: {
|
||||||
|
@ -36,59 +37,57 @@ const determineMediaType = (contentType) => {
|
||||||
const createAssetMetaTags = (asset) => {
|
const createAssetMetaTags = (asset) => {
|
||||||
const { claimData } = asset;
|
const { claimData } = asset;
|
||||||
const { contentType } = claimData;
|
const { contentType } = claimData;
|
||||||
const videoEmbedUrl = `${host}/video-embed/${claimData.name}/${claimData.claimId}`;
|
|
||||||
const showUrl = `${host}/${claimData.claimId}/${claimData.name}`;
|
const showUrl = `${host}/${claimData.claimId}/${claimData.name}`;
|
||||||
const source = `${host}/${claimData.claimId}/${claimData.name}.${claimData.fileExt}`;
|
const serveUrl = `${host}/${claimData.claimId}/${claimData.name}.${claimData.fileExt}`;
|
||||||
const ogTitle = claimData.title || claimData.name;
|
const ogTitle = claimData.title || claimData.name;
|
||||||
const ogDescription = claimData.description || defaultDescription;
|
const ogDescription = claimData.description || defaultDescription;
|
||||||
const ogThumbnailContentType = determineContentTypeFromExtension(claimData.thumbnail);
|
const ogThumbnailContentType = determineContentTypeFromExtension(claimData.thumbnail);
|
||||||
const ogThumbnail = claimData.thumbnail || defaultThumbnail;
|
const ogThumbnail = claimData.thumbnail || defaultThumbnail;
|
||||||
const metaTags = [
|
// {property: 'og:title'] = ogTitle},
|
||||||
// page details
|
const metaTags = {
|
||||||
{property: 'og:title', content: ogTitle},
|
'og:title' : ogTitle,
|
||||||
{property: 'twitter:title', content: ogTitle},
|
'twitter:title' : ogTitle,
|
||||||
{property: 'og:description', content: ogDescription},
|
'og:description' : ogDescription,
|
||||||
{property: 'twitter:description', content: ogDescription},
|
'twitter:description': ogDescription,
|
||||||
// url
|
'og:url' : showUrl,
|
||||||
{property: 'og:url', content: showUrl},
|
'og:site_name' : siteTitle,
|
||||||
// site info
|
'twitter:site' : twitter,
|
||||||
{property: 'og:site_name', content: siteTitle},
|
'fb:app_id' : '1371961932852223',
|
||||||
{property: 'twitter:site', content: twitter},
|
};
|
||||||
{property: 'fb:app_id', content: '1371961932852223'},
|
|
||||||
];
|
|
||||||
if (determineMediaType(contentType) === VIDEO) {
|
if (determineMediaType(contentType) === VIDEO) {
|
||||||
|
const videoEmbedUrl = `${host}/video-embed/${claimData.name}/${claimData.claimId}`;
|
||||||
// card type tags
|
// card type tags
|
||||||
metaTags.push({property: 'og:type', content: 'video.other'});
|
metaTags['og:type'] = 'video.other';
|
||||||
metaTags.push({property: 'twitter:card', content: 'player'});
|
metaTags['twitter:card'] = 'player';
|
||||||
metaTags.push({property: 'twitter:player', content: videoEmbedUrl});
|
metaTags['twitter:player'] = videoEmbedUrl;
|
||||||
metaTags.push({property: 'twitter:player:width', content: 600});
|
metaTags['twitter:player:width'] = 600;
|
||||||
metaTags.push({property: 'twitter:text:player_width', content: 600});
|
metaTags['twitter:text:player_width'] = 600;
|
||||||
metaTags.push({property: 'twitter:player:height', content: 350});
|
metaTags['twitter:player:height'] = 350;
|
||||||
metaTags.push({property: 'twitter:player:stream', content: source});
|
metaTags['twitter:player:stream'] = serveUrl;
|
||||||
metaTags.push({property: 'twitter:player:stream:content_type', content: contentType});
|
metaTags['twitter:player:stream:content_type'] = contentType;
|
||||||
// video tags
|
// video tags
|
||||||
metaTags.push({property: 'og:video', content: source});
|
metaTags['og:video'] = serveUrl;
|
||||||
metaTags.push({property: 'og:video:secure_url', content: source});
|
metaTags['og:video:secure_url'] = serveUrl;
|
||||||
metaTags.push({property: 'og:video:type', content: contentType});
|
metaTags['og:video:type'] = contentType;
|
||||||
// image tags
|
// image tags
|
||||||
metaTags.push({property: 'og:image', content: ogThumbnail});
|
metaTags['og:image'] = ogThumbnail;
|
||||||
metaTags.push({property: 'og:image:width', content: 600});
|
metaTags['og:image:width'] = 600;
|
||||||
metaTags.push({property: 'og:image:height', content: 315});
|
metaTags['og:image:height'] = 315;
|
||||||
metaTags.push({property: 'og:image:type', content: ogThumbnailContentType});
|
metaTags['og:image:type'] = ogThumbnailContentType;
|
||||||
metaTags.push({property: 'twitter:image', content: ogThumbnail});
|
metaTags['twitter:image'] = ogThumbnail;
|
||||||
} else {
|
} else {
|
||||||
// card type tags
|
// card type tags
|
||||||
metaTags.push({property: 'og:type', content: 'article'});
|
metaTags['og:type'] = 'article';
|
||||||
metaTags.push({property: 'twitter:card', content: 'summary_large_image'});
|
metaTags['twitter:card'] = 'summary_large_image';
|
||||||
// image tags
|
// image tags
|
||||||
metaTags.push({property: 'og:image', content: source});
|
metaTags['og:image'] = serveUrl;
|
||||||
metaTags.push({property: 'og:image', content: source});
|
metaTags['og:image'] = serveUrl;
|
||||||
metaTags.push({property: 'og:image:width', content: 600});
|
metaTags['og:image:width'] = 600;
|
||||||
metaTags.push({property: 'og:image:height', content: 315});
|
metaTags['og:image:height'] = 315;
|
||||||
metaTags.push({property: 'og:image:type', content: contentType});
|
metaTags['og:image:type'] = contentType;
|
||||||
metaTags.push({property: 'twitter:image', content: source});
|
metaTags['twitter:image'] = serveUrl;
|
||||||
}
|
}
|
||||||
return metaTags;
|
return createMetaTagsArray(metaTags);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createAssetMetaTags;
|
export default createAssetMetaTags;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import siteConfig from '@config/siteConfig.json';
|
import siteConfig from '@config/siteConfig.json';
|
||||||
import determineContentTypeFromExtension from './determineContentTypeFromExtension.js';
|
import determineContentTypeFromExtension from './determineContentTypeFromExtension.js';
|
||||||
|
import createMetaTagsArray from './createMetaTagsArray';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
details: {
|
details: {
|
||||||
|
@ -14,29 +15,30 @@ const {
|
||||||
} = siteConfig;
|
} = siteConfig;
|
||||||
|
|
||||||
const createBasicMetaTags = () => {
|
const createBasicMetaTags = () => {
|
||||||
return [
|
const metaTags = {
|
||||||
// page details
|
// page details
|
||||||
{property: 'og:title', content: title},
|
'og:title' : title,
|
||||||
{property: 'twitter:title', content: title},
|
'twitter:title' : title,
|
||||||
{property: 'og:description', content: description},
|
'og:description' : description,
|
||||||
{property: 'twitter:description', content: description},
|
'twitter:description': description,
|
||||||
// url
|
// url
|
||||||
{property: 'og:url', content: host},
|
'og:url' : host,
|
||||||
// site id
|
// site id
|
||||||
{property: 'og:site_name', content: title},
|
'og:site_name' : title,
|
||||||
{property: 'twitter:site', content: twitter},
|
'twitter:site' : twitter,
|
||||||
{property: 'fb:app_id', content: '1371961932852223'},
|
'fb:app_id' : '1371961932852223',
|
||||||
// card type
|
// card type
|
||||||
{property: 'og:type', content: 'article'},
|
'og:type' : 'article',
|
||||||
{property: 'twitter:card', content: 'summary_large_image'},
|
'twitter:card' : 'summary_large_image',
|
||||||
// image
|
// image
|
||||||
{property: 'og:image', content: thumbnail},
|
'og:image' : thumbnail,
|
||||||
{property: 'og:image:width', content: 600},
|
'og:image:width' : 600,
|
||||||
{property: 'og:image:height', content: 315},
|
'og:image:height' : 315,
|
||||||
{property: 'og:image:type', content: determineContentTypeFromExtension(thumbnail)},
|
'og:image:type' : determineContentTypeFromExtension(thumbnail),
|
||||||
{property: 'twitter:image', content: thumbnail},
|
'twitter:image' : thumbnail,
|
||||||
{property: 'twitter:image:alt', content: 'Spee.ch Logo'},
|
'twitter:image:alt' : 'Spee.ch Logo',
|
||||||
];
|
};
|
||||||
|
return createMetaTagsArray(metaTags);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createBasicMetaTags;
|
export default createBasicMetaTags;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import siteConfig from '@config/siteConfig.json';
|
import siteConfig from '@config/siteConfig.json';
|
||||||
import determineContentTypeFromExtension from './determineContentTypeFromExtension';
|
import determineContentTypeFromExtension from './determineContentTypeFromExtension';
|
||||||
|
import createMetaTagsArray from './createMetaTagsArray';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
details: {
|
details: {
|
||||||
|
@ -14,29 +15,30 @@ const {
|
||||||
|
|
||||||
export const createChannelMetaTags = (channel) => {
|
export const createChannelMetaTags = (channel) => {
|
||||||
const { name, longId } = channel;
|
const { name, longId } = channel;
|
||||||
return [
|
const metaTags = {
|
||||||
// page detail tags
|
// page detail tags
|
||||||
{property: 'og:title', content: `${name} on ${siteTitle}`},
|
'og:title' : `${name} on ${siteTitle}`,
|
||||||
{property: 'twitter:title', content: `${name} on ${siteTitle}`},
|
'twitter:title' : `${name} on ${siteTitle}`,
|
||||||
{property: 'og:description', content: `${name}, a channel on ${siteTitle}`},
|
'og:description' : `${name}, a channel on ${siteTitle}`,
|
||||||
{property: 'twitter:description', content: `${name}, a channel on ${siteTitle}`},
|
'twitter:description': `${name}, a channel on ${siteTitle}`,
|
||||||
// url
|
// url
|
||||||
{property: 'og:url', content: `${host}/${name}:${longId}`},
|
'og:url' : `${host}/${name}:${longId}`,
|
||||||
// site info
|
// site info
|
||||||
{property: 'og:site_name', content: siteTitle},
|
'og:site_name' : siteTitle,
|
||||||
{property: 'twitter:site', content: twitter},
|
'twitter:site' : twitter,
|
||||||
{property: 'fb:app_id', content: '1371961932852223'},
|
'fb:app_id' : '1371961932852223',
|
||||||
// card type tags
|
// card type tags
|
||||||
{property: 'og:type', content: 'article'},
|
'og:type' : 'article',
|
||||||
{property: 'twitter:card', content: 'summary_large_image'},
|
'twitter:card' : 'summary_large_image',
|
||||||
// image tags
|
// image tags
|
||||||
{property: 'og:image', content: defaultThumbnail},
|
'og:image' : defaultThumbnail,
|
||||||
{property: 'og:image:width', content: 600},
|
'og:image:width' : 600,
|
||||||
{property: 'og:image:height', content: 315},
|
'og:image:height' : 315,
|
||||||
{property: 'og:image:type', content: determineContentTypeFromExtension(defaultThumbnail)},
|
'og:image:type' : determineContentTypeFromExtension(defaultThumbnail),
|
||||||
{property: 'twitter:image', content: defaultThumbnail},
|
'twitter:image' : defaultThumbnail,
|
||||||
{property: 'twitter:image:alt', content: 'Spee.ch Logo'},
|
'twitter:image:alt' : 'Spee.ch Logo',
|
||||||
];
|
};
|
||||||
|
return createMetaTagsArray(metaTags);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createChannelMetaTags;
|
export default createChannelMetaTags;
|
||||||
|
|
14
client/src/utils/createMetaTagsArray.js
Normal file
14
client/src/utils/createMetaTagsArray.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
const createMetaTagsArray = (metaTagsObject) => {
|
||||||
|
let metaTagsArray = [];
|
||||||
|
for (let key in metaTagsObject) {
|
||||||
|
if (metaTagsObject.hasOwnProperty(key)) {
|
||||||
|
metaTagsArray.push({
|
||||||
|
property: key,
|
||||||
|
content : metaTagsObject[key],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return metaTagsArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default createMetaTagsArray;
|
Loading…
Reference in a new issue