From 169ef685cee8434d28e30dfd2d19069f661c2e2e Mon Sep 17 00:00:00 2001 From: Benjamin Singleton <19498453+tetrogem@users.noreply.github.com> Date: Mon, 9 Feb 2026 21:23:28 -0600 Subject: [PATCH] feat: randomize greeting from pool on homepage --- apps/vdn-static/src/components/pages/HomePage.vue | 9 +++++---- apps/vdn-static/src/i18n/greeting.ts | 15 +++++++++++++++ apps/vdn-static/src/utils/random.ts | 13 +++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 apps/vdn-static/src/i18n/greeting.ts create mode 100644 apps/vdn-static/src/utils/random.ts diff --git a/apps/vdn-static/src/components/pages/HomePage.vue b/apps/vdn-static/src/components/pages/HomePage.vue index 9dc89c8..fc406ff 100644 --- a/apps/vdn-static/src/components/pages/HomePage.vue +++ b/apps/vdn-static/src/components/pages/HomePage.vue @@ -1,19 +1,20 @@ - BRÅTULA VIOSSA.NET MÅDE - - Hadjiplas per lera para Viossa – glossa fu vi - + {{ greeting.title }} + {{ greeting.subtitle }} diff --git a/apps/vdn-static/src/i18n/greeting.ts b/apps/vdn-static/src/i18n/greeting.ts new file mode 100644 index 0000000..dd4cae5 --- /dev/null +++ b/apps/vdn-static/src/i18n/greeting.ts @@ -0,0 +1,15 @@ +export interface Greeting { + title: string; + subtitle: string; +} + +export const GREETINGS = [ + { + title: "BRÅTULA VIOSSA.NET MÅDE", + subtitle: "Hadjiplas per lera para Viossa – glossa fu vi", + }, + { + title: "akka po viossa.net!", + subtitle: "kenomasufobo o gen wi tropos o viosox", + }, +] as const satisfies Greeting[]; diff --git a/apps/vdn-static/src/utils/random.ts b/apps/vdn-static/src/utils/random.ts new file mode 100644 index 0000000..9c629bb --- /dev/null +++ b/apps/vdn-static/src/utils/random.ts @@ -0,0 +1,13 @@ +export function randomMaybeElement( + elements: Elements, +): Elements[number] | undefined { + const index = Math.floor(Math.random() * elements.length); + return elements[index]; +} + +export function randomElement( + elements: Elements, +): Elements[number] { + // SAFETY: because there is always at least one element, undefined will never be returned + return randomMaybeElement(elements) as Elements[number]; +}