_scripts/generate-search.mjsimport fs from 'fs'import path from 'path'import { fileURLToPath } from 'url'import { JSDOM } from 'jsdom'import { slugifyWithCounter } from '@sindresorhus/slugify'const __dirname = path.dirname(fileURLToPath(import.meta.url))// Get category slugs from _data/_blog.jsonfunction getCategorySlugs() {const blogJsonPath = path.resolve(__dirname, '../_data/_blog.json')if (!fs.existsSync(blogJsonPath)) {console.warn('Blog data not found: _data/_blog.json')return []}try {const content = fs.readFileSync(blogJsonPath, 'utf8')const posts = JSON.parse(content)
Showing the first 20 lines.
Get full code