You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
609 B
JavaScript

const matchPath = /(?<path>|.+)\/(?<filename>[-_\w]+)(?<filetype>|\/|\.html|\.md)$/;
export default ({
Vue, // the version of Vue being used in the VuePress app
options, // the options for the root Vue instance
router, // the router instance for the app
siteData // site metadata
}) => {
router.beforeEach((to, from, next) => {
if (!to.name) {
const { filename } = to.fullPath.match(matchPath).groups;
next(
siteData.pages
.find((page) => page.regularPath.match(matchPath)?.groups?.filename === filename)
?.regularPath
);
}
next();
});
}