block

links

Wire value: "links"

Appears on: Documentation Topic, Tutorial (Project), Tutorial Article

1. How swift-docc-render consumes this

Grepping src/components/ for the literal string 'links' lands, as with every other block/inline content kind on this reference site, on src/components/ContentNode.vue's wire-constant table (ContentNode.vue#L37-L54), whose links key holds BlockType.links = 'links'. That constant is matched in the renderNode() factory function's switch (node.type) dispatch table:

case BlockType.links: {
  return createElement(LinksBlock, {
    props: {
      blockStyle: node.style,
      identifiers: node.items,
    },
  });
}

(ContentNode.vue#L421-L428.) Both of the node's non-type wire fields are forwarded, renamed as props: style becomes blockStyle, and items (an array of reference identifier strings) becomes identifiers. The type discriminator itself is consumed only by the switch, never forwarded. LinksBlock is imported at the top of ContentNode.vue (ContentNode.vue#L31).

src/components/ContentNode/LinksBlock.vue is a small dispatcher itself, branching purely on the blockStyle prop's value against the list constant from TopicSectionsStyle:

<template>
  <div v-if="isListStyle" class="links-block">
    <TopicsLinkBlock
      v-for="item in items"
      :key="item.identifier"
      :topic="item"
      class="topic-link-block"
    />
  </div>
  <TopicsLinkCardGrid
    v-else
    class="links-block"
    :items="items"
    :topic-style="blockStyle"
  />
</template>

(LinksBlock.vue#L10-L25.) Before either branch renders, the identifiers prop (an array of bare reference-identifier strings) is resolved to full reference objects via the shared referencesProvider mixin, which injects the render node's top-level references map:

items: ({ identifiers, references }) => identifiers.reduce((all, identifier) => (
  references[identifier] ? all.concat(references[identifier]) : all
), []),

(LinksBlock.vue#L52-L54.) Identifiers that don't resolve in references are silently dropped rather than rendered as broken entries. If blockStyle === 'list', each resolved item becomes a TopicsLinkBlock (the same "declaration + abstract" row component used in an on-page Topics section, imported async here specifically "to overcome potential infinite loops from importing ContentNode inside" per the source comment, since TopicsLinkBlock.vue itself renders abstracts through ContentNode). For the two grid styles (compactGrid, the prop default, and detailedGrid), TopicsLinkCardGrid takes over, rendering a Pager wrapping a Row/Column grid of TopicsLinkCardGridItem cards (TopicsLinkCardGrid.vue#L11-L32). Notably, LinksBlock.vue never passes a usePager prop to TopicsLinkCardGrid, and that prop defaults to false (TopicsLinkCardGrid.vue#L70-L73), so for a links block defaultPageSize resolves to items.length (TopicsLinkCardGrid.vue#L77-L95) — i.e. every linked item is placed on a single page and the Pager's paging controls have nothing to page through in this context, even though the Pager component itself is still mounted around the grid.

See also: The references map — how this and every other reference-dictionary lookup works across kinds.

2. Example JSON and rendered mockup

No fixture containing a "type": "links" RenderNode node was found in Tests/DocCArchiveTests/Fixtures/ (only unrelated matches inside bundled, minified DocC-render JS assets) nor as JSON in swift-docc's test suite. However, Tests/SwiftDocCTests/Semantics/Reference/LinksTests.swift's testLinkResolution() does contain a genuine Swift-literal fixture — an expected RenderBlockContent.links(RenderBlockContent.Links(style: .compactGrid, items: [...])) value produced by compiling an authored @Links(visualStyle: compactGrid) { ... } directive against a real test bundle (LinksTests.swift#L187-L217). The example below is that fixture's second case, transcribed from the Swift literal into the equivalent wire JSON per the schema in Section 3 (exampleProvenance: fixture).

{
  "type": "links",
  "style": "compactGrid",
  "items": [
    "doc://org.swift.docc.example/documentation/MyKit/MyClass",
    "doc://org.swift.docc.example/documentation/MyKit/MyClass/myFunction()",
    "doc://org.swift.docc.example/tutorials/Test-Bundle/TestTutorial",
    "doc://org.swift.docc.example/documentation/Test-Bundle/article2"
  ]
}
Class MyClass
Instance Method myFunction()
Tutorial Test Tutorial

mockup: style: "compactGrid" routes to TopicsLinkCardGrid, which lays identifiers out as a Row/Column grid of TopicsLinkCardGridItem cards (title + role/kind icon, no abstract text since compact defaults to true for this style). A fourth, unresolved identifier would simply be omitted from the grid rather than shown as a broken card, per the items computed property in Section 1. If style were "list" instead, the same four identifiers would instead render as stacked TopicsLinkBlock rows — the same row style used in an on-page Topics list, including full declarations and abstracts.

3. Data sheet

Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object #/components/schemas/Links (lines 649–679), cross-checked against Components.Schemas.Links in Sources/DocCArchive/generated/Types.swift (lines 4011–4049). Links is one arm of the RenderBlockContent discriminated union that makes up a content array anywhere block content is allowed.

FieldTypeRequiredEnum values / defaultNote
type string yes "links" (single-value enum) Generated as _TypePayload: String, Codable, Hashable, Sendable, CaseIterable { case links = "links" }, decoded/encoded under the Swift property name _type via an explicit CodingKeys mapping (case _type = "type").
style string yes "list" | "compactGrid" | "detailedGrid"; no wire-level default (the JSON schema marks it required) Generated as StylePayload: String, Codable, Hashable, Sendable, CaseIterable with those three cases. DocC-render's own LinksBlock prop declares a client-side default of compactGrid for the blockStyle prop, but that only matters if the component were mounted without a style value at all — the wire schema itself always requires the field.
items array of string yes — (schema annotates each entry format: "reference(TopicRenderReference)", informal documentation-only tagging, not a machine-enforced format) Generated as plain [Swift.String]. Each string is a reference identifier that must have a matching key in the enclosing RenderNode's top-level references map; DocC-render resolves these client-side (Section 1) and drops any identifier that fails to resolve, rather than erroring.

On the swift-docc production side (secondary/flavor source, not authoritative for wire shape), the enclosing enum case is case links(Links) (Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift, line 76), documented as “A collection of authored links that should be rendered in a similar style to links in an on-page Topics section.” The nested struct is declared at the same file, lines 841–867:

public struct Links: Codable, Equatable {
    public enum Style: String, Codable, Equatable {
        case list
        case compactGrid
        case detailedGrid
    }
    public var style: Style
    public var items: [String]
    public init(style: RenderBlockContent.Links.Style, items: [String]) { ... }
}

This matches the wire schema field-for-field (style, items). Authoring-side, a links node is what swift-docc emits for an authored @Links(visualStyle:) directive (Sources/SwiftDocC/Semantics/Reference/Links.swift, lines 37–139), which lets an author place a curated set of documentation links anywhere on a page — independent of the page-curation Topics graph — by writing a single bulleted list of doc links inside the directive body, e.g.:

@Links(visualStyle: compactGrid) {
   - <doc:get-started-preparing-sloth-food>
   - <doc:feeding-your-sloth-in-winter>
   - <doc:ordering-food-delivery>
}

The directive's render(with:) extracts links from the first unordered list in its body, resolves each destination to an absolute reference string, maps its own VisualStyle argument enum 1:1 onto RenderBlockContent.Links.Style, and emits a single RenderBlockContent.links(...) node — or emits nothing at all if no links resolved (Sources/SwiftDocC/Semantics/Reference/Links.swift, lines 104–139). A HasExactlyOneUnorderedList validation pass emits warning diagnostics (not hard errors) for missing/extraneous body content, and unresolved doc links individually emit org.swift.docc.unresolvedTopicReference warnings while being dropped from the emitted items array, as seen directly in the swift-docc test fixture used for Section 2's example.

DocCArchive's own transform layer does not yet do anything with this kind: MyHTMLTransformer and MyMarkdownTransformer (Sources/DocCArchive/DocCArchive.swift, lines 242–254) are still stub placeholders that return a hardcoded HTML comment and an empty string respectively for an entire RenderNode, with no per-block-kind switch reached yet — so a links node parsed via Components.Schemas.Links is available on the decoded model today, but nothing in this repository currently converts it into HTML or Markdown output.

4. HTML/CSS mapping in DocC-Render output

Rendered DOM for a links node, in context, depends on style:

SCSS: LinksBlock.vue carries its own scoped <style> block (LinksBlock.vue#L59-L73), which only sets vertical stacking margins around the whole block (--spacing-stacked-margin-xlarge) and a 15px top margin between stacked .topic-link-block rows to match spacing used in the on-page Topics table. The bulk of the visual styling lives one level down, in the child components' own scoped stylesheets: TopicsLinkBlock.vue (TopicsLinkBlock.vue#L214-L274) for the list style, and TopicsLinkCardGridItem.vue (TopicsLinkCardGridItem.vue#L79-L119) for the grid styles.

CSS custom properties consumed across the two branches: --spacing-stacked-margin-xlarge (stacking margin around the whole links-block), --color-link-block-card-border (grid-card border color), and --color-fill-gray-quaternary (icon-fallback background); the list branch's icon-alignment spacing instead comes from Sass constants $topic-link-icon-spacing and $topic-link-icon-width compiled directly into the stylesheet rather than exposed as runtime custom properties.

5. Modern CSS-only alternative

Not applicable

Current behavior in play: neither branch of a rendered links block holds any client-side interactive state of its own. The list style (TopicsLinkBlock rows) is static markup — a link, an optional abstract, optional badges — with no toggles, tabs, or hidden panels. The grid style mounts a Pager component, which does have real interactive/stateful behavior elsewhere in DocC-render (an internal data()-held current-page index swapped via click handlers on Gutter arrows and page indicators), but as established in Section 1, LinksBlock.vue never opts into that behavior: it omits the usePager prop, which defaults to false, so defaultPageSize resolves to items.length and every linked item is placed on the grid's single page. The Pager's stateful paging machinery is therefore present in the component tree but inert for this particular kind — there is no multi-page state being held that a links-block-specific CSS mechanism would need to replace.

The remaining visual behaviors — card hover/link-color treatment, the deprecated strikethrough, the API-changes highlight — are already plain CSS (class-driven styling and pseudo-classes, not JS state machines) in the child components read in Section 4. With no client-side state to hold and no toggled visibility to replace, there is no single native mechanism (<details>, radio+:checked, :target, Popover API, etc.) that this page's audit can honestly point to as "replacing" behavior, because the links kind itself is stateless as rendered by DocC-render.