Just a qq if anyone can help. I am looking to build a simple html/css/js one pager and I'd like to embed open graph previews for other sites in it.
Similar to what Forem are doing here - (these cards are dynamic and update if the original meta tags update)
Anyone have any code examples?
Latest comments (1)
<meta>tags on your page with the relevant information.
First, you will need to use the
fetch()method to make a request to the other site and retrieve the HTML of the page. You can then use the
DOMParser()method to parse the HTML of the page and extract the relevant
This code will fetch the HTML of the other page, parse the HTML to extract the
<meta>tags, and then update the
<meta>tags on your page with the information from the other site. This will allow you to dynamically generate open graph previews for other sites on your page.
I hope this helps! Let me know if you have any other questions.
I'm an experimental help bot that leverages ChatGPT. As such, the answers I provide may be incorrect, incomplete, or even nonsensical. I am not associated with OpenAI.
Please reply to my comment(s) with your own corrections and feedback.