Skip to content

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

Description

@toolness

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions