diff --git a/src/app/content/hooks/locationChange.spec.ts b/src/app/content/hooks/locationChange.spec.ts index b739e53f91..77bee5037f 100644 --- a/src/app/content/hooks/locationChange.spec.ts +++ b/src/app/content/hooks/locationChange.spec.ts @@ -211,6 +211,7 @@ describe('contentRouteHookBody', () => { meta: { slug: 'new-book', }, + polish_site_link: '', promote_image: null, publish_date: '2012-06-21', }; diff --git a/src/app/content/types.ts b/src/app/content/types.ts index fbd9fc287d..d935691c79 100644 --- a/src/app/content/types.ts +++ b/src/app/content/types.ts @@ -88,6 +88,7 @@ export interface BookWithOSWebData extends VersionedArchiveBookWithConfig { }; publish_date: string; amazon_link: string; + polish_site_link: string; subject: string; subjects: Array<{subject_name: string}>; categories: Array<{subject_name: string; subject_category: string}>; diff --git a/src/app/content/utils.ts b/src/app/content/utils.ts index 4a88712720..cb689475fd 100644 --- a/src/app/content/utils.ts +++ b/src/app/content/utils.ts @@ -105,6 +105,7 @@ export const formatBookData = ( return { ...pickArchiveFields(archiveBook), amazon_link: osWebBook.amazon_link, + polish_site_link: osWebBook.polish_site_link, authors: osWebBook.authors, book_state: osWebBook.book_state, categories: osWebBook.book_categories, diff --git a/src/app/content/utils/seoUtils.spec.data.ts b/src/app/content/utils/seoUtils.spec.data.ts index 9696f4245c..93217a52ae 100644 --- a/src/app/content/utils/seoUtils.spec.data.ts +++ b/src/app/content/utils/seoUtils.spec.data.ts @@ -74,6 +74,7 @@ export const mockOsWebBook: OSWebBook = { promote_image: null, cnx_id: '', amazon_link: '', + polish_site_link: '', }; export const emptyPage = { diff --git a/src/app/content/utils/urlUtils.ts b/src/app/content/utils/urlUtils.ts index 32c2420011..fb4047421d 100644 --- a/src/app/content/utils/urlUtils.ts +++ b/src/app/content/utils/urlUtils.ts @@ -6,7 +6,7 @@ import { findArchiveTreeNodeById, findArchiveTreeNodeByPageParam } from './archi import { stripIdVersion } from './idUtils'; export function bookDetailsUrl(book: BookWithOSWebData) { - return `/details/books/${book.slug}`; + return book.polish_site_link || `/details/books/${book.slug}`; } export const getBookPageUrlAndParams = ( diff --git a/src/gateways/createOSWebLoader.ts b/src/gateways/createOSWebLoader.ts index 8f5b421e96..ba37f01118 100644 --- a/src/gateways/createOSWebLoader.ts +++ b/src/gateways/createOSWebLoader.ts @@ -20,6 +20,7 @@ export interface OSWebBook { book_categories: Array<{subject_name: string; subject_category: string}>; cnx_id: string; amazon_link: string; + polish_site_link: string; } interface OSWebResponse { @@ -35,6 +36,7 @@ export const fields = [ 'publish_date', 'cover_color', 'amazon_link', + 'polish_site_link', 'book_state', 'promote_image', 'book_subjects', diff --git a/src/test/fixtures/apps/cms/api/v2/pages/%3Ftype%3Dbooks.Book%26fields%3Dcnx_id%2Cauthors%2Cpublish_date%2Ccover_color%2Camazon_link%2Cbook_state%2Cpromote_image%2Cbook_subjects%2Cbook_categories%26cnx_id%3Dtestbook1-uuid b/src/test/fixtures/apps/cms/api/v2/pages/%3Ftype%3Dbooks.Book%26fields%3Dcnx_id%2Cauthors%2Cpublish_date%2Ccover_color%2Camazon_link%2Cpolish_site_link%2Cbook_state%2Cpromote_image%2Cbook_subjects%2Cbook_categories%26cnx_id%3Dtestbook1-uuid similarity index 100% rename from src/test/fixtures/apps/cms/api/v2/pages/%3Ftype%3Dbooks.Book%26fields%3Dcnx_id%2Cauthors%2Cpublish_date%2Ccover_color%2Camazon_link%2Cbook_state%2Cpromote_image%2Cbook_subjects%2Cbook_categories%26cnx_id%3Dtestbook1-uuid rename to src/test/fixtures/apps/cms/api/v2/pages/%3Ftype%3Dbooks.Book%26fields%3Dcnx_id%2Cauthors%2Cpublish_date%2Ccover_color%2Camazon_link%2Cpolish_site_link%2Cbook_state%2Cpromote_image%2Cbook_subjects%2Cbook_categories%26cnx_id%3Dtestbook1-uuid diff --git a/src/test/mocks/osWebLoader.ts b/src/test/mocks/osWebLoader.ts index 753d6f50ee..71aa0d6fc0 100644 --- a/src/test/mocks/osWebLoader.ts +++ b/src/test/mocks/osWebLoader.ts @@ -2,6 +2,7 @@ import { OSWebBook } from '../../gateways/createOSWebLoader'; export const mockCmsBook: OSWebBook = { amazon_link: '', + polish_site_link: '', authors: [{value: {name: 'Bam Bammerson', senior_author: true}}], book_categories: [{subject_name: 'test subject', subject_category: 'test category'}], book_state: 'live',