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

Custom attributes on links not resolved #150

Open
scarlachs opened this issue Nov 22, 2024 · 0 comments
Open

Custom attributes on links not resolved #150

scarlachs opened this issue Nov 22, 2024 · 0 comments

Comments

@scarlachs
Copy link

scarlachs commented Nov 22, 2024

The bug only happens when using the package @storyblok/richtext, in the deprecated package @storyblok/react it works as expected.


Expected Behavior

Custom attributes on links should be added correctly to the a tag, e.g. : <a href="https://www.storyblok.com" target="_self" rel="nofollow noopener">https://www.storyblok.com</a>

Current Behavior

The custom attributes are added as object to the custom attribute, e.g.: <a custom="[object Object]" target="_self" href="https://www.storyblok.com">https://www.storyblok.com</a>

Steps to Reproduce

  1. Story with a richtext field
  2. In the richtext have a link with some custom attributes like "rel: nofollow noopener"
  3. Render the richtext and inspect output
import {
    richTextResolver,
    type StoryblokRichTextOptions,
} from "@storyblok/richtext";
import React from "react";

const options: StoryblokRichTextOptions<React.ReactElement> = {
    renderFn: React.createElement,
    keyedResolvers: true,
};

const { render } = richTextResolver<React.ReactElement>(options);

function Richtext({ blok }: { blok: any }) {
    return (
        <section>
            {render(blok.richtext)}
        </section>
    );
}

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

No branches or pull requests

1 participant