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

summaryrefslogtreecommitdiffhomepage
path: root/frontend/src/main.ts
blob: c67898f90d7313257d8452ba0ab48725086fd690 (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
39
40
41
42
43
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1

import { createApp, watch } from "vue";
import { createRouter, createWebHistory, type RouteRecordRaw } from "vue-router";
import App from "./App.vue";
import { contentRoutes } from "./content/routes";
import DocPage from "./pages/DocPage.vue";
import LandingPage from "./pages/LandingPage.vue";
import OverviewPage from "./pages/OverviewPage.vue";
import GettingStartedPage from "./pages/GettingStartedPage.vue";
import { locale } from "./preferences";
import { applyPageMetadata } from "./seo";
import { site } from "./site";
import "./styles/site.css";

// Every site opens on its own landing page. tala.run also has two pages built by hand; the rest of the
// documentation of each site is rendered from content.
const pages: RouteRecordRaw[] = [
  { path: "/", component: LandingPage },
  ...(site === "language"
    ? [
        { path: "/docs/overview", component: OverviewPage },
        { path: "/docs/getting-started", component: GettingStartedPage },
      ]
    : []),
];
const documentation: RouteRecordRaw[] = contentRoutes[site].map((route) => ({
  path: route.path,
  component: DocPage,
  props: { topic: route.topic, path: route.path },
}));

const router = createRouter({
  history: createWebHistory(),
  scrollBehavior: () => ({ top: 0 }),
  routes: [...pages, ...documentation, { path: "/:pathMatch(.*)*", redirect: "/" }],
});

router.afterEach((to) => applyPageMetadata(to.path, locale.value));
watch(locale, (value) => applyPageMetadata(router.currentRoute.value.path, value));

createApp(App).use(router).mount("#app");