Skip to content

Commit 1558b91

Browse files
committed
Make code work with older SDK version
This is needed because upgrading SDK requires lots of tracking-related changes which are done in separate PR. The PR is expected to be merged after this feature.
1 parent e815b59 commit 1558b91

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

modules/Story/Share/Share.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface Props {
2626
thumbnailUrl?: string;
2727
title: string;
2828
url: string;
29-
uploadcareAssetsGroupUuid: Story.ExtraFields['uploadcare_assets_group_uuid'];
29+
uploadcareAssetsGroupUuid: string; // TODO: use Story.ExtraFields['uploadcare_assets_group_uuid'] when @prezly/sdk upgraded to v23.7.1
3030
slug: Story['slug'];
3131
uuid: Story['uuid'];
3232
}

modules/Story/Share/utils/getStoryPdfUrl.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use server';
22

3-
import { routing, type Story } from '@prezly/sdk';
3+
import type { Story } from '@prezly/sdk';
44

55
const { PREZLY_ACCESS_TOKEN, PREZLY_API_BASEURL } = process.env;
66

7+
const STORIES_ENDPOINT = `${PREZLY_API_BASEURL}/v2/stories`;
8+
79
export async function getStoryPdfUrl(uuid: Story['uuid']) {
8-
return fetch(`${PREZLY_API_BASEURL}${routing.storiesUrl}/${uuid}`, {
10+
return fetch(`${STORIES_ENDPOINT}/${uuid}`, {
911
headers: {
1012
Authorization: `Bearer ${PREZLY_ACCESS_TOKEN}`,
1113
Accept: 'application/pdf',

modules/Story/Story.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,8 @@ type Props = {
2828
};
2929

3030
export async function Story({ actions, sharingOptions, showDate, story, withHeaderImage }: Props) {
31-
const {
32-
links,
33-
visibility,
34-
thumbnail_url: thumbnailUrl,
35-
title,
36-
slug,
37-
uploadcare_assets_group_uuid,
38-
uuid,
39-
} = story;
31+
const { links, visibility, thumbnail_url: thumbnailUrl, title, slug, uuid } = story;
32+
const { uploadcare_assets_group_uuid } = story as any; // TODO: destructure it above when @prezly/sdk is upgraded to v23.7.1
4033
const nodes = JSON.parse(story.content);
4134
const [headerImageDocument, mainDocument] = pullHeaderImageNode(nodes, withHeaderImage);
4235
const sharingUrl = links.short || links.newsroom_view;

0 commit comments

Comments
 (0)