From e4750ccfe82b0c3cc82dd5f5f711090e16549bcd Mon Sep 17 00:00:00 2001 From: Mat Jordan Date: Tue, 27 Aug 2024 16:26:48 -0400 Subject: [PATCH] Add custom View All property for overriding slider homepage. --- pages/docs/slider.mdx | 1 + src/components/Slider/index.tsx | 14 +++++++++++++- src/types/slider.ts | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pages/docs/slider.mdx b/pages/docs/slider.mdx index 63204c0e..77592fc2 100644 --- a/pages/docs/slider.mdx +++ b/pages/docs/slider.mdx @@ -98,6 +98,7 @@ Render the slider with IIIF Collection URI. The only required prop is the `iiifC | `onItemInteraction` | `function` | No | | | `options.breakpoints` | `SwiperProps["breakpoints"]` | No | | | `options.credentials` | `omit`, `same-origin`, `include` | No | `omit` | +| `options.customViewAll` | `string` | No | | ### Custom Breakpoints diff --git a/src/components/Slider/index.tsx b/src/components/Slider/index.tsx index d0190147..f87496c4 100644 --- a/src/components/Slider/index.tsx +++ b/src/components/Slider/index.tsx @@ -1,3 +1,4 @@ +import "src/i18n/config"; import { CollectionItems, CollectionNormalized, @@ -18,6 +19,7 @@ import Header from "src/components/Slider/Header/Header"; import Items from "src/components/Slider/Items/Items"; import hash from "src/lib/hash"; import { upgrade } from "@iiif/parser/upgrader"; +import { format } from "path"; export interface CloverSliderProps { collectionId?: string; @@ -69,6 +71,16 @@ const RenderSlider: React.FC = ({ return <>; } + const homepage: ContentResource[] = options.customViewAll + ? [ + { + id: options.customViewAll, + type: "Text", + format: "text/html", + }, + ] + : (collection?.homepage as any as ContentResource[]); + const instance = hash(iiifResource); if (!collection) return <>; @@ -83,7 +95,7 @@ const RenderSlider: React.FC = ({ ? collection.summary : { none: [""] } } - homepage={collection.homepage as any as ContentResource[]} + homepage={homepage} instance={instance} />