33import { translations , useIntl } from '@prezly/theme-kit-nextjs/index' ;
44import classNames from 'classnames' ;
55
6- import { Button } from '@/components/Button' ;
6+ import { Button , ButtonLink } from '@/components/Button' ;
77import { Divider } from '@/components/Divider' ;
88import { SocialShare } from '@/components/SocialShare' ;
99import { IconFileDown , IconFolderDown , IconLink , IconText } from '@/icons' ;
@@ -13,15 +13,25 @@ import type { SharingOptions } from '../type';
1313
1414import { ButtonWithSuccessTooltip } from './ButtonWithSuccessTooltip' ;
1515import styles from './Share.module.scss' ;
16+ import { getAssetsArchiveDownloadUrl } from './utils/getAssetsArchiveDownloadUrl' ;
1617
1718interface Props {
1819 actions ?: StoryActions ;
1920 sharingOptions : SharingOptions ;
2021 thumbnailUrl ?: string ;
2122 url : string ;
23+ uploadcareAssetsGroupUuid : string | null ;
24+ slug : string ;
2225}
2326
24- export function Share ( { actions, thumbnailUrl, sharingOptions, url } : Props ) {
27+ export function Share ( {
28+ actions,
29+ uploadcareAssetsGroupUuid,
30+ thumbnailUrl,
31+ sharingOptions,
32+ url,
33+ slug,
34+ } : Props ) {
2535 const { formatMessage } = useIntl ( ) ;
2636 const socialNetworks = sharingOptions . sharing_actions ;
2737 const socialShareButtonsCount = socialNetworks . length ;
@@ -31,6 +41,9 @@ export function Share({ actions, thumbnailUrl, sharingOptions, url }: Props) {
3141 actions ?. show_download_assets ,
3242 actions ?. show_download_pdf ,
3343 ] . filter ( Boolean ) . length ;
44+ const assetsUrl = uploadcareAssetsGroupUuid
45+ ? getAssetsArchiveDownloadUrl ( uploadcareAssetsGroupUuid , slug )
46+ : undefined ;
3447
3548 function handleCopyLink ( ) {
3649 window . navigator . clipboard . writeText ( url ) ;
@@ -85,14 +98,15 @@ export function Share({ actions, thumbnailUrl, sharingOptions, url }: Props) {
8598 </ ButtonWithSuccessTooltip >
8699 ) }
87100
88- { actions . show_download_assets && (
89- < Button
101+ { actions . show_download_assets && assetsUrl && (
102+ < ButtonLink
103+ href = { assetsUrl }
90104 className = { styles . action }
91105 icon = { IconFolderDown }
92106 variation = "secondary"
93107 >
94108 Download assets
95- </ Button >
109+ </ ButtonLink >
96110 ) }
97111
98112 { actions . show_download_pdf && (
0 commit comments