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

Consider consolidating common render logic for Contentful rich text documents #35

Open
toolness opened this issue Jun 25, 2021 · 0 comments

Comments

@toolness
Copy link
Contributor

toolness commented Jun 25, 2021

We added contentful-common-strings in #32 but looking at the two external PRs that use it, JustFixNYC/who-owns-what#482 and JustFixNYC/tenants2#2125, it's apparent that we have some repeated code of the following form, which is used to ensure that hyperlinks always open in new tabs:

mport { RenderNode } from "@contentful/rich-text-react-renderer";

const RENDER_NODE: RenderNode = {
  [INLINES.HYPERLINK]: (node, children) => (
    <a rel="noreferrer noopener" target="_blank" href={node.data.uri}>
      {children}
    </a>
  ),
};

We might want to put this in a package, but it's unclear which package that should be: do we want to use contentful-common-strings, which currently has no dependency on React or @contentful/rich-text-react-renderer, or do we want to use react-common, which already depends on React and can also be used outside the context of the Contentful common strings concept (which might be useful since this renderer isn't necessarily specific to common strings)? Or do we want to make a brand-new package?

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