vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

I encountered regarding rewrites. #3596

Closed admin8756 closed 1 month ago

admin8756 commented 2 months ago

Describe the bug

In the rewrites configuration,

I mistakenly set 'test.md': '/pages/teste1.md' instead of 'test.md': 'pages/test1.md'.

This error allows the page to load correctly in the development environment but results in a 404 error upon refreshing.

I acknowledge this as a simple mistake that caused me two days of confusion.

I believe it would be helpful to have a validation check to catch such errors and provide a clear error message. Additionally, the rewrite rule works in development but fails in production.

I am unsure if this usage is correct. Could you please review my demo for further assistance?

demo

My project is a blog.

I can access it through a new URL, but when navigating, the page still uses the old URL.

This behavior is abnormal.

Please check the homepage The branch page cannot be navigated properly from the homepage

although the branch page is actually accessible.

Reproduction

demo

Expected behavior

I expect that all pages should function normally when navigating, and that the behavior should be consistent between production and development environments.

System Info

node v16.20.2

chrome:121.0.6167.86

vitepress:1.0.0-rc.44

os:windows

Additional context

No response

Validations

admin8756 commented 2 months ago

Hey guys, my issue still hasn't been resolved @brc-dd @kiaking @posva

admin8756 commented 1 month ago

我已经通过其他方法解决了这个问题

admin8756 commented 1 month ago

c07f2dda864ea5b06b77efe12a01af7 c22c2775062077e38395471f9aa3aa2 vitepress提供了一个withBase方法。我在它的前边再用一个方法修饰。然后通过生成的文件。直接进行替换。 这样打包的时候就会替换为短连接了 e8ab4f3b71b401fd247ddbe6945962e 这边会通过这个方法生成短连接。如果没有生成。就是长链接