diff --git a/libs/types/src/content/dateRange.d.ts b/libs/types/src/content/dateRange.d.ts index 7b80d0a..175ef77 100644 --- a/libs/types/src/content/dateRange.d.ts +++ b/libs/types/src/content/dateRange.d.ts @@ -1,4 +1,4 @@ export type DateRange = { - from: string - to: string + from: string | number + to: string | number } diff --git a/libs/types/src/content/templates/project-list.d.ts b/libs/types/src/content/templates/project-list.d.ts index c4ea0e6..f9aeab0 100644 --- a/libs/types/src/content/templates/project-list.d.ts +++ b/libs/types/src/content/templates/project-list.d.ts @@ -1,3 +1,4 @@ +import type { DateRange } from '../dateRange' import type { EntryTagCollection } from '../entryTag' import type { EntryWithConfig, EntryWithContent } from './shared' @@ -7,18 +8,11 @@ import type { EntryWithConfig, EntryWithContent } from './shared' * At minimum, the title should be specified. */ export type ProjectListingInfo = { - /**[Supports Markdown] - * Caption displayed below the title of the project on the projects page - */ - caption?: string - /**[Supports Markdown] - * Optional subtitle for the project - */ - subtitle?: string + date?: DateRange | string | number /**[Supports Markdown] * Information to summarize a project */ - summary?: string + description?: string /** * Tags that correspond to project filters on the portfolio page if defined */ @@ -27,14 +21,9 @@ export type ProjectListingInfo = { * The title of the project */ title: string - /**[CSS:background] - * Background image, repeat, attachment, and position for the project - */ - thumbnailBackground?: string - /**[CSS:background-size] - * Background image size - */ - thumbnailBackgroundSize?: string + thumbnail?: { + style: CSSStyleDeclaration + } } export type ProjectEntries = { [key: string]: @@ -43,10 +32,6 @@ export type ProjectEntries = { [key: string]: } export type ProjectList = { - projects: { [key: string]: { - config: string - content: string - }} projects: ProjectEntries tags?: EntryTagCollection removeFromView?: boolean diff --git a/projects/frontend/src/utilities/parse.ts b/projects/frontend/src/utilities/parse.ts new file mode 100644 index 0000000..0c2fb24 --- /dev/null +++ b/projects/frontend/src/utilities/parse.ts @@ -0,0 +1,21 @@ +import type { DateRange } from '@goldenwere/mackenzii-types' + +/** + * Converts a date object/string/number into a formatted date string + * @param date the date to format + * @returns the date formatted into locale string (or the original date if a string) + */ +export const getFormattedDate = (date: DateRange | string | number): string => { + const { from, to } = date as DateRange + if (!!from || !!to) { + return `${getFormattedDate(from)} - ${getFormattedDate(to)}` + } else { + const num = Number(date) + + if (isNaN(+num)) { + return date as string + } + + return new Date(num).toLocaleDateString() + } +} diff --git a/projects/frontend/src/views/project/project-tile.vue b/projects/frontend/src/views/project/project-tile.vue index 380cad3..d2363a5 100644 --- a/projects/frontend/src/views/project/project-tile.vue +++ b/projects/frontend/src/views/project/project-tile.vue @@ -1,6 +1,7 @@