Skip to content
Myr

paths.ts

This file

Path

apps/web/src/features/shared/paths.ts

76 lines · 2.2 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726

lines 1–6why, one step back
1import type {
2 AskId,3 DecisionId,4 Handle,5 ProjectName,6} from "@repo/protocol/ids";

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 7why, one step back
7import { Result } from "effect";

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

line 8why, one step back
8

Merge build/1300-w13-foundation into mainoscabrielbefore adoption0e29c37

lines 9–10why, one step back
9export const ASKS_PATH = "/asks";
10

Merge build/1411-web-import into mainoscabrielbefore adoption059c75c

lines 11–12why, one step back
11export const IMPORT_PATH = "/import";
12

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 13–27why, one step back
13export const EXPLORE_PATH = "/explore";
1415/** Every way to reach the platform; the old `/agents` redirects here. */16export const INSTALL_PATH = "/install";1718/** A reader's own page: the decisions waiting on them, their claims, the asks to take next. */19export const INBOX_PATH = "/inbox";2021export const PRIVACY_PATH = "/privacy";2223/** A reader's own choices, kept in their browser (ADR 0042). */24export const SETTINGS_PATH = "/settings";2526export const TERMS_PATH = "/terms";27

Merge build/1300-w13-foundation into mainoscabrielbefore adoption0e29c37

lines 28–30why, one step back
28export const docsPath = (page?: string) =>
29 page === undefined ? "/docs" : `/docs/${page}`;30

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

lines 31–38why, one step back
31export const projectPath = (project: ProjectName) => `/${project}`;
3233export const askPath = (project: ProjectName, ask: AskId) =>34 `/${project}/asks/${ask}`;3536export const answerPath = (project: ProjectName, ask: AskId) =>37 `/${project}/answers/${ask}`;38

Merge build/comments-web-features into mainoscabrielbefore adoption74bfc72

line 39why, one step back
39/** A handle is URL-safe by its schema. */

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

lines 40–41why, one step back
40export const personPath = (handle: Handle) => `/people/${handle}`;
41

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 42–44why, one step back
42/** A project's Visibility tab (ADR 0041), and the regions on it a link may open. */
43export const visibilityPath = (project: ProjectName) =>44 `/${project}/visibility`;

Fold every page's project events once, keep Markdown off the first load, and cache what never changesoscabrielbefore adoption38e5215

line 45why, one step back
45

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 46–61why, one step back
46export const LEDGER_ANCHOR = "ledger";
4748export const ENVIRONMENT_ANCHOR = "environment";4950/** Each page of a project that folded into its Visibility tab, and the region it opens there. */51export const MOVED_TO_VISIBILITY: ReadonlyMap<string, string> = new Map([52 ["env", ENVIRONMENT_ANCHOR],53 ["ledger", LEDGER_ANCHOR],54]);5556/** Where an old page's address goes: the tab, the query as it was spelled, then the region. */57export const visibilityHref = (58 project: string,59 anchor: string,60 search: string61) => `/${project}/visibility${search}#${anchor}`;

Draw every list and subject from one row, one status line, one family fan and one set of fact blocksoscabrielbefore adoption886b726

lines 62–64why, one step back
62
63export const decisionPath = (project: ProjectName, decision: DecisionId) =>64 `/${project}/decisions/${decision}`;

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

lines 65–76why, one step back
65
66const decoded = (segment: string) =>67 Result.getOrElse(68 Result.try(() => decodeURIComponent(segment)),69 () => segment70 );7172export const segmentsOf = (pathname: string) =>73 pathname74 .split("/")75 .filter((segment) => segment !== "")76 .map(decoded);