_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 post URL paths from _data/_blog.json (preferred) or src/blog/*.tsxfunction getPostSlugs() {const blogJsonPath = path.resolve(__dirname, '../_data/_blog.json')if (fs.existsSync(blogJsonPath)) {try {const posts = JSON.parse(fs.readFileSync(blogJsonPath, 'utf8'))if (Array.isArray(posts) && posts.length > 0 && posts[0].url) {return posts.map((p) => (p.url || '').replace(/^\//, '')).filter(Boolean)}} catch (err) {
Showing the first 20 lines.
Get full code