section

hero

Wire value: "hero"

Appears on: Tutorial (Project), Tutorial Article, Tutorials Overview

1. How swift-docc-render consumes this

hero is one of two kind values (hero, intro) accepted by the IntroRenderSection schema, used as the first section of a Tutorial page or a free-standing Article page (produced from an @Intro directive inside a .tutorial file). There are two separate dispatch sites, one per page type, both of which key a lookup table on section.kind:

For tutorials, the table lives directly in Tutorial.vue:

const SectionComponents = {
  assessments: Assessments,
  hero: Hero,
  tasks: SectionList,
  callToAction: CallToAction,
};
...
const TutorialSection = {
  name: 'TutorialSection',
  render: function render(createElement) {
    const { kind, ...props } = this.section;
    const component = SectionComponents[kind];
    return component ? createElement(component, { props }) : null;
  },
  ...
};

hero maps to Hero, imported as import Hero from 'theme/components/Tutorial/Hero.vue' — i.e. Tutorial/Hero.vue. For articles, the analogous table lives in Article.vue (a SectionKind map plus a componentFor(section) method), which maps hero to Article/Hero.vue — a two-line wrapper that just re-exports the same tutorial component:

<template>
  <TutorialHero v-bind="$props" />
</template>
...
import TutorialHero from 'theme/components/Tutorial/Hero.vue';
export default {
  name: 'Hero',
  components: { TutorialHero },
  props: TutorialHero.props,
};

So both page types ultimately render the same Tutorial/Hero.vue component (internally named Hero). Its template wraps everything in a LinkableSection (renders an element with id="introduction", used as an in-page jump target) and a div.hero.dark, then lays out an optional background image, an H1 headline (with chapter shown as an eyebrow if present), the content block array via the shared ContentNode.vue, an optional "Watch intro video" call-to-action that opens a GenericModal, and a HeroMetadata child component for the estimated-time / project-download / Xcode-requirement row:

<LinkableSection anchor="introduction" :title="sectionTitle" class="tutorial-hero">
  <div class="hero dark">
    <div v-if="backgroundImageUrl" class="bg" :style="bgStyle" />
    <Row><Column>
      <Headline :level="1">
        <template v-if="chapter" #eyebrow>{{ chapter }}</template>
        {{ title }}
      </Headline>
      <div v-if="content || video" class="intro">
        <ContentNode v-if="content" :content="content" />
        <template v-if="video">
          <a href="#" class="call-to-action" @click.prevent="toggleCallToActionModal">
            Watch intro video <PlayIcon />
          </a>
          <GenericModal :visible.sync="callToActionModalVisible" isFullscreen theme="dark">
            <Asset ref="asset" v-show="callToActionModalVisible" :identifier="video" />
          </GenericModal>
        </template>
      </div>
      <Metadata :projectFilesUrl="projectFilesUrl"
                :estimatedTimeInMinutes="estimatedTimeInMinutes"
                :xcodeRequirement="xcodeRequirementData" class="metadata" />
    </Column></Row>
  </div>
</LinkableSection>

Metadata is Tutorial/HeroMetadata.vue, a small presentational component that shows up to three optional items (estimated reading time, a project-files download link, an Xcode-requirement link), each guarded by a plain v-if on whether the corresponding prop was supplied. backgroundImage, image (the standout key image) and video are all plain string reference identifiers that get resolved against the page's references map by the referencesProvider mixin (backgroundImageUrl/xcodeRequirementData computed properties); note that in the template shown, the image prop is accepted but not itself rendered directly in Hero.vue—only backgroundImage and video are consumed there.

Note on scope / naming collision: this hero section kind (an IntroRenderSection, dispatched by kind as shown above) is unrelated to components/DocumentationTopic/Hero/DocumentationHero.vue, a differently-named component used for the banner region at the top of ordinary symbol/article pages in DocumentationTopic.vue. That component is not driven by a kind: "hero" payload at all — it is structural page chrome, always present, and was not found to consume this schema; it is mentioned here only to avoid confusing the two "hero" concepts.

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

2. Example JSON and rendered mockup

Fixture source: Tests/SwiftDocCTests/Rendering/IntroRenderSectionTests.swift in the swift-docc repository (the JSON literal used in its testDecoding()/testRoundTrip() tests). DocCArchive's own fixtures (ExampleDocs.doccarchive, SampleLibrary.doccarchive) contain only documentation-topic pages, no tutorials or articles, so no real data/ JSON with "kind": "hero" exists there — the string "hero" only turns up inside the minified render-side JS bundles (e.g. js/topic.c7f55345.js), which is why this test fixture was used instead per the sourcing order.

{
    "kind": "hero",
    "title": "Introducing TechnologyX",
    "action": {
        "type": "reference",
        "identifier": "doc://testbundle/tutorials/TechnologyX/Tutorial",
        "isActive": true,
        "overridingTitle": "Get started",
        "overridingTitleInlineContent": [
            { "type": "text", "text": "Get started" }
        ]
    },
    "backgroundImage": "intro.png",
    "image": "intro.png",
    "content": [
        {
            "type": "paragraph",
            "inlineContent": [
                { "type": "text", "text": "This is the intro." }
            ]
        }
    ]
}

Introduction

Introducing TechnologyX

This is the intro.

Get started →

mockup: dark hero band, H1 title, intro paragraph via ContentNode, and an action link (metadata row and background image omitted since this example has no estimatedTimeInMinutes/projectFiles/xcodeRequirement and the background image is not visually simulated here).

3. Data sheet

Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object #/components/schemas/IntroRenderSection, cross-checked against the generated Components.Schemas.IntroRenderSection struct in Sources/DocCArchive/generated/Types.swift (lines 3110–3143).

FieldTypeRequiredEnum values / defaultNote
kind string yes "hero", "intro" Generated as a two-case KindPayload enum. Only "hero" has been observed in practice (it is the literal value swift-docc's IntroRenderSection.kind Swift property is hardcoded to; see swiftCaseSite below). No confirmed emitter of "intro" was found while researching this page.
title string yes — Rendered as the page's H1 via Headline.
content array of RenderBlockContent no — Generated as [RenderBlockContent]? (optional). Rendered via ContentNode.vue inside div.intro.

Important gap between the vendored wire schema and the actual Swift model: the JSON Schema object above (and therefore the generated Components.Schemas.IntroRenderSection Swift type DocCArchive exposes) only declares title, kind, and content. swift-docc's actual Swift model, IntroRenderSection.swift (swiftStructSite, since no explicit struct site was given for this page), encodes five additional optional fields that swift-docc-render's Hero.vue actively consumes as props — chapter (string), estimatedTimeInMinutes (int), xcodeRequirement (a RenderReferenceIdentifier string), backgroundImage (a RenderReferenceIdentifier string), action (a RenderInlineContent reference), image (a RenderReferenceIdentifier string), video (a RenderReferenceIdentifier string), and projectFiles (a RenderReferenceIdentifier string). The real-fixture JSON in section 2 above demonstrates three of these (action, backgroundImage, image) being emitted and decoded successfully by swift-docc's own test suite — confirming they are genuinely present on the wire, not just theoretical. A DocCArchive consumer decoding with the generated Components.Schemas.IntroRenderSection type today will silently drop all eight of these fields, since swift-openapi-generator only generates properties for keys the JSON Schema actually declares. Anyone needing chapter, media references, the CTA action, or the metadata-row fields from a hero section must either widen the vendored schema and regenerate, or decode the raw JSON alongside the generated type.

4. HTML/CSS mapping in DocC-Render output

Rendered DOM shape, from Tutorial/Hero.vue's template:

SCSS lives inline in Tutorial/Hero.vue's <style scoped lang="scss"> block (importing docc-render/styles/_core.scss) and in Tutorial/HeroMetadata.vue's own scoped block. Key CSS custom properties consumed:

The .dark modifier class forces both the light-scheme and dark-scheme SCSS color-var mixins (color-vars-light, then color-vars-dark) to be included together inside a @media screen block, with the dark set declared last so it wins — a build-time SCSS technique, not a runtime media-query based scheme switch.

DocCArchive transform status: MyHTMLTransformer and MyMarkdownTransformer in Sources/DocCArchive/DocCArchive.swift are still stub placeholders (the HTML transformer returns a hardcoded <!-- what? --> comment and the Markdown transformer returns an empty string) — there is no kind-specific handling for hero/IntroRenderSection today, and given the field gap documented in section 3, a future implementation would need to decode more than the generated type currently exposes to reproduce what swift-docc-render actually shows.

5. Modern CSS-only alternative

PARTIAL

Current behavior: most of Hero.vue is static, one-way prop-to-template rendering with no interactivity (background image, title, eyebrow, content, metadata row). The one genuinely stateful piece is the "Watch intro video" flow: a boolean callToActionModalVisible in component data() is flipped to true by a @click.prevent="toggleCallToActionModal" handler on the call-to-action link, which is bound via :visible.sync to a child GenericModal, and also drives v-show on the inner video Asset; toggleCallToActionModal() additionally awaits $nextTick() and imperatively calls .play() on the underlying <video> element, and the modal closes itself again on the videoEnded event via handleVideoEnd() setting the flag back to false.

The show/hide half of that (opening and closing the full-screen video overlay) maps mechanically onto the native <dialog> element: the call-to-action link becomes a <button> whose click handler calls dialogEl.showModal() instead of setting a Vue boolean, and the modal markup becomes a <dialog> that the browser itself renders top-layer/centered and backdrop-dimmed, with no v-if/v-show or synced prop required to hold the "is it open" state — the dialog's own open/closed DOM state is the state. A <form method="dialog"> "close" control or the built-in Escape-key handling would replace handleVideoEnd's manual flag reset for the close side. The verdict is partial, not fully applicable, because two behaviors have no equivalent native primitive: (1) autoplaying the video specifically on modal open (<dialog> has no declarative "autoplay when shown" hook; a small script calling video.play() on the dialog's open would still be required, same as today), and (2) auto-closing the dialog when the video finishes, which still needs a videoEnded-style event listener calling dialogEl.close(). So <dialog> removes the Vue-specific state-holding boolean and the :visible.sync plumbing, but does not remove all script entirely.