Skip to content

Can I render a different md file based on query string param? #4281

Answered by brc-dd
johnsimons asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@johnsimons
Comment options

@brc-dd
Comment options

@johnsimons
Comment options

@brc-dd
Comment options

@johnsimons
Comment options

Answer selected by johnsimons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants