refactor createAssetCanonicalLink and usages
This commit is contained in:
parent
1833c326a4
commit
458441600d
6 changed files with 8 additions and 13 deletions
|
@ -4,7 +4,7 @@ import createCanonicalLink from '../../../../utils/createCanonicalLink';
|
||||||
|
|
||||||
const AssetPreview = ({ defaultThumbnail, claimData }) => {
|
const AssetPreview = ({ defaultThumbnail, claimData }) => {
|
||||||
const { name, fileExt, contentType, thumbnail, title } = claimData;
|
const { name, fileExt, contentType, thumbnail, title } = claimData;
|
||||||
const showUrl = createCanonicalLink({ asset: { claimData } });
|
const showUrl = createCanonicalLink({ asset: { ...claimData }});
|
||||||
const embedUrl = `${showUrl}.${fileExt}`;
|
const embedUrl = `${showUrl}.${fileExt}`;
|
||||||
return (
|
return (
|
||||||
<Link to={showUrl} className='asset-preview'>
|
<Link to={showUrl} className='asset-preview'>
|
||||||
|
|
|
@ -16,7 +16,7 @@ class AssetInfo extends React.Component {
|
||||||
const { asset } = this.props;
|
const { asset } = this.props;
|
||||||
const { claimViews, claimData: { channelName, channelShortId, description, name, fileExt, contentType, thumbnail, host } } = asset;
|
const { claimViews, claimData: { channelName, channelShortId, description, name, fileExt, contentType, thumbnail, host } } = asset;
|
||||||
|
|
||||||
const assetCanonicalUrl = `${host}${createCanonicalLink({asset})}`;
|
const assetCanonicalUrl = `${host}${createCanonicalLink({ asset: { ...asset.claimData, shortId: asset.shortId }})}`;
|
||||||
|
|
||||||
let channelCanonicalUrl;
|
let channelCanonicalUrl;
|
||||||
if (channelName) {
|
if (channelName) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ class SEO extends React.Component {
|
||||||
channel,
|
channel,
|
||||||
});
|
});
|
||||||
const canonicalLink = `${host}${createCanonicalLink({
|
const canonicalLink = `${host}${createCanonicalLink({
|
||||||
asset,
|
asset: asset ? { ...asset.claimData, shortId: asset.shortId } : undefined,
|
||||||
channel,
|
channel,
|
||||||
page: pageUri,
|
page: pageUri,
|
||||||
})}`;
|
})}`;
|
||||||
|
|
|
@ -38,7 +38,7 @@ const determineMediaType = (contentType) => {
|
||||||
const createAssetMetaTags = (asset) => {
|
const createAssetMetaTags = (asset) => {
|
||||||
const { claimData } = asset;
|
const { claimData } = asset;
|
||||||
const { contentType } = claimData;
|
const { contentType } = claimData;
|
||||||
const canonicalLink = createCanonicalLink({asset});
|
const canonicalLink = createCanonicalLink({ asset: { ...asset.claimData, shortId: asset.shortId }});
|
||||||
const showUrl = `${host}${canonicalLink}`;
|
const showUrl = `${host}${canonicalLink}`;
|
||||||
const serveUrl = `${showUrl}.${claimData.fileExt}`;
|
const serveUrl = `${showUrl}.${claimData.fileExt}`;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ const getCanonicalUrlFromShow = show => {
|
||||||
const requestType = show.request.type;
|
const requestType = show.request.type;
|
||||||
switch (requestType) {
|
switch (requestType) {
|
||||||
case 'ASSET_DETAILS':
|
case 'ASSET_DETAILS':
|
||||||
return createCanonicalLink({ asset: show.assetList[requestId.key] });
|
const asset = show.assetList[requestId.key];
|
||||||
|
return createCanonicalLink({ asset: { ...asset.claimData, shortId: asset.shortId }});
|
||||||
case 'CHANNEL':
|
case 'CHANNEL':
|
||||||
return createCanonicalLink({ channel: show.channelList[requestId.key] });
|
return createCanonicalLink({ channel: show.channelList[requestId.key] });
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -3,14 +3,8 @@ const createBasicCanonicalLink = (page) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const createAssetCanonicalLink = (asset) => {
|
const createAssetCanonicalLink = (asset) => {
|
||||||
let channelName, channelShortId, name, claimId;
|
const { channelName, channelShortId, name, claimId, shortId } = asset;
|
||||||
if (asset.claimData) {
|
return channelName ? `/${channelName}:${channelShortId}/${name}` : `/${shortId || claimId}/${name}`;
|
||||||
({ channelName, channelShortId, name, claimId } = asset.claimData);
|
|
||||||
}
|
|
||||||
if (channelName) {
|
|
||||||
return `/${channelName}:${channelShortId}/${name}`;
|
|
||||||
}
|
|
||||||
return `/${asset.shortId || claimId}/${name}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createChannelCanonicalLink = (channel) => {
|
const createChannelCanonicalLink = (channel) => {
|
||||||
|
|
Loading…
Reference in a new issue