import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify'; import * as fs from 'fs'; import * as path from 'path'; let cachedNavbar: string | null = null; function getNavbarHTML(activePage: string, showSearch: boolean = true): string { if (!cachedNavbar) { const navbarPath = path.join(__dirname, '..', '..', 'views', 'components', 'navbar.html'); cachedNavbar = fs.readFileSync(navbarPath, 'utf-8'); } let navbar = cachedNavbar; const pages = ['anime', 'books', 'gallery', 'schedule' , 'marketplace']; pages.forEach(page => { const regex = new RegExp(`(