File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,31 @@ watch(
5757 },
5858 { immediate: true },
5959)
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+ )
6085 </script >
6186
6287<template >
You can’t perform that action at this time.
0 commit comments