const express = require('express'); const router = express.Router(); const contentService = require('../services/content'); router.get('/:slug', (req, res, next) => { const pagePath = `/${req.params.slug}`; const page = contentService.getPage(pagePath); if (!page) { return next(); // Fall through to 404 } res.locals.seo = { title: `${page.title} - ${res.locals.site.title}`, description: page.frontmatter.description || res.locals.site.tagline, canonicalUrl: `${res.locals.site.url}${pagePath}`, ogImage: res.locals.seo.ogImage, type: 'website' }; const layout = page.layout === 'home' ? 'pages/home' : 'pages/page'; res.render(layout, { title: page.title, page }); }); module.exports = router;