highlighter

tcmts.site.highlighter · #iuxv26hb · term · 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 { highlighters, LANGS } from "#codebase/tcmts/site";
import type { Highlighter } from "#codebase/tcmts/site";
import { createHighlighter } from "shiki";

export function highlighter(): Promise<Highlighter> {
  let h = highlighters.get("site");
  if (!h) highlighters.set("site", (h = createHighlighter({ themes: ["github-light", "github-dark"], langs: LANGS })));
  return h;
}

uses

used by