cleanup projects types

This commit is contained in:
lightling 2024-05-03 17:38:44 -04:00
parent e6cac42dbd
commit 38170b39bc
5 changed files with 12 additions and 82 deletions

View file

@ -1,6 +1,6 @@
import { HeaderEntry } from './navigation'
import { SiteThemeList } from './themes'
import { WarningModal } from './warnings'
import type { HeaderEntry } from './navigation'
import type { SiteThemeList } from './themes'
import type { WarningModal } from './warnings'
/**
* Defines global values for the site.

View file

@ -26,4 +26,4 @@ export type EntryTag = {
* 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 }
export type EntryTagCollection = { [id: string]: EntryTag }

View file

@ -94,5 +94,5 @@ export type GalleryList = {
/**
* the tags to use for filtering entries
*/
tags: EntryTagCollection
tags?: EntryTagCollection
}

View file

@ -1,4 +1,5 @@
import { DateRange } from 'src/types/shared/dateRange'
import type { DateRange } from '../dateRange'
import type { EntryTagCollection } from '../entryTag'
/**
* This describes aditional information about a project.
@ -36,81 +37,10 @@ export type ProjectListingInfo = {
thumbnailBackgroundSize?: string
}
/**
* This concatenates project files for entry within the store.
*/
export type ProjectStoreEntry = {
/**
* Content pulled from the projects' markdown (.md) file
*/
content?: string
/**
* Listing information pulled from the projects' yaml (.yml) file
*/
listing?: ProjectListingInfo
}
/**
* Defines a filter category in the filters panel
*/
export type ProjectFilterCategory = {
/**
* The heading of the category
*/
heading: string
/**
* The filters associated with the category, or more categories
*/
filters: FilterDefinition[] | ProjectFilterCategory[]
}
/**
* Defines a filter for a project
*/
export type FilterDefinition = {
/**
* The name to display in the filters panel
*/
displayName: string
/**
* The tag which the filter corresponds to for when defined in {@link ProjectListingInfo.tags}
*/
tag: string
}
/**
* Whenever a filter is toggled in the filters panel, this holds the data regarding that change
*/
export type FilterChangeEvent = {
/**
* The tag that the filter is associated with
*/
tag: string
/**
* The toggle state of the filter
*/
value: boolean
}
/**
* Defines the state of the filters panel
*/
export type FilterState = { [tag: string]: boolean }
export type TagDefinition = {
displayName: string
className: string
}
export type Tag =
| TagDefinition
| string
export type ProjectList = {
projects: { [key: string]: {
config: string
content: string
}}
filters?: FilterDefinition[] | ProjectFilterCategory[]
tags?: EntryTagCollection
}

View file

@ -58,12 +58,10 @@ const tagsByCategory = ref({} as { [category: string]: Record<string, string> })
* Handles updating the displayed tags in the list
*/
const onLoadTags = () => {
if (!config.tags) {
tagsByCategory.value = null as any
} else {
if (!!config.tags) {
tagsByCategory.value = { 'NoCategory': {}}
Object.keys(config.tags).forEach(id => {
const tag = config.tags[id]
const tag = config.tags![id]
if (!!tag.category) {
if (!tagsByCategory.value[tag.category]) {
tagsByCategory.value[tag.category] = {}
@ -73,6 +71,8 @@ const onLoadTags = () => {
tagsByCategory.value['NoCategory'][id] = tag.displayName || id
}
})
} else {
tagsByCategory.value = null as any
}
}