Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
TypeScript
at feat/nuxt-v5
12345678910111213141516171819202122232425import type { RouteLocationNormalized, RouteRecordNormalized } from 'vue-router'import { match } from './routes'
export default defineNuxtRouteMiddleware((to, from) => { const path = to.path const matched = match(path) Object.assign(to.meta, matched?.meta) augmentMatched(from) augmentMatched(to) if (matched?.path instanceof RegExp) { to.params = (path.match(matched.path)?.groups as Record<string, string>) || {} }})
function augmentMatched (route: RouteLocationNormalized) { route.matched = [ { components: { default: match(route.path)?.component.__asyncResolved?.__name, }, } as any as RouteRecordNormalized, ]}