Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Add <img> tag support to rich-text-html-parser using Caisy's Assets #8

Open
dallyh opened this issue Apr 2, 2024 · 0 comments

Comments

@dallyh
Copy link

dallyh commented Apr 2, 2024

Hello,

Would it be possible to add support for <img> tags inside rich-text-html-parser for linked documents, which are Caisy assets? This would probably require passing connections with the rich text JSON, and generating the <img> tag with the help of connections like in other libraries:

{
    connections &&
        connections.map((component: any) => {
            if (component?.__typename === "Asset" && node?.attrs?.documentId === component.id) {
                return <Asset {...component} />;
            }
            return null;
        })
}

Motivation is that this library can be used (as I'm using it) to render HTML content for RSS feeds with frameworks that dont support rendering components to HTML like Astro (see here). Of course there are workarounds (for Astro), like using React for such things, but this for me looks like overkill, just to get the HTML for RSS feed.

Currently the library has an extension for document link, which adds a tag of <connection data-document-id="{GUID}"></connection> to the outputted HTML. This currently cannot be altered in a meaningful way from my perspective, apart from modifying the HTML itself - that is creating a DOM/tree from the HTML and modifying it.

One alternative could also be to expose something to overwrite the document link tags like in other provided rich text libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant