Skip to content

Custom vue component in markdown needs to declare a static asset from prop #4619

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

You must be logged in to vote

You can manually specify ?url for now I guess - https://stackblitz.com/edit/vite-bukpxmwg?file=docs/index.md,docs/.vitepress/config.ts

or update the logic of component to something like

const data = ref('')

onMounted(async () => {
  try {
    data.value = JSON.parse(props.src)
  } catch {
    data.value = await (await fetch(props.src)).json()
  } catch (e) {
    data.value = { error: e.message }
  }
})

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@brc-dd
Comment options

@victorpoughon
Comment options

@brc-dd
Comment options

@brc-dd
Comment options

Answer selected by victorpoughon
@victorpoughon
Comment options

@victorpoughon
Comment options

@victorpoughon
Comment options

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