wordpress-rest-apiastrojs

Converting Ampersand from Wordpress Rest API in Astro dynamic routes


I want to build a static website with Astro and WordPress as CMS. I get the categories via WordPress Rest API. One category has an ampersand in its name. "This & That". The API response for the name is "This & That"

Is there a possibility in Astro to convert the special character before rendering it?


Solution

  • You can use set:html to treat the content as HTML. Make sure you trust the provider of the content when using this.

    <p set:html={category.name}/>