支持 Markdown 动态渲染
linpengteng opened this issue · comments
lin commented
Is your feature request related to a problem? Please describe.
例如:
-
当我部署在 github 渲染显示如下内容
git clone https://github.com/username/xxxx.git
-
当我部署在 gitee 渲染显示如下内容
git clone https://gitee.com/username/xxxx.git
Describe the solution you'd like
Support:
```md {render=window.location.href.start('https://github.com')} git clone https://github.com/username/xxxx.git ```
```md {render=window.location.href.start('https://gitee.com')} git clone https://gitee.com/username/xxxx.git ```
Describe alternatives you've considered
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the docs.
- Read the Contributing Guidelines.
- Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
Divyansh Singh commented
That needs too much of architecture change and SSR won't work for those parts defeating the main purpose of VitePress.
You can use something like this instead: https://vitepress.dev/guide/using-vue#unescape-in-code-blocks
```sh-vue
git clone {{ gitUrl }}
```
<script setup lang="ts">
import { onMounted, ref } from 'vue'
const gitUrl = ref('')
onMounted(() => {
if(window.location.href.start('https://gitee.com') {
gitUrl.value = 'https://gitee.com/username/xxxx.git'
} else {
gitUrl.value = 'https://github.com/username/xxxx.git'
}
})
</script>
lin commented
thank you, it is worked.