vuejs / vitepress

Vite & Vue powered static site generator.

Home Page:https://vitepress.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

支持 Markdown 动态渲染

linpengteng opened this issue · comments

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

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>
commented

thank you, it is worked.