Best way to retrieve frontmatter from the next page #4831
-
| I'm looking to assess the frontmatter of an incoming page using the Additionally, if you know a method to load the HTML content of the next page, that would be very helpful! Thank you very much in advance |
Beta Was this translation helpful? Give feedback.
Answered by brc-dd Jul 8, 2025
Replies: 1 comment 5 replies
-
| Hmm page is loaded after route change. So, hard to get it that way. Maybe you can extract the relevant data to a separate file (maybe createContentLoader) and do something like this: // .vitepress/theme/index.ts import type { Theme } from 'vitepress' import DefaultTheme from 'vitepress/theme' import { data } from '../../frontmatter.data.js' export default { extends: DefaultTheme, enhanceApp({ router }) { router.onBeforeRouteChange = (to) => { const frontmatter = data[to] } } } satisfies Theme |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by BenjaminOddou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Hmm page is loaded after route change. So, hard to get it that way. Maybe you can extract the relevant data to a separate file (maybe createContentLoader) and do something like this: