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 post URL paths from _data/_blog.json (preferred) or src/blog/*.tsx
function 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

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