mirror of
https://github.com/bitbaum/heidi.git
synced 2026-12-04 05:17:27 +01:00
Under the fold on the signed-out home page: six moments one person is in (the group chat in dialect, the lunch table, the Kindsgi, the doctor, the Gemeinde, the no that does not sound like no) and five a city has (the switch to Standard German, care homes, workplaces, unlabelled media, the learner who cannot check what they are taught). Each card is the problem, what Heidi does about it today, and a link to the page that does it, then a closing call into the chat. - Structure in lib/config/problems.ts: each link is a route key or a scene id, labelled with that page's own nav label or scene title. - Words in all seven dictionaries under home.problems, keyed by id; the Swiss German copy passes Heidi's own dialect gate. - lib/config/problems.test.ts: unique ids, copy for exactly the configured cards in every locale and translated, scene links exist in the packs, route links are public pages with a file (and the #gate anchor exists). - HEIDI.md §5, CHANGELOG.md and lib/config/changelog.ts record it. Claude-Session: https://claude.ai/code/session_016tA6LherCgxwapQ2oYTjc5 Co-authored-by: Claude <noreply@anthropic.com>
80 lines
3.3 KiB
TypeScript
80 lines
3.3 KiB
TypeScript
import type { Dictionary } from "../i18n/dictionaries/de.ts";
|
|
import type { Locale } from "../i18n/locales.ts";
|
|
import { ROUTES, href, type RouteKey } from "../i18n/routes.ts";
|
|
|
|
/**
|
|
* "What Heidi solves" on the public home page: concrete moments, one person's
|
|
* first, then the ones a whole city has.
|
|
*
|
|
* STRUCTURE HERE, WORDS IN THE DICTIONARIES, paired by `id` — the split the
|
|
* situations and grammar topics already make. A link is the same in seven
|
|
* languages; a sentence about the doctor is not.
|
|
*
|
|
* THE LINK IS NEVER A STRING. It is a route key or a scene id, and the card's
|
|
* label is read from the same place the rest of the site reads it — the nav
|
|
* label for a route, the scene's own title for a scene. So a card cannot point
|
|
* at a page that does not exist, or call it something the page does not call
|
|
* itself; `problems.test.ts` holds both.
|
|
*
|
|
* THE HONESTY RULE: every `solution` in the dictionaries describes something
|
|
* that works on the site today. A roadmap item does not belong on this list,
|
|
* and neither does a promise about how fluent anybody becomes (HEIDI.md §8).
|
|
*/
|
|
|
|
type Problems = Dictionary["home"]["problems"];
|
|
export type ProblemId = keyof Problems["items"];
|
|
export type ProblemScaleId = keyof Problems["scales"];
|
|
export type SceneId = keyof Dictionary["situations"]["scenes"];
|
|
|
|
export type ProblemLink =
|
|
| { kind: "route"; route: RouteKey; hash?: string }
|
|
| { kind: "scene"; scene: SceneId };
|
|
|
|
export type ProblemScale = {
|
|
id: ProblemScaleId;
|
|
items: readonly { id: ProblemId; link: ProblemLink }[];
|
|
};
|
|
|
|
export const PROBLEM_SCALES: readonly ProblemScale[] = [
|
|
{
|
|
id: "people",
|
|
items: [
|
|
{ id: "message", link: { kind: "route", route: "chat" } },
|
|
{ id: "lunchTable", link: { kind: "scene", scene: "small-talk" } },
|
|
{ id: "kindergarten", link: { kind: "scene", scene: "school-parents" } },
|
|
{ id: "doctor", link: { kind: "scene", scene: "doctor" } },
|
|
{ id: "gemeinde", link: { kind: "scene", scene: "municipality" } },
|
|
{ id: "indirectNo", link: { kind: "scene", scene: "indirect-no" } },
|
|
],
|
|
},
|
|
{
|
|
id: "society",
|
|
items: [
|
|
{ id: "theSwitch", link: { kind: "route", route: "warmup" } },
|
|
{ id: "care", link: { kind: "scene", scene: "handover" } },
|
|
{ id: "work", link: { kind: "route", route: "organisations" } },
|
|
{ id: "media", link: { kind: "route", route: "listen" } },
|
|
{ id: "trust", link: { kind: "route", route: "method", hash: "gate" } },
|
|
],
|
|
},
|
|
];
|
|
|
|
/** Where a card goes. Scene pages live below `/situations`, like everywhere else. */
|
|
export function problemHref(locale: Locale, link: ProblemLink): string {
|
|
if (link.kind === "scene") return href(locale, `situations/${link.scene}`);
|
|
const path = href(locale, segmentOf(link.route));
|
|
return link.hash ? `${path}#${link.hash}` : path;
|
|
}
|
|
|
|
/** What a card's link says: the page's own name, never a second wording of it. */
|
|
export function problemLinkLabel(dict: Dictionary, link: ProblemLink): string {
|
|
return link.kind === "scene" ? dict.situations.scenes[link.scene].title : dict.nav[link.route];
|
|
}
|
|
|
|
/** The segment from the route table, so a renamed route follows here. */
|
|
function segmentOf(key: RouteKey): string {
|
|
const route = ROUTES.find((r) => r.key === key);
|
|
if (!route) throw new Error(`a home-page problem links to a route that does not exist: ${key}`);
|
|
return route.segment;
|
|
}
|