#!/usr/bin/env node /** * LLM Documentation Generator * * Generates clean markdown files from MDX pages for LLM indexing. * Creates: * - public/llms/*.md - Clean markdown versions of each page * - public/llms.txt - Index file linking to all pages */ import fs from 'fs'; import path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT_DIR = path.join(__dirname, '..'); const PAGES_DIR = path.join(ROOT_DIR, 'src/pages'); const OUTPUT_DIR = path.join(ROOT_DIR, 'public/llms'); const LLMS_TXT_PATH = path.join(ROOT_DIR, 'public/llms.txt'); // Base URL for the docs site const BASE_URL = 'https://docs.netbird.io'; /** * Strip JSX/React components from MDX content, keeping clean markdown */ function stripJsx(content) { let result = content; // Remove import statements result = result.replace(/^import\s+.*?[;\n]/gm, ''); // Remove export statements (but keep the content if it's a description) result = result.replace(/^export\s+const\s+description\s*=\s*(['"`])(.+?)\1;?\s*$/gm, ''); result = result.replace(/^export\s+.*?[;\n]/gm, ''); // Remove JSX self-closing tags like ,