diff --git a/client/src/components/AssetPreview/index.jsx b/client/src/components/AssetPreview/index.jsx index 87a01166..6bfd5e68 100644 --- a/client/src/components/AssetPreview/index.jsx +++ b/client/src/components/AssetPreview/index.jsx @@ -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 ( diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index d7f2ca22..c4bc14df 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -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) { diff --git a/client/src/containers/SEO/view.jsx b/client/src/containers/SEO/view.jsx index 057e5d9b..989dacc3 100644 --- a/client/src/containers/SEO/view.jsx +++ b/client/src/containers/SEO/view.jsx @@ -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, })}`; diff --git a/client/src/utils/createAssetMetaTags.js b/client/src/utils/createAssetMetaTags.js index 3e0f49eb..980a0df4 100644 --- a/client/src/utils/createAssetMetaTags.js +++ b/client/src/utils/createAssetMetaTags.js @@ -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}`; diff --git a/server/render/src/handleShowRender.jsx b/server/render/src/handleShowRender.jsx index f8445283..a0640ffa 100644 --- a/server/render/src/handleShowRender.jsx +++ b/server/render/src/handleShowRender.jsx @@ -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: diff --git a/utils/createCanonicalLink.js b/utils/createCanonicalLink.js index fec9a2e5..210bcd86 100644 --- a/utils/createCanonicalLink.js +++ b/utils/createCanonicalLink.js @@ -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) => {