Incognito-Wiki/src/starlight-route-data.ts
2026-08-16 12:03:59 +02:00

10 lines
468 B
TypeScript

import { defineRouteMiddleware } from '@astrojs/starlight/route-data';
import { filterResolvedSidebar } from './config/programme-navigation.mjs';
export const onRequest = defineRouteMiddleware((context, next) => {
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
const pathname = context.url.pathname.replace(base, '');
const route = context.locals.starlightRoute;
route.sidebar = filterResolvedSidebar(route.sidebar, pathname);
return next();
});