feat(api): Integrate API navigation into Hugo menu system

Add API nav items as children of "InfluxDB HTTP API" menu item:
- New api-menu-items.html partial generates nav from data/articles.yml
- Modified nested-menu.html to inject API nav for API parent menu item
- Updated api_nav_groups.yml to add url for Administration group
- Created Administration landing pages for Core and Enterprise
- Updated .gitignore to allow hand-crafted API conceptual pages

The Administration page uses layout: list and isConceptual: true to render
content directly without RapiDoc wrapper.
worktree-2025-12-30T19-16-55
Jason Stirnaman 2025-12-09 16:05:53 -06:00
parent b1fcaa1443
commit 6e38e24335
6 changed files with 302 additions and 6 deletions

4
.gitignore vendored
View File

@ -22,6 +22,10 @@ package-lock.json
/content/influxdb3/*/reference/api/**
/static/openapi
# Exception: hand-crafted API conceptual pages (not generated)
!/content/influxdb3/*/api/administration/
!/content/influxdb3/*/api/administration/_index.md
/helper-scripts/output/*
/telegraf-build
!telegraf-build/templates

View File

@ -0,0 +1,26 @@
---
title: Administration
description: Endpoints for managing databases, tables, and tokens.
type: api
layout: list
weight: 105
isConceptual: true
---
Use the Administration API to manage InfluxDB resources:
<div class="children-links">
### [Database](/influxdb3/core/api/database/)
Create, list, and delete databases.
### [Table](/influxdb3/core/api/table/)
Create and delete tables within databases.
### [Token](/influxdb3/core/api/token/)
Manage authentication tokens for API access.
</div>

View File

@ -0,0 +1,26 @@
---
title: Administration
description: Endpoints for managing databases, tables, and tokens.
type: api
layout: list
weight: 105
isConceptual: true
---
Use the Administration API to manage InfluxDB resources:
<div class="children-links">
### [Database](/influxdb3/enterprise/api/database/)
Create, list, and delete databases.
### [Table](/influxdb3/enterprise/api/table/)
Create and delete tables within databases.
### [Token](/influxdb3/enterprise/api/token/)
Manage authentication tokens for API access.
</div>

View File

@ -1,6 +1,12 @@
# API Navigation Groups
# Defines sidebar navigation structure for API reference documentation
# Tags are grouped by function/task for better UX
#
# Group fields:
# name: Display name in the navigation
# weight: Sort order (lower = higher)
# tags: List of tag names that belong to this group
# url: (optional) URL path suffix for the group page (relative to api/)
groups:
- name: Concepts
@ -27,6 +33,7 @@ groups:
- name: Administration
weight: 5
url: administration
tags:
- Database
- Table

View File

@ -0,0 +1,216 @@
{{/*
API Reference Menu Items for Hugo Navigation
Generates <li class="nav-item"> elements matching Hugo's menu structure.
Used by nested-menu.html when rendering "InfluxDB HTTP API" menu item.
Parameters:
- page: Current page context
- url: URL of the API parent page (e.g., /influxdb3/core/api/)
Uses data from:
- data/article_data/influxdb/{product}/articles.yml
- data/api_nav_groups.yml
*/}}
{{ $currentPage := .page }}
{{ $apiUrl := .url }}
{{/* Extract product and version from API URL */}}
{{ $productPathData := findRE "[^/]+.*?" $apiUrl }}
{{ $product := index $productPathData 0 }}
{{ $version := index $productPathData 1 }}
{{/* Build data key for article data lookup */}}
{{ $dataKey := "" }}
{{ if eq $product "influxdb3" }}
{{ $dataKey = print "influxdb3_" $version }}
{{ else if eq $product "influxdb" }}
{{ $dataKey = print $version }}
{{ else }}
{{ $dataKey = $product }}
{{ end }}
{{/* Get article data for this product */}}
{{ $siteData := .siteData }}
{{ $articles := slice }}
{{/* Data path: data/article_data/influxdb/{dataKey}/articles.yml -> siteData.article_data.influxdb.{dataKey}.articles.articles */}}
{{ with $siteData.article_data }}
{{ with index . "influxdb" }}
{{ with index . $dataKey }}
{{ with index . "articles" }}
{{ with .articles }}
{{ $articles = . }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{/* Get navigation groups configuration */}}
{{ $navGroups := $siteData.api_nav_groups.groups }}
{{/* Check if articles use tag-based structure */}}
{{ $isTagBased := false }}
{{ if gt (len $articles) 0 }}
{{ $firstArticle := index $articles 0 }}
{{ if reflect.IsMap $firstArticle }}
{{ with index $firstArticle "fields" }}
{{ if reflect.IsMap . }}
{{ if isset . "tag" }}
{{ $isTagBased = true }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ if and (gt (len $articles) 0) $navGroups $isTagBased }}
{{/* Build a map of tag slug -> article for quick lookup */}}
{{ $articlesByTag := dict }}
{{ range $articles }}
{{ if and (reflect.IsMap .) (isset . "fields") }}
{{ $fields := index . "fields" }}
{{ if and (reflect.IsMap $fields) (isset $fields "tag") }}
{{ $tag := index $fields "tag" }}
{{ $articlesByTag = merge $articlesByTag (dict $tag .) }}
{{ end }}
{{ end }}
{{ end }}
{{/* Render navigation groups */}}
{{ range $groupIdx, $group := $navGroups }}
{{ $groupTags := $group.tags }}
{{ $groupHasArticles := false }}
{{/* Check if any tags in this group have articles */}}
{{ range $groupTags }}
{{ if index $articlesByTag . }}
{{ $groupHasArticles = true }}
{{ end }}
{{ end }}
{{ if $groupHasArticles }}
{{/* Count actual articles in this group */}}
{{ $articlesInGroup := slice }}
{{ range $groupTags }}
{{ $article := index $articlesByTag . }}
{{ if $article }}
{{ $articlesInGroup = $articlesInGroup | append $article }}
{{ end }}
{{ end }}
{{ $isSingleTag := eq (len $articlesInGroup) 1 }}
{{/* Check if this group should be open (contains active page) */}}
{{ $groupIsOpen := false }}
{{ range $articlesInGroup }}
{{ $path := index . "path" }}
{{ $pageUrl := print "/" $product "/" $version "/" $path "/" }}
{{ if eq $currentPage.RelPermalink $pageUrl }}
{{ $groupIsOpen = true }}
{{ end }}
{{ end }}
{{ if $isSingleTag }}
{{/* Single tag group: direct link to tag page with operations as children */}}
{{ $article := index $articlesInGroup 0 }}
{{ $path := index $article "path" }}
{{ $fields := index $article "fields" }}
{{ $tagPageUrl := print "/" $product "/" $version "/" $path "/" | relURL }}
{{ $isActive := eq $currentPage.RelPermalink (print "/" $product "/" $version "/" $path "/") }}
{{ $operations := slice }}
{{ if and (reflect.IsMap $fields) (isset $fields "operations") }}
{{ $operations = index $fields "operations" }}
{{ end }}
{{ $hasOperations := gt (len $operations) 0 }}
<li class="nav-item{{ if $isActive }} active{{ end }}">
{{ if $hasOperations }}<a href="#" class="children-toggle{{ if or $isActive $groupIsOpen }} open{{ end }}"></a>{{ end }}
<a href="{{ $tagPageUrl }}">{{ $group.name }}</a>
{{ if $hasOperations }}
<ul class="children{{ if or $isActive $groupIsOpen }} open{{ end }}">
{{ range $operations }}
{{ $apiPath := .path }}
{{ $trimmedPath := strings.TrimPrefix "/" $apiPath }}
{{ $contentPath := $trimmedPath }}
{{ if not (hasPrefix $trimmedPath "api/") }}
{{ $contentPath = printf "api/%s" $trimmedPath }}
{{ end }}
{{ $fragment := printf "#operation/%s" .operationId }}
{{ $fullUrl := printf "%s%s" (print "/" $product "/" $version "/" $contentPath "/" | relURL) $fragment }}
<li class="nav-item api-operation">
<a href="{{ $fullUrl | safeURL }}">
<span class="api-method api-method--{{ lower .method }}">{{ upper .method }}</span>
{{ with .summary }}{{ . }}{{ else }}<code>{{ $apiPath }}</code>{{ end }}
</a>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ else }}
{{/* Multi-tag group: group label (or link if url defined) with tag pages as children */}}
{{ $groupUrl := "" }}
{{ $groupIsActive := false }}
{{ with $group.url }}
{{ $groupUrl = print "/" $product "/" $version "/api/" . "/" | relURL }}
{{ $groupIsActive = eq $currentPage.RelPermalink (print "/" $product "/" $version "/api/" . "/") }}
{{ end }}
<li class="nav-item{{ if $groupIsActive }} active{{ end }}">
<a href="#" class="children-toggle{{ if or $groupIsOpen $groupIsActive }} open{{ end }}"></a>
{{ if $groupUrl }}
<a href="{{ $groupUrl }}">{{ $group.name }}</a>
{{ else }}
<span class="nav-group-label">{{ $group.name }}</span>
{{ end }}
<ul class="children{{ if or $groupIsOpen $groupIsActive }} open{{ end }}">
{{ range $tagIdx, $tagName := $groupTags }}
{{ $article := index $articlesByTag $tagName }}
{{ if $article }}
{{ $path := index $article "path" }}
{{ $fields := index $article "fields" }}
{{ $tagPageUrl := print "/" $product "/" $version "/" $path "/" | relURL }}
{{ $isActive := eq $currentPage.RelPermalink (print "/" $product "/" $version "/" $path "/") }}
{{ $operations := slice }}
{{ if and (reflect.IsMap $fields) (isset $fields "operations") }}
{{ $operations = index $fields "operations" }}
{{ end }}
{{ $menuName := $tagName }}
{{ if and (reflect.IsMap $fields) (isset $fields "menuName") }}
{{ $menuName = index $fields "menuName" }}
{{ end }}
{{ $hasOperations := gt (len $operations) 0 }}
<li class="nav-item{{ if $isActive }} active{{ end }}">
{{ if $hasOperations }}<a href="#" class="children-toggle{{ if $isActive }} open{{ end }}"></a>{{ end }}
<a href="{{ $tagPageUrl }}">{{ $menuName }}</a>
{{ if $hasOperations }}
<ul class="children{{ if $isActive }} open{{ end }}">
{{ range $operations }}
{{ $apiPath := .path }}
{{ $trimmedPath := strings.TrimPrefix "/" $apiPath }}
{{ $contentPath := $trimmedPath }}
{{ if not (hasPrefix $trimmedPath "api/") }}
{{ $contentPath = printf "api/%s" $trimmedPath }}
{{ end }}
{{ $fragment := printf "#operation/%s" .operationId }}
{{ $fullUrl := printf "%s%s" (print "/" $product "/" $version "/" $contentPath "/" | relURL) $fragment }}
<li class="nav-item api-operation">
<a href="{{ $fullUrl | safeURL }}">
<span class="api-method api-method--{{ lower .method }}">{{ upper .method }}</span>
{{ with .summary }}{{ . }}{{ else }}<code>{{ $apiPath }}</code>{{ end }}
</a>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}
{{ end }}
</ul>
</li>
{{ end }}
{{ end }}
{{ end }}
{{ end }}

View File

@ -1,22 +1,39 @@
{{ $page := .page }}
{{ $menu := .menu }}
{{ $siteData := .siteData }}
{{ define "recursiveMenu" }}
{{ $menuContext := .menu }}
{{ $currentPage := .currentPage }}
{{ $site := .site }}
{{ $siteData := .siteData }}
{{ $depth := add .depth 1 }}
{{ $navClass := cond (gt $depth 1) "item" "category" }}
{{ range $menuContext }}
{{/* Check if this is the InfluxDB HTTP API menu item for InfluxDB 3 products */}}
{{ $isApiParent := and (eq .Name "InfluxDB HTTP API") (or (hasPrefix .URL "/influxdb3/") (hasPrefix .URL "/influxdb/")) }}
<li class="nav-{{ $navClass }} {{ if eq $currentPage.RelPermalink .URL }}active{{end}}">
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
<a href='{{ default .URL .Params.url }}'>{{ .Name }}</a>
{{ if .HasChildren }}
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
{{ template "recursiveMenu" (dict "menu" .Children "currentPage" $currentPage "depth" $depth) }}
{{ if $isApiParent }}
{{/* API Reference: render custom API nav children instead of standard menu children */}}
{{ $hasApiContent := or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) (hasPrefix $currentPage.RelPermalink .URL) }}
<a href="#" class="children-toggle {{ if $hasApiContent }}open{{end}}"></a>
<a href='{{ default .URL .Params.url }}'>{{ .Name }}</a>
<ul class="children {{ if $hasApiContent }}open{{end}}">
{{ partial "sidebar/api-menu-items" (dict "page" $currentPage "url" .URL "siteData" $siteData) }}
</ul>
{{ else }}
{{/* Standard menu rendering */}}
{{ if .HasChildren }}<a href="#" class="children-toggle {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}"></a>{{ end }}
<a href='{{ default .URL .Params.url }}'>{{ .Name }}</a>
{{ if .HasChildren }}
<ul class="children {{ if or ($currentPage.IsMenuCurrent .Menu .) ($currentPage.HasMenuCurrent .Menu .) }}open{{end}}">
{{ template "recursiveMenu" (dict "menu" .Children "currentPage" $currentPage "site" $site "siteData" $siteData "depth" $depth) }}
</ul>
{{ end }}
{{ end }}
</li>
{{ end }}
{{ end }}
{{ template "recursiveMenu" (dict "menu" .menu "currentPage" .page "depth" 0) }}
{{ template "recursiveMenu" (dict "menu" .menu "currentPage" .page "site" $page.Site "siteData" $siteData "depth" 0) }}