generate-search.mjs

_scripts/generate-search.mjs
import 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.json
function 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

Support

Talk to the developers of this project to learn more

We have been building professional websites for big clients for over 15 years. Gallop templates and blocks is our best foundation for SEO websites and web apps.

© 2026 Web Plant Media, LLC