vuejs / vitepress

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

Reference the current page to a shared file #4136

Closed xsjcTony closed 3 months ago

xsjcTony commented 3 months ago

Is your feature request related to a problem? Please describe.

Imagine the case I want two different route show the exact same content, and I want to store that .md file someone else for reference from those 2 routes

Describe the solution you'd like

Files:

However, I want /category-1/bar and /category-2/baz to show exactly the same content as stored in /docs/shared/foo.md

I can use srcExclude to not generate the route for /shared/foo, but there's no way I can make route /category-1/bar and /category-2/baz to show the content of /docs/shared/foo.md

Describe alternatives you've considered

Maybe we can have something in the frontmatter to makes it work like this:

---
reference: ../shared/foo.md
---

Additional context

No response

Validations

brc-dd commented 3 months ago

https://vitepress.dev/guide/markdown#markdown-file-inclusion ?

xsjcTony commented 3 months ago

Seems solid, the title is a bit different as I thought so I didn't found it🤣.

Just want to confirm that as long as I put the shared folder into srcExclude, it will not generate the route right? And will it get parsed if it's referenced from another file if it's in srcExclude?

I'll give it a try tomorrow anyway, if everything works well, I'll close this. Thanks!

brc-dd commented 3 months ago

Just want to confirm that as long as I put the shared folder into srcExclude, it will not generate the route right? And will it get parsed if it's referenced from another file if it's in srcExclude?

Yes.

xsjcTony commented 3 months ago

Tried it today, works perfectly. Thanks!