We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 59691eb commit a786be3Copy full SHA for a786be3
1 file changed
app/components/Code/Viewer.vue
@@ -57,6 +57,31 @@ watch(
57
},
58
{ immediate: true },
59
)
60
+
61
+// Use Nuxt's `navigateTo` for the rendered import links
62
+function handleImportLinkNavigate() {
63
+ if (!codeRef.value) return
64
65
+ const anchors = codeRef.value.querySelectorAll('a.import-link')
66
+ anchors.forEach(anchor => {
67
+ // NOTE: We do not need to remove previous listeners because we re-create the entire HTML content on each html update
68
+ anchor.addEventListener('click', event => {
69
+ const href = anchor.getAttribute('href')
70
+ if (href) {
71
+ event.preventDefault()
72
+ navigateTo(href)
73
+ }
74
+ })
75
76
+}
77
78
+watch(
79
+ () => props.html,
80
+ () => {
81
+ nextTick(handleImportLinkNavigate)
82
+ },
83
+ { immediate: true },
84
+)
85
</script>
86
87
<template>
0 commit comments