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 { name, fileExt, contentType, thumbnail, title } = claimData;
|
||||
const showUrl = createCanonicalLink({ asset: { claimData } });
|
||||
const showUrl = createCanonicalLink({ asset: { ...claimData }});
|
||||
const embedUrl = `${showUrl}.${fileExt}`;
|
||||
return (
|
||||
<Link to={showUrl} className='asset-preview'>
|
||||
|
|
|
@ -16,7 +16,7 @@ class AssetInfo extends React.Component {
|
|||
const { asset } = this.props;
|
||||
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;
|
||||
if (channelName) {
|
||||
|
|
|
@ -22,7 +22,7 @@ class SEO extends React.Component {
|
|||
channel,
|
||||
});
|
||||
const canonicalLink = `${host}${createCanonicalLink({
|
||||
asset,
|
||||
asset: asset ? { ...asset.claimData, shortId: asset.shortId } : undefined,
|
||||
channel,
|
||||
page: pageUri,
|
||||
})}`;
|
||||
|
|
|
@ -38,7 +38,7 @@ const determineMediaType = (contentType) => {
|
|||
const createAssetMetaTags = (asset) => {
|
||||
const { claimData } = asset;
|
||||
const { contentType } = claimData;
|
||||
const canonicalLink = createCanonicalLink({asset});
|
||||
const canonicalLink = createCanonicalLink({ asset: { ...asset.claimData, shortId: asset.shortId }});
|
||||
const showUrl = `${host}${canonicalLink}`;
|
||||
const serveUrl = `${showUrl}.${claimData.fileExt}`;
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ const getCanonicalUrlFromShow = show => {
|
|||
const requestType = show.request.type;
|
||||
switch (requestType) {
|
||||
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':
|
||||
return createCanonicalLink({ channel: show.channelList[requestId.key] });
|
||||
default:
|
||||
|
|
|
@ -3,14 +3,8 @@ const createBasicCanonicalLink = (page) => {
|
|||
};
|
||||
|
||||
const createAssetCanonicalLink = (asset) => {
|
||||
let channelName, channelShortId, name, claimId;
|
||||
if (asset.claimData) {
|
||||
({ channelName, channelShortId, name, claimId } = asset.claimData);
|
||||
}
|
||||
if (channelName) {
|
||||
return `/${channelName}:${channelShortId}/${name}`;
|
||||
}
|
||||
return `/${asset.shortId || claimId}/${name}`;
|
||||
const { channelName, channelShortId, name, claimId, shortId } = asset;
|
||||
return channelName ? `/${channelName}:${channelShortId}/${name}` : `/${shortId || claimId}/${name}`;
|
||||
};
|
||||
|
||||
const createChannelCanonicalLink = (channel) => {
|
||||
|
|
Loading…
Reference in a new issue