-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[markdown-it] Internal links and nuxt router #14
Comments
Solved thanks ;) <template>
<div v-html="content">
</div>
</template>
<script>
export default {
props: ['content'],
mounted() {
this.addListeners()
},
beforeDestroy() {
this.removeListeners()
},
watch: {
'content': 'contentUpdated'
},
methods: {
navigate(event) {
const href = event.target.getAttribute('href')
if (href && href[0] === '/') {
event.preventDefault()
this.$router.push(href)
}
},
contentUpdated() {
this.removeListeners()
this.$nextTick(() => {
this.addListeners()
})
},
addListeners() {
this._links = this.$el.getElementsByTagName('a')
for (let i = 0; i < this._links.length; i++) {
this._links[i].addEventListener('click', this.navigate, false)
}
},
removeListeners() {
for (let i = 0; i < this._links.length; i++) {
this._links[i].removeEventListener('click', this.navigate, false)
}
this._links = []
}
}
}
</script> Should be intergrated in markdown-it module btw. |
Another problem now. With nuxt generate the content of the md file is not rendered in html, but in the js file. Is there a way to force the html rendering? Thanks |
Bump :) All pages js are in prefetch in every page's head... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I use nuxt with external .md files for the content and markdown-it parser.
Is it a way to catch internal links to use nuxt router instead of the generated regular links?
Thx
The text was updated successfully, but these errors were encountered: