Skip to content

Commit

Permalink
Merge pull request #227 from samvera-labs/5189-slider-custom-homepage
Browse files Browse the repository at this point in the history
Add custom View All property for overriding slider homepage.
  • Loading branch information
mathewjordan authored Aug 27, 2024
2 parents 985d15d + e4750cc commit 92e97a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions pages/docs/slider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion src/components/Slider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "src/i18n/config";
import {
CollectionItems,
CollectionNormalized,
Expand All @@ -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;
Expand Down Expand Up @@ -69,6 +71,16 @@ const RenderSlider: React.FC<CloverSliderProps> = ({
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 <></>;
Expand All @@ -83,7 +95,7 @@ const RenderSlider: React.FC<CloverSliderProps> = ({
? collection.summary
: { none: [""] }
}
homepage={collection.homepage as any as ContentResource[]}
homepage={homepage}
instance={instance}
/>
<Items
Expand Down
1 change: 1 addition & 0 deletions src/types/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SwiperProps } from "swiper/react";
export interface ConfigOptions {
breakpoints?: SwiperBreakpoints;
credentials?: FetchCredentials;
customViewAll?: string;
}

export type CustomHomepage = Array<
Expand Down

0 comments on commit 92e97a9

Please sign in to comment.