Skip to content

Library exports a server JLink component #753

Description

@romain-pm

Part of #749. The component over getLinkProps. Server-only.

<JLink node={props["j:linknode"]} className={classes.cta}>{label}</JLink>
  • Renders a bare <a>: no class, no wrapper, no styling opinion — the same stance as <JImage>.
  • JLinkProps is a discriminated union over node | content | href, so "exactly one of" is a type error rather than prose, and the href branch requires children or aria-label. An anchor with no accessible name is a WCAG 2.4.4 failure, and it is the real analogue of JImage's required alt.
  • whenUnresolved: "children" (default) renders the children unwrapped, "none" renders nothing. Not named fallbackJImage's fallback is a static-asset URL, and the two components are presented as a matched pair.
  • Never an <a> without href. That is what luxe's CTA produces today, and its test asserts the resulting <a>Broken</a>.
  • Emits aria-current="page" from state.isCurrent. No LinkState key reaches the DOM — assert this in a unit test, so a field added later cannot leak.
  • Arbitrary children, so <JLink node={target}><JImage node={cover} alt={alt} /></JLink> works — core's jnt:imageReferenceLink family, which Digitall ships instances of.
  • All other anchor attributes pass through untouched (onClick, aria-label, hreflang, lang, download).
  • Importing it from a client bundle already fails at build time (vite-plugin/src/index.ts:214-221, :316-321). Make sure the error names JLink's server-only status and points at getLinkProps + <a {...anchor}>.
  • Naming: JLink, for the same reason <JImage> is not <Image>.

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