-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic routes do not get generated with build #160
Comments
Maybe try to use the |
Even it that works there are pages I want to be rendered (redirect links) that I do not want to appear in the sidebar or nav menu. We need a way to add extra routes through the config and via themes for this to work fully. |
util.js |
@Bloss utils.js or app.js? Not that it matters both of them are client-side scripts and the problem is with the server-side prerendering. There is no problem with adding new routes in the client-side applications - they work as expected when in dev or SPA mode. The problem is when you go to build the app the server-side it does not know about the extra routes and so does not prerender the pages. This results in a 404 when you first hit them (but then work if you navigate to them once in SPA mode). |
According to the following code, what should be rendered is determined by the Lines 63 to 67 in f0b33e1
The original routes file is generated from Lines 277 to 307 in f0b33e1
Although your add routes to |
To make things clear: Current In In |
@meteorlxy , not sure if this is what you meant, but when I tried this in const p = siteData.pages.find(({path}) => path === '/guide/assets.html')
const c = {...p}
c.path = '/guide/assets/index.html'
siteData.pages.push(c)
console.log('c', c)
let r = router.options.routes.find(({path}) => path === '/guide/assets.html')
const rNew = {...r}
rNew.path = '/guide/assets/index.html'
router.options.routes.push(rNew)
console.log(rNew) edit: i see now, you were pointing out the reason why this didn't work, nvm! |
It will work in edit: yes I was pointing out the reason, but your code is not correct and won't work even in |
@meteorlxy Hello! I am using the Vuepress Next version: |
@gcharang |
@meteorlxy i.e., I am looking for a more general type of redirect. |
@meteorlxy Thanks for your introduction, but @gcharang is right. 🤣 @gcharang I have been considering about supporting "a more general type of redirect" in |
@gcharang |
@shigma I will be sure to add a feature request. Thank you! @meteorlxy I tried using the "vuepress-plugin-dehydrate" plugin along with the |
Co-authored-by: meteorlxy <[email protected]>
You have access to the route via
.vuepress/enhanceApp.js
and can add extra routes such as:or
And they work as expected when you run it is dev mode
vurepress dev site
. But when building the appvurepress build site
the added routes do not get generated/prerendered, resulting in a 404 when trying to load the route for the first time.As far as I can tell there is no other way to add routes to the generated list of routes which means that routes cannot be added dynamically via the site or themes.
The text was updated successfully, but these errors were encountered: