Replies: 1 comment 1 reply
-
@Karlstens Did you find a solution for this? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm very new to VitePress and learning the ropes, and enjoying many aspects of this fantastic project.
After reading through the available documentation that I could find, I was still stuck on a method of introducing global parameters into my docs. Perhaps I missed a chapter, or misunderstood the guides I've been reading... regardless, I set out this morning to resolve a workflow that at least allows me to move forward with a solution, albeit a hack-solution at that (or maybe it;s a perfectly acceptable one? 😁 )
This is a module I created that does a word-for-word swap during dev/build process. Here, you can see what I consider global parameters such as "$appversion", "$animal" and "$colour", with the intent for them to swapout with the value they've been assigned, "1.0.0", "Cat" and "Blue".
..vitepress\enhanceMarkdown.mjs
I import my enhanceMarkdown.mjs file into my vitePress config as such;
./.vitepress/config.mjs
And I author my markdown content, including the global variables where I need them.
Which renders as;
My question, is this the way to go about working with vitepress when it comes to setting up global parameters / global variables in a vitepress project? Or, am I actually building a mountain out of a molehill for what I assumed to be an out-of-the-box feature that I've somehow missed, and there's actually a far simplier method to implement this?
Side quest: Assuming that what I've created is one way of resolving the problem, perhaps there's actually a better/simpler way to resolve this same requirement for global parameters?
Edit: Also worth noting this method so that the values can return as expected within a Codeblock.
https://vitepress.dev/guide/using-vue#unescape-in-code-blocks
Beta Was this translation helpful? Give feedback.
All reactions