$schema: http://json-schema.org/draft-07/schema#
$id: https://diplodoc.com/schemas/leading/draft-01/schema#
title: Diplodoc (index.yaml)
type: object
properties:
  title:
    $ref: '#/definitions/TextItems'
    description: Main heading of the leading page. Supports conditional text items.
    markdownDescription: |-
      **`string | TextItems`** Main heading displayed at the top of the leading page.

      Can be a plain string or a conditional `TextItem` array:
      ```yaml
      title: My Section
      ```
  description:
    $ref: '#/definitions/TextItems'
    description: Short description shown below the title. Supports conditional text items.
    markdownDescription: '**`string | TextItems`** Short description shown below the title on the leading page.'
  meta:
    allOf:
      - $ref: './frontmatter-schema.yaml#'
    description: Page metadata — SEO, UI overrides, resources, and access rules. Uses the same fields as Markdown frontmatter.
    markdownDescription: |-
      **`Frontmatter`** Page metadata — uses the same fields as Markdown frontmatter:
      `title`, `description`, `noIndex`, `keywords`, `canonical`, `interface` (toc, gallery, search…), `stage`, `script`, `style`, `restricted-access`, etc.
    defaultSnippets:
      - label: SEO metadata
        body:
          title: ${1:Page title for SEO}
          description: ${2:Page description for SEO}
          noIndex: false
  nav:
    type: object
    properties:
      title:
        $ref: '#/definitions/TextItems'
        description: Title used in the breadcrumb navigation for this section.
        markdownDescription: '**`string`** Title shown in the breadcrumb navigation for this section (overrides the TOC entry name).'
    additionalProperties: false
    markdownDescription: '**`{title}`** Navigation breadcrumb override for this leading page.'
    description: Breadcrumb / navigation override for this leading page.
  links:
    type: array
    items:
      type: object
      properties:
        title:
          $ref: '#/definitions/TextItems'
          translate: md
          description: Card title text.
          markdownDescription: '**`string`** Card title text. Supports conditional `TextItems`.'
        description:
          $ref: '#/definitions/TextItems'
          translate: md
          description: Card description text shown below the title.
          markdownDescription: '**`string`** Card description shown below the title. Supports conditional `TextItems`.'
        href:
          type: string
          format: url
          markdownDescription: '**`string`** Relative path to the target `.md` page or `index.yaml` section.'
          description: Relative path to the target page or section.
        when:
          type:
            - string
            - boolean
          description: Liquid condition. Card is hidden when false.
          markdownDescription: '**`string | boolean`** Liquid condition — card is hidden when the expression is falsy.'
      additionalProperties: true
      markdownDescription: '**`{title, description, href, when}`** A navigation link card on the leading page.'
      description: A single navigation link card.
      defaultSnippets:
        - label: Link card
          body:
            title: ${1:Card title}
            description: ${2:Card description}
            href: ${3:page.md}
    markdownDescription: |-
      **`object[]`** Navigation link cards shown on the leading page. Each card has a title, optional description, and an `href`.

      ```yaml
      links:
        - title: Quickstart
          description: Up and running in 5 minutes.
          href: quickstart.md
      ```
    description: Navigation link cards displayed on the leading page.
additionalProperties: false
definitions:
  TextItems:
    oneOf:
      - type: string
        markdownDescription: '**`string`**'
      - type: array
        translate: md
        items:
          oneOf:
            - type: string
              translate: md
              markdownDescription: '**`string`**'
            - $ref: '#/definitions/TextItem'
        markdownDescription: '**`string | TextItem[]`**'
    description: Plain string or array of conditional text items.
    markdownDescription: '**`string | TextItem[]`** Text value — either a plain string or a list of conditional text items (the first item whose `when` condition is truthy is used).'
  TextItem:
    type: object
    description: Conditional text item — the first item whose 'when' is truthy is used.
    properties:
      text:
        oneOf:
          - type: string
            markdownDescription: '**`string`**'
          - type: array
            items:
              type: string
              markdownDescription: '**`string`**'
            markdownDescription: '**`string[]`**'
        translate: md
        description: Text content to display when the condition is met.
        markdownDescription: '**`string | string[]`** Text content shown when `when` is truthy. **Required.**'
      when:
        type:
          - string
          - boolean
        description: Liquid condition. This item is used when the expression is truthy.
        markdownDescription: '**`string | boolean`** Liquid condition. This item is selected when the expression is truthy.'
    required:
      - text
    additionalProperties: true
    markdownDescription: |-
      **`TextItem`** Conditional text item. The first item in the array whose `when` evaluates to `true` is displayed.

      ```yaml
      title:
        - text: Internal title
          when: env == 'internal'
        - text: Public title
      ```
  Alternate:
    type: object
    properties:
      href:
        type: string
        format: uri
        markdownDescription: '**`string (uri)`** URL of the alternate page.'
      hreflang:
        type: string
        markdownDescription: '**`string`** Language code (e.g. `en`, `ru`).'
    required:
      - href
    additionalProperties: false
    markdownDescription: '**`Alternate`** Alternate language version for `<link rel="alternate">`.'
    description: Alternate language version of this page.
  MetaItem:
    type: object
    properties:
      name:
        type: string
        markdownDescription: '**`string`**'
      property:
        type: string
        markdownDescription: '**`string`**'
      http-equiv:
        type: string
        markdownDescription: '**`string`**'
      content:
        type: string
        markdownDescription: '**`string`**'
    required:
      - content
    additionalProperties: false
    markdownDescription: '**`MetaItem`** Custom `<meta>` tag — requires `content` plus one of `name`, `property`, or `http-equiv`.'
    description: Custom HTML meta tag definition.
  Contributor:
    type: object
    properties:
      avatar:
        type: string
        markdownDescription: '**`string`**'
      email:
        type: string
        format: email
        markdownDescription: '**`string`**'
      login:
        type: string
        markdownDescription: '**`string`**'
      name:
        type: string
        markdownDescription: '**`string`**'
      url:
        type: string
        format: uri
        markdownDescription: '**`string`**'
    additionalProperties: false
    markdownDescription: '**`{avatar, email, login, ...}`**'
markdownDescription: |-
  Diplodoc leading page file (`index.yaml`).
  A leading page is a structured landing page for a documentation section. It can display a title, description, and navigation links.
  ```yaml title: Getting Started description: Learn how to set up and use My Product. links:
    - title: Quickstart
      description: Up and running in 5 minutes.
      href: quickstart.md
    - title: Concepts
      description: Core concepts and architecture.
      href: concepts/index.yaml
  ```
