docs-v2/layouts/api/single.html

153 lines
5.7 KiB
HTML

{{/*
API Documentation Single Page Layout
Used for:
- Conceptual pages (isConceptual: true) like Authentication, Quick start
- Individual operation pages (legacy - being phased out)
For conceptual pages:
- Shows Hugo content or tagDescription markdown
Required frontmatter:
- title: Page title
- isConceptual: true (for conceptual pages)
*/}}
{{ partial "header.html" . }}
{{ partial "topnav.html" . }}
<div class="page-wrapper">
{{/* Left: Existing Hugo sidebar (includes API nav via sidebar.html) */}}
{{ partial "sidebar.html" . }}
{{/* Center + Right: Content and TOC */}}
<div class="content-wrapper api-content">
<div class="api-main">
<article class="article article--content api-reference" role="main">
<header class="article--header">
<div class="article--header-row">
<div class="article--header-text">
{{/* For operation pages, show method badge with title */}}
{{ with .Params.method }}
<div class="api-operation-header">
<span class="api-method api-method--{{ lower . }}">{{ upper . }}</span>
<h1 class="article--title">{{ $.Title }}</h1>
</div>
{{ with $.Params.path }}
<code class="api-operation-path">{{ . }}</code>
{{ end }}
{{ else }}
<h1 class="article--title">{{ .Title }}</h1>
{{ end }}
{{/* Summary/Description - skip for conceptual pages (shown in content section) */}}
{{ if not (.Params.isConceptual | default false) }}
{{ with .Params.summary }}
<p class="article--summary">{{ . | markdownify }}</p>
{{ else }}
{{ with .Description }}
<p class="article--summary">{{ . | markdownify }}</p>
{{ end }}
{{ end }}
{{ end }}
</div>
{{/* Download OpenAPI spec button - context-aware for Clustered/Cloud Dedicated */}}
{{ with .Params.staticFilePath }}
{{/* Extract product name from path like /openapi/influxdb-oss-v2/tags/... */}}
{{ $productName := replaceRE `^/openapi/([^/]+)/.*$` "$1" . }}
{{/* Check if this is a dual-API product (Clustered or Cloud Dedicated) */}}
{{ $isDualApi := or (strings.Contains $productName "clustered") (strings.Contains $productName "cloud-dedicated") }}
{{ if $isDualApi }}
{{/* Determine API type from path */}}
{{ $isManagementApi := strings.Contains . "management-api" }}
{{ if $isManagementApi }}
{{ $specPath := printf "/openapi/%s-management-api.yml" $productName }}
<div class="api-spec-actions">
<a href="{{ $specPath }}" class="btn api-spec-download" download>
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
<path d="M8 12L3 7h3V2h4v5h3L8 12z"/>
<path d="M1 14h14v2H1v-2z"/>
</svg>
Download Management API Spec
</a>
</div>
{{ else }}
{{ $specPath := printf "/openapi/%s-v2-data-api.yml" $productName }}
<div class="api-spec-actions">
<a href="{{ $specPath }}" class="btn api-spec-download" download>
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
<path d="M8 12L3 7h3V2h4v5h3L8 12z"/>
<path d="M1 14h14v2H1v-2z"/>
</svg>
Download Data API Spec
</a>
</div>
{{ end }}
{{ else }}
{{/* Single-spec products - existing behavior */}}
{{ $completeSpecPath := printf "/openapi/%s.yml" $productName }}
<div class="api-spec-actions">
<a href="{{ $completeSpecPath }}" class="btn api-spec-download" download>
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
<path d="M8 12L3 7h3V2h4v5h3L8 12z"/>
<path d="M1 14h14v2H1v-2z"/>
</svg>
Download OpenAPI Spec
</a>
</div>
{{ end }}
{{ end }}
</div>
</header>
{{ $isConceptual := .Params.isConceptual | default false }}
{{ if $isConceptual }}
{{/* Conceptual Page - Show content directly */}}
<section class="api-conceptual-content">
{{ with .Content }}
{{ . }}
{{ else }}
{{ with .Params.tagDescription }}
{{ . | markdownify }}
{{ end }}
{{ end }}
</section>
{{/* Security Schemes from OpenAPI spec (only show if showSecuritySchemes: true) */}}
{{ if .Params.showSecuritySchemes }}
{{ partial "api/security-schemes.html" . }}
{{ end }}
{{ else }}
{{/* Operation Page - Hugo-native rendering */}}
{{/* Note: Individual operation pages are being phased out. */}}
{{/* Operations are now accessed via tag pages only. */}}
{{/* Hugo page content shown as overview */}}
{{ with .Content }}
<section class="api-content-overview">
{{ . }}
</section>
{{ end }}
{{ end }}
{{/* Related documentation links */}}
{{ partial "article/related.html" . }}
</article>
</div>
{{/* Right: Page TOC - "ON THIS PAGE" */}}
<aside class="api-toc" data-component="api-toc">
<h4 class="api-toc-header">ON THIS PAGE</h4>
<nav class="api-toc-nav"></nav>
</aside>
</div>
</div>
{{ partial "footer.html" . }}