get gallery functionality working again

- redefine gallery types
- re-implement gallery list, tile, and view
- no carousel yet for variants, but WithoutVariants works when url specified
This commit is contained in:
lightling 2024-08-02 14:05:51 -04:00
parent 07b37e0805
commit 8ac3ed16ff
Signed by: lightling
GPG key ID: F1F29650D537C773
9 changed files with 225 additions and 145 deletions

View file

@ -6,17 +6,55 @@ import type { MediaEntry } from './shared'
export type GalleryEntryFormat =
| 'image'
/**
* This describes additional information about a gallery entry
* to display when listing the entry on the gallery-list page.
*/
export type GalleryEntry = {
/**
* Defines properties shared among the different versions of a {@link GalleryEntry}
*/
export type GalleryEntrySharedProperties = {
/**
* The kind of media the entry is
*/
format: GalleryEntryFormat
} & MediaEntry
/**
* This describes additional information about a gallery entry which does not contain any variants.
* It contains a URL to the media that the entry represents.
*/
export type GalleryEntryWithoutVariants = {
/**
* URL to the markdown document of the gallery entry
* URL to the entry
*/
url: string
} & MediaEntry
} & GalleryEntrySharedProperties
/**
* This describes additional information about a gallery entry which contains variants.
* It contains a collection of ids which map to a gallery entry without variants.
*/
export type GalleryEntryWithVariants = {
/**
* The id of the entry from the {@link GalleryEntry variants} collection to display when the page first loads.
* If this is not defined, the first entry will be chosen instead.
*/
defaultVariant?: string
/**
* Variants are a collection of alternate media to display for the entry.
* This changes based on the {@link GalleryEntryFormat format} of the entry:
* - For music, this is treated like a tracklist for an album,
* with the {@link GalleryEntry.defaultVariant default} or selected variant being treated as the current track in the player
* - For all other media, this is put into a carousel,
* where the {@link GalleryEntry.defaultVariant default} or selected variant is displayed in the main viewer
*/
variants: Record<string, GalleryEntryWithoutVariants>
} & GalleryEntrySharedProperties
/**
* This describes the overall structure of a gallery entry
* to display when listing the entry on the gallery-list page.
* Note that a {@link GalleryEntryWithVariants} will take priority
* over a {@link GalleryEntryWithoutVariants}
* if the parsed config results in one with fields from both types.
*/
export type GalleryEntry =
| GalleryEntryWithoutVariants
| GalleryEntryWithVariants