diff --git a/mocks/mockEnv.ts b/mocks/mockEnv.ts index 34373aa8..451550b0 100644 --- a/mocks/mockEnv.ts +++ b/mocks/mockEnv.ts @@ -5,5 +5,5 @@ export const LIMITED_ACCESS_EDITION_PATH = "/edition/6977884"; export const WORK_PATH = "/work/5950e6df-9d99-42fe-8924-1116166a2acb"; export const DOWNLOAD_PATH = "/test-download-pdf"; export const HOME_PATH = "/"; -export const COLLECTION_LIST_PATH = "/collection/list"; +export const COLLECTION_LIST_PATH = "/collections"; export const INVALID_COLLECTION_PATH = "/collection/invalid-collection"; diff --git a/src/__tests__/fixtures/CollectionFixture.ts b/src/__tests__/fixtures/CollectionFixture.ts index a29948df..077af333 100644 --- a/src/__tests__/fixtures/CollectionFixture.ts +++ b/src/__tests__/fixtures/CollectionFixture.ts @@ -188,7 +188,7 @@ export const oneCollectionListData: Opds2Feed = { ], links: [ { - href: "/collection/list?page=1", + href: "/collections?page=1", rel: ["self", "first", "previous", "next", "last"], type: "application/opds+json", }, @@ -1721,7 +1721,7 @@ export const collectionListData: CollectionResult = { ], links: [ { - href: "/collection/list?page=1", + href: "/collections?page=1", rel: ["self", "first", "previous", "next", "last"], type: "application/opds+json", }, diff --git a/src/lib/api/CollectionApi.ts b/src/lib/api/CollectionApi.ts index 190bda48..255bdcd5 100644 --- a/src/lib/api/CollectionApi.ts +++ b/src/lib/api/CollectionApi.ts @@ -15,7 +15,10 @@ const collectionUrl = apiUrl + collectionPath; export const collectionFetcher = async (query: CollectionQuery) => { const collectionApiQuery = toApiCollectionQuery(query); - const url = new URL(collectionUrl + "/" + query.identifier); + const urlWithIdentifier = query.identifier + ? collectionUrl + "/" + query.identifier + : collectionUrl; + const url = new URL(urlWithIdentifier); url.search = new URLSearchParams( toLocationQuery(collectionApiQuery) ).toString(); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 85c6e37c..e5e833ec 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -9,7 +9,6 @@ import Error from "./_error"; export async function getServerSideProps() { // Fetch all collections const collectionResult: CollectionResult = await collectionFetcher({ - identifier: "list", perPage: 8, }); diff --git a/src/types/CollectionQuery.ts b/src/types/CollectionQuery.ts index 7ec689f9..2cb32fec 100644 --- a/src/types/CollectionQuery.ts +++ b/src/types/CollectionQuery.ts @@ -6,7 +6,7 @@ export type ApiCollectionQuery = { }; export type CollectionQuery = { - identifier: string; + identifier?: string; page?: number; perPage?: number; sort?: string;