Open
Description
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 production
helloPlugins.ts
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
export default defineUserConfig({
plugins: [
helloPlugin(),
],
})
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
file
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>
additional info
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.
I remembered when vuepress was beta ,the second solution works well.
Reproduction
https://github.com/yzqbugs/vuepress-bugs
Used Package Manager
yarn
System Info
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