From 9d1ccace1050a3f94dcfecf12e3cf625998a2117 Mon Sep 17 00:00:00 2001 From: Christian Georgi Date: Wed, 5 Aug 2026 15:10:16 +0200 Subject: [PATCH] Export slugify function --- .vitepress/config.js | 6 ++---- .vitepress/lib/slugify.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .vitepress/lib/slugify.ts diff --git a/.vitepress/config.js b/.vitepress/config.js index d8e16645a..298b5b49e 100644 --- a/.vitepress/config.js +++ b/.vitepress/config.js @@ -8,6 +8,7 @@ import { fileURLToPath } from 'node:url' import { defineConfig } from 'vitepress' import languages from './languages' import playground from './lib/cds-playground/index.js' +import { slugify } from './lib/slugify.ts' import { Menu } from './menu.js' const __dirname = dirname(fileURLToPath(import.meta.url)) @@ -46,10 +47,7 @@ const config = defineConfig({ }, anchor: { // VS Code-compatible GitHub-style slugifier (mirrors markdown-language-features/src/slugify.ts) - slugify: (str) => str - .trim().toLowerCase() - .replace(/[^\p{L}\p{N}\p{M}\s_-]/gu, '') - .replace(/\s/g, '-'), + slugify, }, container: { // Doesn't seem to work yet infoLabel: 'Info', diff --git a/.vitepress/lib/slugify.ts b/.vitepress/lib/slugify.ts new file mode 100644 index 000000000..9ab18a23c --- /dev/null +++ b/.vitepress/lib/slugify.ts @@ -0,0 +1,8 @@ +// VS Code-compatible GitHub-style slugifier (mirrors markdown-language-features/src/slugify.ts). +// Used as VitePress' markdown anchor slugifier, and reused to derive heading anchors elsewhere (e.g. llms-full.txt). +export function slugify(str: string): string { + return str + .trim().toLowerCase() + .replace(/[^\p{L}\p{N}\p{M}\s_-]/gu, '') + .replace(/\s/g, '-') +}