I have created a blog website with Prismic(headless CMS)/Astro/vanilla JS and one of the data fields that is brought to my website is a RichText field. I have formatted the RichText on Prismic side(with difficulty, editor needs some improvement). My website currently brings in the content just fine, and renders it, however when the content comes in and is rendered into HTML, it looses a lot of its formatting and looks pretty rough. I have looked at the Prismic documentation to figure out a way to format received content using the serializer to put classes on my elements that are brought in, so I can help format on website side. The "vanilla JS" documentation is frustrating as it has areas with deprecated content that is no longer supported or advised ( ie. importing @prismicio/helpers to help with RichText). I have looked through the documentation and can't seem to get the serializer to work as intended, I have tried different variations of serializer just to be able to put css classes on element types to better format. I have tried using many different variations based on documentation (some might be deprecated) to no avail. I have tried using serializer function with parameters (elements, children,node,content) and then added serializer as 2nd parameter to my prismic.asHTML(...,{serializer:customSerializer}) with nothing working. As of the current version of Prismic, what is the recommended way of handling RichText manipulation on client side using vanilla JS? Is serializer still the best method for adding custom classes to HTML elements brought in from RichText field API calls? Thanks for reading
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
Line breaks in rich text fields | 7 | 4670 | November 9, 2022 | |
How do I remove wrapping div from prismic-rich-text | 4 | 1437 | December 9, 2021 | |
Bold text formatting not shown on live page | 6 | 869 | December 9, 2021 | |
Render RichText without any p tags | 5 | 448 | December 9, 2021 | |
Query API and get the HTML for rich text | 1 | 299 | July 13, 2023 |