highlighter

tcmts.site.highlighter · #tcj5m5x5 · function · runs anywhere

The code highlighter: a light and a dark theme, as CSS variables, so the colours follow the system like the rest of the page.

import { shiki } from "#codebase/tcmts/content";
import type { Highlight } from "#codebase/tcmts/content";
import { highlighters, LANGS } from "#codebase/tcmts/site";

export function highlighter(): Promise<Highlight> {
  let h = highlighters.get("site");
  if (!h) highlighters.set("site", (h = shiki({ langs: LANGS, defaultColor: false })));
  return h;
}

uses

used by