Replies: 1 comment 2 replies
-
In your ::CustomHtml
<div class="some-div">Some div</div>
::
::Script
const el = document.querySelector('.some-div')
el.addEventListener('click', e => {console.log('clicked')})
:: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using nuxt content version 2 which comes with nuxt 3 and I have a blog setup. The articles use markdown files and they have a component system where you can use a vue component in markdown.
If I create an article sometimes I need custom html rendered and the thing that was getting annoying was for every article, if I needed a demo, I had to create a component each time.
I thought it would be better to create a general component that I can pass a script and html into but I can't get the script to execute.
take this code for example in
some-post.md
and in the components folder we have the following code in the
<CustomHtml />
component:This works just fine and it's quite useful. The advantage to this is maybe you want a grid setup, here you can just code the grid in html and it will be correctly outputted.
But how can we add javascript to this?
How could this be accomplished from the markdown file?
some-post.md
Beta Was this translation helpful? Give feedback.
All reactions