organize types

This commit is contained in:
lightling 2024-05-03 17:30:03 -04:00
parent f48118122b
commit e6cac42dbd
9 changed files with 51 additions and 48 deletions

View file

@ -1,15 +1,7 @@
import { TemplateType } from '../content/templates/templateType'
import { WarningModal } from './warnings'
/**
* Defines the available `views` that can be used to set up routes.
* Each `Template` has different configuration options
*/
export type Template =
| 'markdown'
| 'project-list'
| 'gallery-list'
/**
* Defines the shared options for a route
*/
@ -17,7 +9,7 @@ export type SharedRouteDefinition = {
id: string
scriptUrl?: string
stylesheetUrls: string[]
template: Template
template: TemplateType
title: string
warning: boolean | WarningModal
}
@ -37,14 +29,14 @@ export type ConfigfulRouteDefinition = SharedRouteDefinition & {
}
/**
* Defines the config for a route using the `markdown` {@link Template}
* Defines the config for a route using the `markdown` {@link TemplateType}
*/
export type MarkdownDefinition = ContentfulRouteDefintion & {
template: 'markdown'
}
/**
* Defines the config for a route using the `project-list` {@link Template}
* Defines the config for a route using the `project-list` {@link TemplateType}
*/
export type ProjectListDefinition = ConfigfulRouteDefinition & {
template: 'project-list'
@ -54,7 +46,7 @@ export type ProjectListDefinition = ConfigfulRouteDefinition & {
}
/**
* Defines the config for a route using the `gallery-list` {@link Template}
* Defines the config for a route using the `gallery-list` {@link TemplateType}
*/
export type GalleryListDefinition = ConfigfulRouteDefinition & {
template: 'gallery-list'

29
libs/types/src/content/entryTag.d.ts vendored Normal file
View file

@ -0,0 +1,29 @@
/**
* Defines a tag used by entries in a gallery-list/project-list,
* used for filtering entries from view
*/
export type EntryTag = {
/**
* specifies a category that the tag belongs to
* in order to optionally organize them in the view;
* if category is not specified, tags will be assigned
* "NoCategory" and organized into a section without a heading
* placed before any other sections formed by categories (if any)
*/
category?: string
/**
* specifies the name that the tag will appear as in the DOM;
* if not specified, the id of the tag will be used in its place
*/
displayName?: string
}
/**
* Defines the list of tags in a gallery-list/project-list,
* a key-value object where the value is the entry,
* and the key represents the id of a tag;
* the id of a tag must be unique,
* and the ids specified in a gallery/project entry must match
* the ids specified in `EntryTagCollection` in order for them to work effectively
*/
export type EntryTagCollection = { [id: string]: GalleryTag }

View file

@ -1,3 +1,5 @@
import type { EntryTagCollection } from '../entryTag'
/**
* A partial definition of a {@link GalleryEntry}
* which defines the properties of an entry
@ -81,36 +83,6 @@ export type GalleryEntry = GalleryEntryInheritedProperties & {
*/
export type GalleryEntries = { [idOrTitle: string]: GalleryEntry }
/**
* Defines a tag used by entries in a gallery
* used for filtering entries from view
*/
export type GalleryTag = {
/**
* specifies a category that the tag belongs to
* in order to optionally organize them in the view;
* if category is not specified, tags will be assigned
* "NoCategory" and organized into a section without a heading
* placed before any other sections formed by categories (if any)
*/
category?: string
/**
* specifies the name that the tag will appear as in the DOM;
* if not specified, the id of the tag will be used in its place
*/
displayName?: string
}
/**
* Defines the list of tags in a gallery,
* a key-value object where the value is the entry,
* and the key represents the id of a tag;
* the id of a tag must be unique,
* and the ids specified in a gallery entry must match
* the ids specified in `GalleryTags` in order for them to work effectively
*/
export type GalleryTags = { [id: string]: GalleryTag }
/**
* Defines the model of the `GalleryList` template
*/
@ -122,5 +94,5 @@ export type GalleryList = {
/**
* the tags to use for filtering entries
*/
tags: GalleryTags
tags: EntryTagCollection
}

View file

@ -0,0 +1,8 @@
/**
* Defines the available `views` that can be used to set up routes.
* Each `Template` has different configuration options
*/
export type TemplateType =
| 'markdown'
| 'project-list'
| 'gallery-list'

View file

@ -5,7 +5,9 @@ export * from './config/themes'
export * from './config/warnings'
export * from './content/dateRange'
export * from './content/entryTag'
export * from './content/link'
export * from './content/templates/gallery'
export * from './content/templates/project'
export * from './content/templates/gallery-list'
export * from './content/templates/project-list'
export * from './content/templates/templateType'

View file

@ -7,7 +7,7 @@ import {
type ProjectListDefinition,
type RouteDefinition,
type SiteGlobals,
type Template,
type TemplateType,
} from '@goldenwere/static-web-templates-types'
const markdownBody = () => import ('./views/markdown/markdown.vue')
@ -16,7 +16,7 @@ const projectViewBody = () => import ('./views/project/project-view.vue')
const galleryListBody = () => import ('./views/gallery/gallery-list.vue')
const galleryViewBody = () => import ('./views/gallery/gallery-view.vue')
export const templates: Record<Template, () => Promise<any>> = {
export const templates: Record<TemplateType, () => Promise<any>> = {
'markdown': markdownBody,
'project-list': projectListBody,
'gallery-list': galleryListBody,