From 3d5e310f4b1082ddaf2844d6569a560ad5226e47 Mon Sep 17 00:00:00 2001 From: Lightling Date: Sun, 20 Apr 2025 17:04:02 -0400 Subject: [PATCH] 0.1.0 --- libs/embeds/package.json | 2 +- libs/types/package.json | 2 +- libs/types/src/config/globals.d.ts | 23 ++++++ libs/types/src/config/navigation.d.ts | 3 +- libs/types/src/config/routing.d.ts | 70 ++++++++++++++----- libs/types/src/config/themes.d.ts | 12 +++- libs/types/src/config/warnings.d.ts | 18 +++++ .../src/content/templates/article-list.d.ts | 6 ++ .../src/content/templates/gallery-list.d.ts | 15 ++-- .../src/content/templates/templateType.d.ts | 3 +- package-lock.json | 16 ++--- package.json | 2 +- projects/frontend/package.json | 2 +- .../src/views/article/article-view.vue | 2 +- projects/manager/package.json | 2 +- 15 files changed, 140 insertions(+), 38 deletions(-) diff --git a/libs/embeds/package.json b/libs/embeds/package.json index cb4295d..f2358f9 100644 --- a/libs/embeds/package.json +++ b/libs/embeds/package.json @@ -1,7 +1,7 @@ { "name": "@goldenwere/mackenzii-embeds", "private": true, - "version": "0.0.0", + "version": "0.1.0", "type": "module", "main": "src/index.ts", "peerDependencies": { diff --git a/libs/types/package.json b/libs/types/package.json index 615759b..a669c55 100644 --- a/libs/types/package.json +++ b/libs/types/package.json @@ -1,7 +1,7 @@ { "name": "@goldenwere/mackenzii-types", "private": true, - "version": "0.0.0", + "version": "0.1.0", "type": "module", "types": "src/index.d.ts", "main": "src/index.d.ts" diff --git a/libs/types/src/config/globals.d.ts b/libs/types/src/config/globals.d.ts index dc2c046..74d9d31 100644 --- a/libs/types/src/config/globals.d.ts +++ b/libs/types/src/config/globals.d.ts @@ -8,11 +8,34 @@ import type { WarningModal } from './warnings' * Defines global values for the site. */ export type SiteGlobals = { + /** + * Route config + */ routes: RouteCollection + /** + * Header config + */ header: HeaderEntry[] + /** + * Identifier for the site (used for prefixing site cache values) + */ id: string + /** + * Global stylesheets shared across all pages to load for the site; + * these are additive and not overridden by per-page stylesheet URLs + */ stylesheetUrls: string[] + /** + * Theme config + */ themes: SiteThemeList + /** + * Tags used by certain templates + */ tags?: string | MediaEntryTag[] + /** + * Default modal text shown by certain templates that may feature content warnings; + * can be overridden per-page, this is used as a fallback when not defined per-page. + */ warning: WarningModal } diff --git a/libs/types/src/config/navigation.d.ts b/libs/types/src/config/navigation.d.ts index 29b1b44..48b8ea9 100644 --- a/libs/types/src/config/navigation.d.ts +++ b/libs/types/src/config/navigation.d.ts @@ -6,12 +6,13 @@ export type HeaderEntry = { displayName: string } & ({ path: string - target?: + target?: ( | '_self' | '_blank' | '_parent' | '_top' | '_unfencedTop' + ) } | { children: HeaderEntry[] }) diff --git a/libs/types/src/config/routing.d.ts b/libs/types/src/config/routing.d.ts index 6c3a0c7..f476c9b 100644 --- a/libs/types/src/config/routing.d.ts +++ b/libs/types/src/config/routing.d.ts @@ -3,18 +3,48 @@ import { ArticleEntry } from '../content/templates/article-list' import { GalleryEntry } from '../content/templates/gallery-list' import { TemplateType } from '../content/templates/templateType' import { WarningModal } from './warnings' -import { mount } from 'mount-vue-component' +import type { mount } from 'mount-vue-component' + +/** + * Defines the base options for all routes + */ +export type BaseRouteDefinition = { + /** + * The short-form title of the page (used for breadcrumbs/any other place that `fullTitle` isn't used) + */ + title: string + /** + * The full title of the page (used for document title) + */ + fullTitle: string + /** + * Stylesheets to load on the page + */ + stylesheetUrls?: string[] + /** + * Script to load on the page + */ + scriptUrl?: string +} /** * Defines the shared options for a route */ -export type SharedRouteDefinition = { +export type SharedRouteDefinition = BaseRouteDefinition & { + /** + * Unique identifier for the page + */ id: string - scriptUrl?: string - stylesheetUrls?: string[] + /** + * What kind of page the route is + */ template: TemplateType - title: string - fullTitle: string + /** + * Modal text shown by certain templates that may feature content warnings; + * setting this to `false` will force the modal off regardless of global site config; + * setting this to `true` or leaving it `undefined`/`null` will use the global site config; + * setting this to {@link WarningModal} will override the global site config with the defined modal definition + */ warning?: boolean | WarningModal } @@ -22,6 +52,9 @@ export type SharedRouteDefinition = { * Defines a content-based route */ export type ContentfulRouteDefintion = SharedRouteDefinition & { + /** + * Url to the page's content + */ content: string } @@ -29,6 +62,9 @@ export type ContentfulRouteDefintion = SharedRouteDefinition & { * Defines a config-based route */ export type ConfigfulRouteDefinition = SharedRouteDefinition & { + /** + * Url to the page's config + */ config: string } @@ -44,11 +80,10 @@ export type MarkdownDefinition = ContentfulRouteDefintion & { */ export type ArticleListDefinition = ConfigfulRouteDefinition & { template: 'article-list' - view: { - title: string - fullTitle: string - stylesheetUrls: string[] - } + /** + * Config for the child view `{parent/path}/view` route + */ + view: BaseRouteDefinition } /** @@ -56,20 +91,20 @@ export type ArticleListDefinition = ConfigfulRouteDefinition & { */ export type GalleryListDefinition = ConfigfulRouteDefinition & { template: 'gallery-list' - view: { - title: string - fullTitle: string - stylesheetUrls: string[] - } + /** + * Config for the child view `{parent/path}/view` route + */ + view: BaseRouteDefinition } /** * Defines all available route definitions */ -export type RouteDefinition = +export type RouteDefinition = ( | MarkdownDefinition | ArticleListDefinition | GalleryListDefinition +) /** * Defines the collection of routes the app uses @@ -80,6 +115,7 @@ export type RouteCollection = { [key: string]: RouteDefinition } * Defines {@link Window} globals */ export interface RoutedWindow extends Window { + /** function registered by the vite-ssg build which will mount Vue components in place of elements they are replacing (e.g. image embeds with PrimeVue Image) */ mountComponent: typeof mount /** refers to a template's primary route config; may briefly refer to sub config until a view is fully resolved */ routeConfig: RouteDefinition diff --git a/libs/types/src/config/themes.d.ts b/libs/types/src/config/themes.d.ts index b7d409b..54ee149 100644 --- a/libs/types/src/config/themes.d.ts +++ b/libs/types/src/config/themes.d.ts @@ -2,8 +2,17 @@ * Defines a stylesheet the site uses for applying a theme */ export type SiteTheme = { + /** + * User-friendly name to render in the site theme picker + */ displayName?: string + /** + * What kind of theme it is for accessibility purposes + */ type: SiteThemeType + /** + * The stylesheet url for the theme + */ url: string } @@ -17,8 +26,9 @@ export type SiteThemeList = { [id: string]: SiteTheme } * for the purposes of determining a default theme * based on the system/browser setting of the visitor */ -export type SiteThemeType = +export type SiteThemeType = ( | 'dark' | 'light' | 'dark_hc' | 'light_hc' +) diff --git a/libs/types/src/config/warnings.d.ts b/libs/types/src/config/warnings.d.ts index e8d0fb7..f9da490 100644 --- a/libs/types/src/config/warnings.d.ts +++ b/libs/types/src/config/warnings.d.ts @@ -2,11 +2,29 @@ * Defines the structure of the warning modal that shows when a route has a content warning of some sort. */ export type WarningModal = { + /** + * The modal's body text + */ prompt: string + /** + * Information used by the Leave button + */ leave: { + /** + * The url the button should kick the user to + */ url: string, + /** + * The text shown on the Leave button + */ text: string, }, + /** + * The text shown on the Acknowledge button + */ acknowledge: string, + /** + * The text shown on the Remember checkbox (which caches the user's consent and avoids re-prompting the modal repeatedly) + */ remember: string, } diff --git a/libs/types/src/content/templates/article-list.d.ts b/libs/types/src/content/templates/article-list.d.ts index 58880c6..81ab330 100644 --- a/libs/types/src/content/templates/article-list.d.ts +++ b/libs/types/src/content/templates/article-list.d.ts @@ -5,7 +5,13 @@ import type { MediaEntry } from './shared' * to display when listing the entry on the article-list page. */ export type ArticleEntry = { + /** + * Alternative text to render for an entry (used on alt attribute for thumbnail where applicable) + */ alternativeText?: string + /** + * Caption to show for the entry (used on title attribute as well as displayed caption text where applicable) + */ caption?: string /** * URL to the entry's thumbnail diff --git a/libs/types/src/content/templates/gallery-list.d.ts b/libs/types/src/content/templates/gallery-list.d.ts index 58d73eb..b859f29 100644 --- a/libs/types/src/content/templates/gallery-list.d.ts +++ b/libs/types/src/content/templates/gallery-list.d.ts @@ -3,12 +3,13 @@ import type { MediaEntry } from './shared' /** * Defines the supported formats for a gallery entry */ -export type GalleryEntryFormat = +export type GalleryEntryFormat = ( | 'image' +) - /** - * Defines properties shared among the different versions of a {@link GalleryEntry} - */ +/** + * Defines properties shared among the different versions of a {@link GalleryEntry} + */ export type GalleryEntrySharedProperties = { /** * The kind of media the entry is @@ -21,7 +22,13 @@ export type GalleryEntrySharedProperties = { * It contains a URL to the media that the entry represents. */ export type GalleryEntryWithoutVariants = { + /** + * Alternative text to render for an entry (used on alt attribute for images where applicable) + */ alternativeText?: string + /** + * Caption to show for the entry (used on title attribute as well as displayed caption text where applicable) + */ caption?: string /** * URL to the entry's thumbnail diff --git a/libs/types/src/content/templates/templateType.d.ts b/libs/types/src/content/templates/templateType.d.ts index 056baa6..ac966a1 100644 --- a/libs/types/src/content/templates/templateType.d.ts +++ b/libs/types/src/content/templates/templateType.d.ts @@ -2,7 +2,8 @@ * Defines the available `views` that can be used to set up routes. * Each `Template` has different configuration options */ -export type TemplateType = +export type TemplateType = ( | 'markdown' | 'article-list' | 'gallery-list' +) diff --git a/package-lock.json b/package-lock.json index 495b0e6..3cb4c22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@goldenwere/mackenzii", - "version": "0.0.0", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@goldenwere/mackenzii", - "version": "0.0.0", + "version": "0.1.0", "workspaces": [ "projects/*", "libs/*" @@ -14,14 +14,14 @@ }, "libs/embeds": { "name": "@goldenwere/mackenzii-embeds", - "version": "0.0.0", + "version": "0.1.0", "peerDependencies": { "typescript": "^5" } }, "libs/types": { "name": "@goldenwere/mackenzii-types", - "version": "0.0.0" + "version": "0.1.0" }, "node_modules/@asamuzakjp/css-color": { "version": "3.1.2", @@ -10978,7 +10978,7 @@ } }, "node_modules/github-from-package": { - "version": "0.0.0", + "version": "0.1.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", "license": "MIT" @@ -14425,7 +14425,7 @@ } }, "node_modules/noms": { - "version": "0.0.0", + "version": "0.1.0", "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", "integrity": "sha512-lNDU9VJaOPxUmXcLb+HQFeUgQQPtMI24Gt6hgfuMHRJgMRHMF/qZ4HJD3GDru4sSw9IQl2jPjAYnQrdIeLbwow==", "license": "ISC", @@ -21036,7 +21036,7 @@ } }, "projects/frontend": { - "version": "0.0.0", + "version": "0.1.0", "devDependencies": { "@goldenwere/mackenzii-embeds": "*", "@goldenwere/mackenzii-types": "*", @@ -21069,7 +21069,7 @@ } }, "projects/manager": { - "version": "0.0.0", + "version": "0.1.0", "devDependencies": { "chalk": "5.4.1", "symlink-dir": "6.0.5" diff --git a/package.json b/package.json index bf01ef6..1fa9fe6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@goldenwere/mackenzii", "private": true, - "version": "0.0.0", + "version": "0.1.0", "type": "module", "scripts": { "start": "npm start -w=frontend", diff --git a/projects/frontend/package.json b/projects/frontend/package.json index 11bdcc2..3c931ba 100644 --- a/projects/frontend/package.json +++ b/projects/frontend/package.json @@ -1,7 +1,7 @@ { "name": "frontend", "private": true, - "version": "0.0.0", + "version": "0.1.0", "type": "module", "scripts": { "start": "vite", diff --git a/projects/frontend/src/views/article/article-view.vue b/projects/frontend/src/views/article/article-view.vue index bc0fc55..6092165 100644 --- a/projects/frontend/src/views/article/article-view.vue +++ b/projects/frontend/src/views/article/article-view.vue @@ -29,7 +29,7 @@ const routeSubConfig = routeStore._routes[currentRoute.path] onMounted(async () => { const config = await fetchAndParseConfig>(routeConfig.config) - resolved.value = await fetchConfigByIdFromList(config, currentRoute.query.id as string) + resolved.value = await fetchConfigByIdFromList(config, currentRoute.query.id as string) const md = await fetchAndParseMarkdown(resolved.value.url) content.value = md document.title = routeSubConfig.fullTitle?.replace('$ENTRY', resolved.value.title) diff --git a/projects/manager/package.json b/projects/manager/package.json index 81d97fc..03271e3 100644 --- a/projects/manager/package.json +++ b/projects/manager/package.json @@ -1,7 +1,7 @@ { "name": "manager", "private": true, - "version": "0.0.0", + "version": "0.1.0", "type": "module", "devDependencies": { "chalk": "5.4.1",