Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/frontend/src/content/routes.ts
blob: 393bd0d052de881b32fda14a7fbb24d76498fb6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1

import type { Locale } from "../locales";
import { siteTopics, type Site } from "../site.ts";
import { syntaxRoutes } from "./syntax.ts";
import { talacRoutes } from "./talac.ts";
import { talafmtRoutes } from "./talafmt.ts";
import { talalintRoutes } from "./talalint.ts";
import { tazelRoutes } from "./tazel.ts";
import type { DocRoute } from "./types";

/** The documentation pages each site renders from content; the language site also has hand-built pages. */
export const contentRoutes: Record<Site, readonly DocRoute[]> = {
  language: syntaxRoutes,
  talac: talacRoutes,
  tazel: tazelRoutes,
  talafmt: talafmtRoutes,
  talalint: talalintRoutes,
};

// The two hand-built pages of the language site name themselves in their own components; the sidebar of a content
// page needs their names too.
const languagePageNames: Record<Locale, Record<string, string>> = {
  "en-US": { "/docs/overview": "Overview", "/docs/getting-started": "Getting started" },
  "de-DE": { "/docs/overview": "Überblick", "/docs/getting-started": "Erste Schritte" },
  "ru-RU": { "/docs/overview": "Обзор", "/docs/getting-started": "Начало работы" },
  "he-IL": { "/docs/overview": "סקירה", "/docs/getting-started": "צעדים ראשונים" },
};

/** The sidebar of a documentation page: every topic of the site, in order. */
export function sidebarFor(site: Site, locale: Locale): { path: string; label: string }[] {
  return siteTopics[site].map((path) => {
    const content = contentRoutes[site].find((route) => route.path === path);
    const label = content ? content.topic[locale].nav : (languagePageNames[locale][path] ?? path);
    return { path, label };
  });
}