add "fields" to gallery entry, split inherit props

This commit is contained in:
lightling 2024-03-20 23:09:54 -04:00
parent 2359541fbf
commit 643b7d1bee
3 changed files with 20 additions and 7 deletions

View file

@ -1,12 +1,15 @@
export type GalleryEntry = {
id: string
export type GalleryEntryInheritedProperties = {
description?: string
thumbnailPosition?: `${'left' | 'center' | 'right'} ${'top' | 'center' | 'bottom'}`
thumbnailUrl: string
fields?: Record<string, string>
title: string | null | undefined
warning?: string
}
export type GalleryEntry = GalleryEntryInheritedProperties & {
id: string
thumbnailUrl: string
url?: string
variants?: GalleryEntries
warning?: string
}
export type GalleryEntries = { [idOrTitle: string]: GalleryEntry }

View file

@ -1,4 +1,4 @@
import type { GalleryEntry } from 'src/types/galleries/galleryList'
import type { GalleryEntry, GalleryEntryInheritedProperties } from 'src/types/galleries/galleryList'
import { deepCopy } from './dom'
export const getTitleFromEntryOrId = (entry: GalleryEntry, id: string) => (
@ -18,7 +18,7 @@ export const amendVariantsWithDefaults = (entry: GalleryEntry) => {
return variants
}
export const _amendVariantWithDefaults = (parent: GalleryEntry, variant: GalleryEntry) => {
export const _amendVariantWithDefaults = (parent: GalleryEntryInheritedProperties, variant: GalleryEntryInheritedProperties) => {
if (variant.title === undefined && (!!parent.title || parent.title === null || parent.title === '')) {
variant.title = parent.title
}
@ -28,6 +28,9 @@ export const _amendVariantWithDefaults = (parent: GalleryEntry, variant: Gallery
if (variant.warning === undefined && !!parent.warning) {
variant.warning = parent.warning
}
if (!variant.fields && !!parent.fields) {
variant.fields = parent.fields
}
return variant
}

View file

@ -49,6 +49,13 @@ onMounted(async () => {
)
.view-content
p {{ title }}
.info
.info-entry(
v-for='(field, key) in entry.fields'
:class='key'
)
dl {{ key }}
dt {{ field }}
EmbedableContent(
:content='entry.description'
)