We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://v2.vuepress.vuejs.org/advanced/cookbook/adding-extra-pages.html
use plugin api to create a extra page /hello, and it's not found when in dev and production helloPlugins.ts
/hello
import { createPage, type Page, type PluginFunction } from "vuepress/core"; export const helloPlugin = (options?:any): PluginFunction => (app) => { console.log("hello"); return { name: "hello", async onInitialized(app) { const helloPage = await createPage(app, { path: "/hello", frontmatter: { title: "hello" }, content: `\ # 欢迎来到 ${app.options.title} 这是 hello `, }); app.pages.push(helloPage); console.log(app.pages); }, }; };
register in config.ts
config.ts
export default defineUserConfig({ plugins: [ helloPlugin(), ], })
A /hello route is expected, but it is 404 link reproduction repo repo
https://v2.vuepress.vuejs.org/advanced/cookbook/usage-of-client-config.html use client config to add a route this client.ts file
client.ts
import Hello from './component/Hello.vue'; export default defineClientConfig({ enhance({ app, router, siteData }) { app.component("Hello", Hello); router.addRoute({ path: "/hi", name: "hi", component: Hello, }); }, })
Hello.vue
<template> <div> <p>hello</p> </div> </template> <script setup lang="ts"> </script> <style scoped> </style>
I see the .vuepress/.temp/pages folder has a hello.html.vue file, it's content is very well ,while in /hello route ,it's not found.
.vuepress/.temp/pages
hello.html.vue
I remembered when vuepress was beta ,the second solution works well.
https://github.com/yzqbugs/vuepress-bugs
yarn
System: OS: Windows 10 10.0.19045 CPU: (8) x64 AMD Ryzen 5 3400G with Radeon Vega Graphics Memory: 10.77 GB / 31.95 GB Binaries: Node: 22.0.0 - ~\AppData\Local\Temp\xfs-9423c53a\node.CMD Yarn: 4.1.1 - ~\AppData\Local\Temp\xfs-9423c53a\yarn.CMD npm: 10.5.1 - C:\Program Files\nodejs\npm.CMD pnpm: 9.0.6 - D:\scoop\shims\pnpm.EXE bun: 1.1.4 - D:\scoop\shims\bun.EXE Utilities: Git: 2.43.0. Browsers: Chrome: Not Found Edge: Chromium (123.0.2420.97), ChromiumDev (123.0.2420.10) npmPackages: @vuepress/bundler-vite: ^2.0.0-rc.9 => 2.0.0-rc.9 @vuepress/bundler-webpack: Not Found @vuepress/cli: 2.0.0-rc.9 @vuepress/client: 2.0.0-rc.9 @vuepress/core: 2.0.0-rc.9 @vuepress/markdown: 2.0.0-rc.9 @vuepress/shared: 2.0.0-rc.9 @vuepress/utils: 2.0.0-rc.9 vue: 3.4.25 vue-router: 4.3.2 vuepress: next => 2.0.0-rc.9
The text was updated successfully, but these errors were encountered:
/hello.html
Sorry, something went wrong.
It works for extra page, thank you.
2.0.0-rc.2
I just downgrade vuepress to 2.0.0-rc.2 the function router.addRoute to add a route works. while update to 2.0.0-rc3 the added route is not found
router.addRoute
2.0.0-rc3
repo
export default defineClientConfig({ enhance({ app, router, siteData }) { app.component("Hello", Hello); router.addRoute({ path: "/hi", name: "hi", component: Hello, }); }, });
the router.addRoute added page (vuepress version 2.0.0-rc.2) https://yzqbugs.github.io/vuepress-bugs/hi
the #1447 custom routes pr seems to break common usage
https://stackblitz.com/edit/vuepress-ccylja?file=docs%2F.vuepress%2Fclient.ts,docs%2F.vuepress%2FHello.vue,docs%2FREADME.md
click the to hi page button , /hi not found
to hi page
/hi
Again, /hi.html, if you need these clean urls, then you must override resolveRoutePath to pervent it being normalized to /hi.html
/hi.html
cc @meteorlxy Maybe we should add extra check with a clean URL edition when the original route path not found.
meteorlxy
Successfully merging a pull request may close this issue.
Description
use extra page or client config to define a route not working
use extra pages
https://v2.vuepress.vuejs.org/advanced/cookbook/adding-extra-pages.html
use plugin api to create a extra page
/hello
, and it's not found when in dev and productionhelloPlugins.ts
register in
config.ts
A /hello route is expected, but it is 404 link
reproduction repo repo
use vue-router
https://v2.vuepress.vuejs.org/advanced/cookbook/usage-of-client-config.html
use client config to add a route
this
client.ts
fileHello.vue
additional info
I see the
.vuepress/.temp/pages
folder has ahello.html.vue
file, it's content is very well ,while in/hello
route ,it's not found.I remembered when vuepress was beta ,the second solution works well.
Reproduction
https://github.com/yzqbugs/vuepress-bugs
Used Package Manager
yarn
System Info
The text was updated successfully, but these errors were encountered: