begin refactoring lists

- async fetching of list entries is now done when the tile is mounted for blog-lists
- started removing recursion from galleries
This commit is contained in:
lightling 2024-07-30 22:01:03 -04:00
parent 51e720fc29
commit 650df38f6c
Signed by: lightling
GPG key ID: F1F29650D537C773
7 changed files with 111 additions and 348 deletions

View file

@ -1,45 +1,12 @@
import type { DateRange } from '../dateRange'
import type { EntryTagCollection } from '../entryTag'
import type { ListWithEntries } from './shared'
import type { MediaEntry } from './shared'
/**
* This describes aditional information about a blog entry
* This describes additional information about a blog entry
* to display when listing the entry on the blog-list page.
* At minimum, the title should be specified.
*/
export type BlogEntry = {
/**
* Specifies the date of the blog entry
*/
date?: DateRange | string | number
/**[Supports Markdown]
* Information to summarize an entry
*/
description?: string
/**
* Tags that correspond to filters on the blog-list page if defined
*/
tags?: string[]
/**[Supports Markdown]
* The title of the blog entry
*/
title: string
/**
* Information regarding the thumbnail
*/
thumbnail?: {
/**
* Sets the inline-styles for the thumbnail
*/
style: CSSStyleDeclaration
}
/**
* URL to the markdown document of the blog entry
*/
url: string
}
export type BlogList = {
tags?: EntryTagCollection
removeFromView?: boolean
} & ListWithEntries<BlogEntry>
} & MediaEntry

View file

@ -1,83 +1,22 @@
import type { EntryTagCollection } from '../entryTag'
import type { ListWithEntries } from './shared'
import type { MediaEntry } from './shared'
/**
* A partial definition of a {@link GalleryEntry}
* which defines the properties of an entry
* that can be passed down from a top-level entry down to its variants
* Defines the supported formats for a gallery entry
*/
export type GalleryEntryInheritedProperties = {
/**
* css background applied to the image (useful for transparent images)
*/
background?: string
/**
* [SUPPORTS MARKDOWN] a place for the siteowner to describe the entry
*/
description?: string
/**
* a key-value pair set of general-purpose fields to additionally describe the entry
* @example entry.fields = {
* 'date': '1960/01/01',
* 'rating': 'general',
* }
*/
fields?: Record<string, string>
/**
* array of tag-ids that apply to the art;
* this is used to allow a visitor to filter out entries of a specific tag
* @see {@link GalleryList.tags}
*/
tags: string[]
/**
* css background applied to the thumbnail (useful for transparent images)
*/
thumbnailBackground?: string
/**
* the position of the thumbnail;
* this will be applied as css `object-position`
*/
thumbnailPosition?: string
/**
* the title of the entry
*/
title: string | null | undefined
/**
* any content warnings that apply to the entry,
* which will be used to apply the `.warning` classname
* to the DOM of a gallery tile
* and will be displayed with the tile
*/
warning?: string
} & ListWithEntries<GalleryEntryInheritedProperties>
export type GalleryEntryFormat =
| 'image'
/**
* Defines an entry in a gallery that can be displayed in a tiled manner
* and can be clicked by a visitor to display its variants or the entry itself if there are none
* This describes additional information about a gallery entry
* to display when listing the entry on the gallery-list page.
*/
export type GalleryEntry = GalleryEntryInheritedProperties & {
export type GalleryEntry = {
/**
* the url to the thumbnail to show for the entry in the gallery tile
* The kind of media the entry is
*/
thumbnailUrl?: string
format: GalleryEntryFormat
/**
* the url to the entry itself
* URL to the markdown document of the gallery entry
*/
url?: string
}
/**
* Defines the model of the `GalleryList` template
*/
export type GalleryList = {
/**
* the tags to use for filtering entries
*/
tags?: EntryTagCollection
/**
* whether or not tag filtering removes entries completely from view;
* if false, they will apply a class selector instead
* in order to manually style (CSS filtering/opacity/etc.)
*/
removeFromView?: boolean
} & ListWithEntries<GalleryEntry>
url: string
} & MediaEntry

View file

@ -1,3 +1,6 @@
import type { DateRange } from '../dateRange'
import type { EntryTagCollection } from '../entryTag'
/**
* Defines entries that are already fetched or are embedded directly in the list.
* Stored in key-value format where the key is the id of the entry,
@ -32,9 +35,61 @@ export type ListWithEntries<T> = {
embeddedEntries?: ListEntries<T>
}
export type ListEntriesWithNestedEntries<T> = { [key: string]: T & ListWithEntries<T> }
/**
* The resolved instance of a list, which will flatten
*/
export type ResolvedListEntries<T> = ListEntries<Promise<T>>
export type ListWithNestedEntries<T> = {
entries?: ListRemoteEntries
embeddedEntries?: ListEntriesWithNestedEntries<T>
/**
* Defines a list that supports tagging the entries
*/
export type ListWithTags<T> = {
/**
* the tags to use for filtering entries
*/
tags?: EntryTagCollection
/**
* whether or not tag filtering removes entries completely from view;
* if false, they will apply a class selector instead
* in order to manually style (CSS filtering/opacity/etc.)
*/
removeFromView?: boolean
} & ListWithEntries<T>
/**
* Defines an entry with common media-related fields
*/
export type MediaEntry = {
/**
* Specifies the date of the entry
*/
date?: DateRange | string | number
/**[Supports Markdown]
* Information to summarize an entry
*/
description?: string
/**
* Tags that correspond to filters on the list page if defined
*/
tags?: string[]
/**[Supports Markdown]
* The title of the entry
*/
title: string
/**
* Information regarding the thumbnail
*/
thumbnail?: {
/**
* Sets the inline-styles for the thumbnail
*/
style: CSSStyleDeclaration
}
/**
* any content warnings that apply to the entry,
* which will be used to apply the `.warning` classname
* to the DOM of a tile
* and will be displayed with the tile
*/
warning?: string
}