Can I render a different md file based on query string param? #4281
Unanswered
johnsimons
asked this question in
Q&A
Replies: 1 comment 2 replies
-
You can use vue inside markdown, so something like this is possible: <template v-if="version === 'core_7'>
# license for core_7
</template>
<template v-if="version === 'core_9'>
# license for core_9
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
const version = ref('')
onMounted(() => {
version.value = (new URLSearchParams(window.location.search)).get('version')
})
</script> If you think the file is getting big, you can move the markdown parts to different files and include or import them. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My use can is that I am trying to convert an existing website that uses query strings to render different versions of the documentation.
The website I am trying to migrate is https://docs.particular.net.
So, for example, https://docs.particular.net/nservicebus/licensing/?version=core_7 a version but https://docs.particular.net/nservicebus/licensing/?version=core_9 renders a different version.
I want the sidebar item to stay active.
This is different from regular versioning of a single product, because this website contains many different"products", so we allow versioning at the page level.
I hope this makes sense, let me know.
Beta Was this translation helpful? Give feedback.
All reactions