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 _createMetaTagsArray = _interopRequireDefault(require("./createMetaTagsArray"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _siteConfig$details = _siteConfig.default.details,
|
||||
|
@ -44,148 +46,59 @@ var determineMediaType = function determineMediaType(contentType) {
|
|||
var createAssetMetaTags = function createAssetMetaTags(asset) {
|
||||
var claimData = asset.claimData;
|
||||
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 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 ogDescription = claimData.description || defaultDescription;
|
||||
var ogThumbnailContentType = (0, _determineContentTypeFromExtension.default)(claimData.thumbnail);
|
||||
var ogThumbnail = claimData.thumbnail || defaultThumbnail;
|
||||
var metaTags = [// page details
|
||||
{
|
||||
property: 'og:title',
|
||||
content: ogTitle
|
||||
}, {
|
||||
property: 'twitter:title',
|
||||
content: ogTitle
|
||||
}, {
|
||||
property: 'og:description',
|
||||
content: ogDescription
|
||||
}, {
|
||||
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'
|
||||
}];
|
||||
var ogThumbnail = claimData.thumbnail || defaultThumbnail; // {property: 'og:title'] = ogTitle},
|
||||
|
||||
var metaTags = {
|
||||
'og:title': ogTitle,
|
||||
'twitter:title': ogTitle,
|
||||
'og:description': ogDescription,
|
||||
'twitter:description': ogDescription,
|
||||
'og:url': showUrl,
|
||||
'og:site_name': siteTitle,
|
||||
'twitter:site': twitter,
|
||||
'fb:app_id': '1371961932852223'
|
||||
};
|
||||
|
||||
if (determineMediaType(contentType) === VIDEO) {
|
||||
// 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
|
||||
var videoEmbedUrl = "".concat(host, "/video-embed/").concat(claimData.name, "/").concat(claimData.claimId); // card type tags
|
||||
|
||||
metaTags.push({
|
||||
property: 'og:video',
|
||||
content: source
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'og:video:secure_url',
|
||||
content: source
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'og:video:type',
|
||||
content: contentType
|
||||
}); // image tags
|
||||
metaTags['og:type'] = 'video.other';
|
||||
metaTags['twitter:card'] = 'player';
|
||||
metaTags['twitter:player'] = videoEmbedUrl;
|
||||
metaTags['twitter:player:width'] = 600;
|
||||
metaTags['twitter:text:player_width'] = 600;
|
||||
metaTags['twitter:player:height'] = 350;
|
||||
metaTags['twitter:player:stream'] = serveUrl;
|
||||
metaTags['twitter:player:stream:content_type'] = contentType; // video tags
|
||||
|
||||
metaTags.push({
|
||||
property: 'og:image',
|
||||
content: ogThumbnail
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'og:image:width',
|
||||
content: 600
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'og:image:height',
|
||||
content: 315
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'og:image:type',
|
||||
content: ogThumbnailContentType
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'twitter:image',
|
||||
content: ogThumbnail
|
||||
});
|
||||
metaTags['og:video'] = serveUrl;
|
||||
metaTags['og:video:secure_url'] = serveUrl;
|
||||
metaTags['og:video:type'] = contentType; // image tags
|
||||
|
||||
metaTags['og:image'] = ogThumbnail;
|
||||
metaTags['og:image:width'] = 600;
|
||||
metaTags['og:image:height'] = 315;
|
||||
metaTags['og:image:type'] = ogThumbnailContentType;
|
||||
metaTags['twitter:image'] = ogThumbnail;
|
||||
} else {
|
||||
// card type tags
|
||||
metaTags.push({
|
||||
property: 'og:type',
|
||||
content: 'article'
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'twitter:card',
|
||||
content: 'summary_large_image'
|
||||
}); // image tags
|
||||
metaTags['og:type'] = 'article';
|
||||
metaTags['twitter:card'] = 'summary_large_image'; // image tags
|
||||
|
||||
metaTags.push({
|
||||
property: 'og:image',
|
||||
content: source
|
||||
});
|
||||
metaTags.push({
|
||||
property: 'og:image',
|
||||
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
|
||||
});
|
||||
metaTags['og:image'] = serveUrl;
|
||||
metaTags['og:image'] = serveUrl;
|
||||
metaTags['og:image:width'] = 600;
|
||||
metaTags['og:image:height'] = 315;
|
||||
metaTags['og:image:type'] = contentType;
|
||||
metaTags['twitter:image'] = serveUrl;
|
||||
}
|
||||
|
||||
return metaTags;
|
||||
return (0, _createMetaTagsArray.default)(metaTags);
|
||||
};
|
||||
|
||||
var _default = createAssetMetaTags;
|
||||
|
|
|
@ -9,6 +9,8 @@ var _siteConfig = _interopRequireDefault(require("@config/siteConfig.json"));
|
|||
|
||||
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension.js"));
|
||||
|
||||
var _createMetaTagsArray = _interopRequireDefault(require("./createMetaTagsArray"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _siteConfig$details = _siteConfig.default.details,
|
||||
|
@ -19,60 +21,30 @@ var _siteConfig$details = _siteConfig.default.details,
|
|||
thumbnail = _siteConfig.default.assetDefaults.thumbnail;
|
||||
|
||||
var createBasicMetaTags = function createBasicMetaTags() {
|
||||
return [// page details
|
||||
{
|
||||
property: 'og:title',
|
||||
content: title
|
||||
}, {
|
||||
property: 'twitter:title',
|
||||
content: title
|
||||
}, {
|
||||
property: 'og:description',
|
||||
content: description
|
||||
}, {
|
||||
property: 'twitter:description',
|
||||
content: description
|
||||
}, // url
|
||||
{
|
||||
property: 'og:url',
|
||||
content: host
|
||||
}, // site id
|
||||
{
|
||||
property: 'og:site_name',
|
||||
content: title
|
||||
}, {
|
||||
property: 'twitter:site',
|
||||
content: twitter
|
||||
}, {
|
||||
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 metaTags = {
|
||||
// page details
|
||||
'og:title': title,
|
||||
'twitter:title': title,
|
||||
'og:description': description,
|
||||
'twitter:description': description,
|
||||
// url
|
||||
'og:url': host,
|
||||
// site id
|
||||
'og:site_name': title,
|
||||
'twitter:site': twitter,
|
||||
'fb:app_id': '1371961932852223',
|
||||
// card type
|
||||
'og:type': 'article',
|
||||
'twitter:card': 'summary_large_image',
|
||||
// image
|
||||
'og:image': thumbnail,
|
||||
'og:image:width': 600,
|
||||
'og:image:height': 315,
|
||||
'og:image:type': (0, _determineContentTypeFromExtension.default)(thumbnail),
|
||||
'twitter:image': thumbnail,
|
||||
'twitter:image:alt': 'Spee.ch Logo'
|
||||
};
|
||||
return (0, _createMetaTagsArray.default)(metaTags);
|
||||
};
|
||||
|
||||
var _default = createBasicMetaTags;
|
||||
|
|
|
@ -9,6 +9,8 @@ var _siteConfig = _interopRequireDefault(require("@config/siteConfig.json"));
|
|||
|
||||
var _determineContentTypeFromExtension = _interopRequireDefault(require("./determineContentTypeFromExtension"));
|
||||
|
||||
var _createMetaTagsArray = _interopRequireDefault(require("./createMetaTagsArray"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _siteConfig$details = _siteConfig.default.details,
|
||||
|
@ -20,60 +22,30 @@ var _siteConfig$details = _siteConfig.default.details,
|
|||
var createChannelMetaTags = function createChannelMetaTags(channel) {
|
||||
var name = channel.name,
|
||||
longId = channel.longId;
|
||||
return [// page detail tags
|
||||
{
|
||||
property: 'og:title',
|
||||
content: "".concat(name, " on ").concat(siteTitle)
|
||||
}, {
|
||||
property: 'twitter:title',
|
||||
content: "".concat(name, " on ").concat(siteTitle)
|
||||
}, {
|
||||
property: 'og:description',
|
||||
content: "".concat(name, ", a channel on ").concat(siteTitle)
|
||||
}, {
|
||||
property: 'twitter:description',
|
||||
content: "".concat(name, ", a channel on ").concat(siteTitle)
|
||||
}, // url
|
||||
{
|
||||
property: 'og:url',
|
||||
content: "".concat(host, "/").concat(name, ":").concat(longId)
|
||||
}, // site info
|
||||
{
|
||||
property: 'og:site_name',
|
||||
content: siteTitle
|
||||
}, {
|
||||
property: 'twitter:site',
|
||||
content: twitter
|
||||
}, {
|
||||
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'
|
||||
}];
|
||||
var metaTags = {
|
||||
// page detail tags
|
||||
'og:title': "".concat(name, " on ").concat(siteTitle),
|
||||
'twitter:title': "".concat(name, " on ").concat(siteTitle),
|
||||
'og:description': "".concat(name, ", a channel on ").concat(siteTitle),
|
||||
'twitter:description': "".concat(name, ", a channel on ").concat(siteTitle),
|
||||
// url
|
||||
'og:url': "".concat(host, "/").concat(name, ":").concat(longId),
|
||||
// site info
|
||||
'og:site_name': siteTitle,
|
||||
'twitter:site': twitter,
|
||||
'fb:app_id': '1371961932852223',
|
||||
// card type tags
|
||||
'og:type': 'article',
|
||||
'twitter:card': 'summary_large_image',
|
||||
// image tags
|
||||
'og:image': defaultThumbnail,
|
||||
'og:image:width': 600,
|
||||
'og:image:height': 315,
|
||||
'og:image:type': (0, _determineContentTypeFromExtension.default)(defaultThumbnail),
|
||||
'twitter:image': defaultThumbnail,
|
||||
'twitter:image:alt': 'Spee.ch Logo'
|
||||
};
|
||||
return (0, _createMetaTagsArray.default)(metaTags);
|
||||
};
|
||||
|
||||
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 determineContentTypeFromExtension from './determineContentTypeFromExtension';
|
||||
import createMetaTagsArray from './createMetaTagsArray';
|
||||
|
||||
const {
|
||||
details: {
|
||||
|
@ -36,59 +37,57 @@ const determineMediaType = (contentType) => {
|
|||
const createAssetMetaTags = (asset) => {
|
||||
const { claimData } = asset;
|
||||
const { contentType } = claimData;
|
||||
const videoEmbedUrl = `${host}/video-embed/${claimData.name}/${claimData.claimId}`;
|
||||
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 ogDescription = claimData.description || defaultDescription;
|
||||
const ogThumbnailContentType = determineContentTypeFromExtension(claimData.thumbnail);
|
||||
const ogThumbnail = claimData.thumbnail || defaultThumbnail;
|
||||
const metaTags = [
|
||||
// page details
|
||||
{property: 'og:title', content: ogTitle},
|
||||
{property: 'twitter:title', content: ogTitle},
|
||||
{property: 'og:description', content: ogDescription},
|
||||
{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'},
|
||||
];
|
||||
// {property: 'og:title'] = ogTitle},
|
||||
const metaTags = {
|
||||
'og:title' : ogTitle,
|
||||
'twitter:title' : ogTitle,
|
||||
'og:description' : ogDescription,
|
||||
'twitter:description': ogDescription,
|
||||
'og:url' : showUrl,
|
||||
'og:site_name' : siteTitle,
|
||||
'twitter:site' : twitter,
|
||||
'fb:app_id' : '1371961932852223',
|
||||
};
|
||||
if (determineMediaType(contentType) === VIDEO) {
|
||||
const videoEmbedUrl = `${host}/video-embed/${claimData.name}/${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});
|
||||
metaTags['og:type'] = 'video.other';
|
||||
metaTags['twitter:card'] = 'player';
|
||||
metaTags['twitter:player'] = videoEmbedUrl;
|
||||
metaTags['twitter:player:width'] = 600;
|
||||
metaTags['twitter:text:player_width'] = 600;
|
||||
metaTags['twitter:player:height'] = 350;
|
||||
metaTags['twitter:player:stream'] = serveUrl;
|
||||
metaTags['twitter:player:stream:content_type'] = contentType;
|
||||
// video tags
|
||||
metaTags.push({property: 'og:video', content: source});
|
||||
metaTags.push({property: 'og:video:secure_url', content: source});
|
||||
metaTags.push({property: 'og:video:type', content: contentType});
|
||||
metaTags['og:video'] = serveUrl;
|
||||
metaTags['og:video:secure_url'] = serveUrl;
|
||||
metaTags['og:video:type'] = contentType;
|
||||
// image tags
|
||||
metaTags.push({property: 'og:image', content: ogThumbnail});
|
||||
metaTags.push({property: 'og:image:width', content: 600});
|
||||
metaTags.push({property: 'og:image:height', content: 315});
|
||||
metaTags.push({property: 'og:image:type', content: ogThumbnailContentType});
|
||||
metaTags.push({property: 'twitter:image', content: ogThumbnail});
|
||||
metaTags['og:image'] = ogThumbnail;
|
||||
metaTags['og:image:width'] = 600;
|
||||
metaTags['og:image:height'] = 315;
|
||||
metaTags['og:image:type'] = ogThumbnailContentType;
|
||||
metaTags['twitter:image'] = ogThumbnail;
|
||||
} else {
|
||||
// card type tags
|
||||
metaTags.push({property: 'og:type', content: 'article'});
|
||||
metaTags.push({property: 'twitter:card', content: 'summary_large_image'});
|
||||
metaTags['og:type'] = 'article';
|
||||
metaTags['twitter:card'] = 'summary_large_image';
|
||||
// image tags
|
||||
metaTags.push({property: 'og:image', content: source});
|
||||
metaTags.push({property: 'og:image', 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});
|
||||
metaTags['og:image'] = serveUrl;
|
||||
metaTags['og:image'] = serveUrl;
|
||||
metaTags['og:image:width'] = 600;
|
||||
metaTags['og:image:height'] = 315;
|
||||
metaTags['og:image:type'] = contentType;
|
||||
metaTags['twitter:image'] = serveUrl;
|
||||
}
|
||||
return metaTags;
|
||||
return createMetaTagsArray(metaTags);
|
||||
};
|
||||
|
||||
export default createAssetMetaTags;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import siteConfig from '@config/siteConfig.json';
|
||||
import determineContentTypeFromExtension from './determineContentTypeFromExtension.js';
|
||||
import createMetaTagsArray from './createMetaTagsArray';
|
||||
|
||||
const {
|
||||
details: {
|
||||
|
@ -14,29 +15,30 @@ const {
|
|||
} = siteConfig;
|
||||
|
||||
const createBasicMetaTags = () => {
|
||||
return [
|
||||
const metaTags = {
|
||||
// page details
|
||||
{property: 'og:title', content: title},
|
||||
{property: 'twitter:title', content: title},
|
||||
{property: 'og:description', content: description},
|
||||
{property: 'twitter:description', content: description},
|
||||
'og:title' : title,
|
||||
'twitter:title' : title,
|
||||
'og:description' : description,
|
||||
'twitter:description': description,
|
||||
// url
|
||||
{property: 'og:url', content: host},
|
||||
'og:url' : host,
|
||||
// site id
|
||||
{property: 'og:site_name', content: title},
|
||||
{property: 'twitter:site', content: twitter},
|
||||
{property: 'fb:app_id', content: '1371961932852223'},
|
||||
'og:site_name' : title,
|
||||
'twitter:site' : twitter,
|
||||
'fb:app_id' : '1371961932852223',
|
||||
// card type
|
||||
{property: 'og:type', content: 'article'},
|
||||
{property: 'twitter:card', content: 'summary_large_image'},
|
||||
'og:type' : 'article',
|
||||
'twitter:card' : '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: determineContentTypeFromExtension(thumbnail)},
|
||||
{property: 'twitter:image', content: thumbnail},
|
||||
{property: 'twitter:image:alt', content: 'Spee.ch Logo'},
|
||||
];
|
||||
'og:image' : thumbnail,
|
||||
'og:image:width' : 600,
|
||||
'og:image:height' : 315,
|
||||
'og:image:type' : determineContentTypeFromExtension(thumbnail),
|
||||
'twitter:image' : thumbnail,
|
||||
'twitter:image:alt' : 'Spee.ch Logo',
|
||||
};
|
||||
return createMetaTagsArray(metaTags);
|
||||
};
|
||||
|
||||
export default createBasicMetaTags;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import siteConfig from '@config/siteConfig.json';
|
||||
import determineContentTypeFromExtension from './determineContentTypeFromExtension';
|
||||
import createMetaTagsArray from './createMetaTagsArray';
|
||||
|
||||
const {
|
||||
details: {
|
||||
|
@ -14,29 +15,30 @@ const {
|
|||
|
||||
export const createChannelMetaTags = (channel) => {
|
||||
const { name, longId } = channel;
|
||||
return [
|
||||
const metaTags = {
|
||||
// page detail tags
|
||||
{property: 'og:title', content: `${name} on ${siteTitle}`},
|
||||
{property: 'twitter:title', content: `${name} on ${siteTitle}`},
|
||||
{property: 'og:description', content: `${name}, a channel on ${siteTitle}`},
|
||||
{property: 'twitter:description', content: `${name}, a channel on ${siteTitle}`},
|
||||
'og:title' : `${name} on ${siteTitle}`,
|
||||
'twitter:title' : `${name} on ${siteTitle}`,
|
||||
'og:description' : `${name}, a channel on ${siteTitle}`,
|
||||
'twitter:description': `${name}, a channel on ${siteTitle}`,
|
||||
// url
|
||||
{property: 'og:url', content: `${host}/${name}:${longId}`},
|
||||
'og:url' : `${host}/${name}:${longId}`,
|
||||
// site info
|
||||
{property: 'og:site_name', content: siteTitle},
|
||||
{property: 'twitter:site', content: twitter},
|
||||
{property: 'fb:app_id', content: '1371961932852223'},
|
||||
'og:site_name' : siteTitle,
|
||||
'twitter:site' : twitter,
|
||||
'fb:app_id' : '1371961932852223',
|
||||
// card type tags
|
||||
{property: 'og:type', content: 'article'},
|
||||
{property: 'twitter:card', content: 'summary_large_image'},
|
||||
'og:type' : 'article',
|
||||
'twitter:card' : '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: determineContentTypeFromExtension(defaultThumbnail)},
|
||||
{property: 'twitter:image', content: defaultThumbnail},
|
||||
{property: 'twitter:image:alt', content: 'Spee.ch Logo'},
|
||||
];
|
||||
'og:image' : defaultThumbnail,
|
||||
'og:image:width' : 600,
|
||||
'og:image:height' : 315,
|
||||
'og:image:type' : determineContentTypeFromExtension(defaultThumbnail),
|
||||
'twitter:image' : defaultThumbnail,
|
||||
'twitter:image:alt' : 'Spee.ch Logo',
|
||||
};
|
||||
return createMetaTagsArray(metaTags);
|
||||
};
|
||||
|
||||
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