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

summaryrefslogtreecommitdiffhomepage
path: root/nuxt.config.ts
blob: 70968172611832db593c169a599f6c57f70f8fa5 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
// SPDX-License-Identifier: AGPL-3.0-or-later WITH AdditionRef-Progmasoft-Patent-Grant-1.1

import { localePath, locales } from "./app/content/locales";
import { readdirSync } from "node:fs";
import type { LanguageRegistration } from "shiki";
import grammar from "./grammars/tala.tmLanguage.json";

// Every page in every language, so the generated site holds them all even before a link is found.
// The documents of the English docs, as the paths Nuxt Content gives them: without the numbers
// that order them and without the extension.
const docs = readdirSync("content/en-US/docs", { recursive: true, encoding: "utf8" })
  .filter((file) => file.endsWith(".md"))
  .map(
    (file) =>
      "/docs/" +
      file
        .replaceAll("\\", "/")
        .replace(/\.md$/, "")
        .split("/")
        .map((segment) => segment.replace(/^\d+\./, ""))
        .join("/"),
  );
const pages = ["/", "/docs", ...docs];
const routes = locales.flatMap((locale) => pages.map((page) => localePath(locale, page)));

// The grammar of Tala from the compiler repository; fences name it `tala`.
const tala = { ...grammar, name: "tala" } as unknown as LanguageRegistration;

// The theme is set before the first paint, so a visitor who chose dark never sees a light flash.
const theme = `try{var t=localStorage.getItem("tazel-theme");if(t==="dark"||t==="light")document.documentElement.dataset.theme=t}catch(e){}`;

export default defineNuxtConfig({
  compatibilityDate: "2026-10-15",
  devtools: { enabled: false },
  telemetry: false,
  modules: ["@nuxt/content"],
  css: ["~/assets/site.css"],
  content: {
    experimental: { sqliteConnector: "native" },
    build: {
      markdown: {
        toc: { depth: 3 },
        highlight: {
          // Code is set on a dark ground in both themes.
          theme: "github-dark",
          langs: ["kotlin", "bash", "powershell", "properties", "json", "sql", tala],
        },
      },
    },
  },
  app: {
    head: {
      htmlAttrs: { lang: "en-US", dir: "ltr" },
      meta: [
        { charset: "utf-8" },
        { name: "viewport", content: "width=device-width, initial-scale=1" },
        { name: "theme-color", content: "#032f39" },
      ],
      link: [{ rel: "icon", type: "image/svg+xml", href: "/favicon.svg" }],
      script: [{ innerHTML: theme, tagPosition: "head" }],
    },
  },
  nitro: {
    prerender: {
      crawlLinks: true,
      routes: [...routes, "/sitemap.xml"],
      failOnError: true,
    },
  },
  typescript: { strict: true },
});