Skip to content

Commit 71b6bba

Browse files
committed
Add story sharing buttons to the top of the story
1 parent 1b8fd33 commit 71b6bba

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

modules/Story/Story.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FormattedDate } from '@/adapters/client';
77
import { app } from '@/adapters/server';
88
import { CategoriesList } from '@/components/CategoriesList';
99
import { ContentRenderer } from '@/components/ContentRenderer';
10+
import { SocialShare } from '@/components/SocialShare';
1011
import type { StoryActions, ThemeSettings } from 'theme-settings';
1112

1213
import { Embargo } from './Embargo';
@@ -31,6 +32,7 @@ export async function Story({ actions, sharingOptions, showDate, story, withHead
3132
const nodes = JSON.parse(story.content);
3233
const [headerImageDocument, mainDocument] = pullHeaderImageNode(nodes, withHeaderImage);
3334
const sharingUrl = links.short || links.newsroom_view;
35+
const canShare = visibility === 'public' && sharingUrl;
3436

3537
const headerAlignment = getHeaderAlignment(nodes);
3638

@@ -59,10 +61,17 @@ export async function Story({ actions, sharingOptions, showDate, story, withHead
5961
<FormattedDate value={story.published_at} />
6062
</p>
6163
)}
64+
{canShare && sharingOptions.share_icons_placement?.includes('top') && (
65+
<SocialShare
66+
socialNetworks={sharingOptions.sharing_actions}
67+
url={sharingUrl}
68+
thumbnailUrl={thumbnailUrl}
69+
/>
70+
)}
6271
</div>
6372
<ContentRenderer story={story} nodes={mainDocument} />
6473
</article>
65-
{visibility === 'public' && sharingUrl && (
74+
{canShare && (
6675
<Share
6776
actions={actions}
6877
sharingOptions={sharingOptions}

0 commit comments

Comments
 (0)