From 8a9663c568eca349db4e8ef1517fde0a3865af55 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Fri, 12 Dec 2025 11:14:43 -0600 Subject: [PATCH] refactor(api): Simplify sidebar nav to sort by isConceptual, then alphabetically - Remove api_nav_groups.yml config file (no longer needed) - Update api-menu-items.html to derive order from article data - Sort: conceptual tags (traitTags) first, then other tags alphabetically - Reduces template from 255 to 152 lines --- data/api_nav_groups.yml | 69 ----- layouts/partials/sidebar/api-menu-items.html | 259 ++++++------------- 2 files changed, 78 insertions(+), 250 deletions(-) delete mode 100644 data/api_nav_groups.yml diff --git a/data/api_nav_groups.yml b/data/api_nav_groups.yml deleted file mode 100644 index 773e2cfde..000000000 --- a/data/api_nav_groups.yml +++ /dev/null @@ -1,69 +0,0 @@ -# API Navigation Groups -# Defines sidebar navigation structure for API reference documentation -# Single-tag groups render as direct links; multi-tag groups create nested menus -# -# Group fields: -# name: Display name in the navigation -# weight: Sort order (lower = higher) -# tags: List of tag names that belong to this group - -groups: - - name: Quick start - weight: 1 - tags: - - Quick start - - - name: Authentication - weight: 2 - tags: - - Authentication - - - name: Headers and parameters - weight: 3 - tags: - - Headers and parameters - - - name: Write data - weight: 10 - tags: - - Write data - - - name: Query data - weight: 11 - tags: - - Query data - - - name: Cache data - weight: 12 - tags: - - Cache data - - - name: Database - weight: 20 - tags: - - Database - - - name: Table - weight: 21 - tags: - - Table - - - name: Auth token - weight: 22 - tags: - - Auth token - - - name: Processing engine - weight: 30 - tags: - - Processing engine - - - name: Server information - weight: 40 - tags: - - Server information - - - name: Compatibility endpoints - weight: 50 - tags: - - Compatibility endpoints diff --git a/layouts/partials/sidebar/api-menu-items.html b/layouts/partials/sidebar/api-menu-items.html index 204f5b924..120542452 100644 --- a/layouts/partials/sidebar/api-menu-items.html +++ b/layouts/partials/sidebar/api-menu-items.html @@ -4,13 +4,14 @@ Generates - - {{ 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/" . "/") }} + {{ if $isConceptual }} + {{ $conceptualArticles = $conceptualArticles | append . }} + {{ else }} + {{ $operationArticles = $operationArticles | append . }} {{ end }} - {{ end }} {{ end }} {{ end }} + + {{/* Sort each group alphabetically by tag name */}} + {{ $conceptualArticles = sort $conceptualArticles "fields.tag" }} + {{ $operationArticles = sort $operationArticles "fields.tag" }} + + {{/* Combine: conceptual first, then operations */}} + {{ $sortedArticles := $conceptualArticles | append $operationArticles }} + + {{/* Render each tag as a nav item */}} + {{ range $sortedArticles }} + {{ $path := index . "path" }} + {{ $fields := index . "fields" }} + {{ $tag := index $fields "tag" }} + {{ $tagPageUrl := print "/" $product "/" $version "/" $path "/" | relURL }} + {{ $isActive := eq $currentPage.RelPermalink (print "/" $product "/" $version "/" $path "/") }} + + {{/* Get operations */}} + {{ $operations := slice }} + {{ if isset $fields "operations" }} + {{ $operations = index $fields "operations" }} + {{ end }} + + {{/* Don't show operations for conceptual/traitTag pages */}} + {{ $isConceptual := false }} + {{ if isset $fields "isConceptual" }} + {{ $isConceptual = index $fields "isConceptual" }} + {{ end }} + {{ $hasOperations := and (gt (len $operations) 0) (not $isConceptual) }} + + {{/* Check if any operation in this tag is active */}} + {{ $tagHasActiveOp := false }} + {{ range $operations }} + {{ $opPathSlug := .path | replaceRE "^/" "" }} + {{ $opUrl := printf "/%s/%s/api/%s/%s/" $product $version $opPathSlug (lower .method) }} + {{ if eq $currentPage.RelPermalink $opUrl }} + {{ $tagHasActiveOp = true }} + {{ end }} + {{ end }} + + + {{ end }} {{ end }}