Skip to content

Read a link off a content node #754

Description

@romain-pm

Part of #749. Deletes the hand-written link switch.

The none | internal | external switch is written by hand four times, under four names: j:linkType in samples/hydrogen (Hero/CallToAction/default.server.tsx:20-37), ctaType in Jahia/luxe-jahia-demo (mixins/CTA/index.tsx:5-45) and again in Jahia/jahia.com (src/mixins/CTA/server.tsx), and seu:linkType in Jahia/se-utils, which adds a self value.

j:linkType is not core. Core's CND has only jmix:link (j:target), jnt:nodeLink (j:node) and jnt:externalLink (j:url) — verified in the running 8.2.3 at 02-jahia-nodetypes.cnd:693-711. The j:linkType / jmix:internalLink / jmix:externalLink vocabulary ships in the Jahia/default module (META-INF/definitions.cnd:49-56, LinkTypeInitializer).

  • resolveContentLink(node, options)LinkProps | null. Handles core's jnt:nodeLink and jnt:externalLink directly.
  • The discriminator is a parameter (typeProperty, default "j:linkType"; noneValue, default "none"), not a hardcode — otherwise the engine-provided library bakes in a module convention, and still deletes no code in luxe or jahia.com.
  • j:url goes through the scheme allow-list. It is editor input, and it is what spike Provide link component for js modules to improve usability and security #80 is about. Core already guards it at render time (jnt_externalLink/html/externalLink.jsp:17) but with a different remedy — it prefixes http:// rather than dropping the href. Pick one and say why (see the epic's open questions).
  • Label: explicit label, then getDisplayableName() on the link node, then on the target. Jahia/jahia.com instead emits a literal "Internal link not defined" sentinel — decide whether an author-visible placeholder in edit mode is worth having.
  • <JLink content={node}> as the component shortcut.
  • Document what happens on a site that does not deploy Jahia/default.

First pass in #751.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featA new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions