I need to use oEmbed in NUXT. How to use this plugin called Embed.js in NUXT? This is from their GitHub:
// You need to use plugins or presets to do anything. By default embed-js does nothing. Let's assume that the HTML structure is as written below
<div id="element">
<!--===== your string here =======-->
</div>
// Creating an instance of embed.js
import EmbedJS from 'embed-js'
import url from 'embed-plugin-url'
import emoji from 'embed-plugin-emoji'
const x = new EmbedJS({
input: document.getElementById('element'),
plugins: [
url(),
emoji()
]
})
</div>
// Next step is replacing the original text with the processed text.
//Render the result
x.render();
</div>
// There may be cases where you just want the processed string to use it according to your need. You can get it by the following method. This can be used on the server side to get the string. Still if the plugin involves interactions, you will have to load it on the client side.
// Get the resulting string
x.text().then(({ result }) => {
console.log(result); //The resulting string
})
</div>
// If you wan't to destroy the instance. It will also replace the processed string with the original string.
//Destroy the instance
x.destroy()
I already added the Embed.js file to the plugins folder of NUXT but I'm stuck on how to generate the component.