+
+
{{ $p := . -}}
{{ range .Site.Menus.main -}}
@@ -58,39 +62,41 @@
{{ end -}}
{{ if .Site.Params.versions -}}
- -
+
{{ end -}}
{{ if (gt (len .Site.Home.Translations) 0) -}}
- -
+
{{ end -}}
- {{ if .Site.Params.ui.showLightDarkModeMenu -}}
-
{{ end -}}
+
-
+
{{ partial "search-input.html" . }}
-{{ define "_partials/version-string" }}
- {{ $ret := "unstable version"}}
+{{- define "_partials/version-string" -}}
+ {{ $ret := "unstable version" -}}
- {{ $status := .Site.Params.version.status }}
+ {{ $status := .Site.Params.version.status -}}
- {{ if ne $status "unstable"}}
- {{ $path := path.Join "changelogs" }}
+ {{ if ne $status "unstable" -}}
+ {{ $path := path.Join "changelogs" -}}
- {{/* produces a string similar to "version v1.5" */}}
- {{ $ret = delimit (slice "version v" .Site.Params.version.major "." .Site.Params.version.minor) "" }}
- {{ end }}
+ {{/* produces a string similar to "version v1.5" */ -}}
+ {{ $ret = delimit (slice "version v" .Site.Params.version.major "." .Site.Params.version.minor) "" -}}
+ {{ end -}}
- {{ return $ret }}
-{{ end }}
+ {{ return $ret -}}
+{{- end -}}
diff --git a/layouts/_partials/openapi/render-api.html b/layouts/_partials/openapi/render-api.html
index 608cfa33..92d2bdd8 100644
--- a/layouts/_partials/openapi/render-api.html
+++ b/layouts/_partials/openapi/render-api.html
@@ -7,6 +7,8 @@
of each value in `paths` to get a complete URL.
* `anchor_base`: an optional prefix for the HTML IDs generated by
this template.
+ * `page`: the (Hugo) Page object to store endpoint metadata in the Scratch of. Used to build the endpoints TOC.
+ * `module`: the current CS API module name, if any. Used to group endpoints in the TOC.
This template replaces the old {{*_http_api}} template.
@@ -15,6 +17,8 @@
{{ $api_data := index .api_data }}
{{ $base_url := .base_url }}
{{ $anchor_base := .anchor_base }}
+{{ $page := .page }}
+{{ $module := .module }}
{{ range $path_name, $path_data := $api_data.paths }}
@@ -26,28 +30,28 @@
{{ with $path_data.get }}
- {{ $operation_params := merge $params (dict "method" "GET" "operation_data" . "anchor_base" $anchor_base) }}
+ {{ $operation_params := merge $params (dict "method" "GET" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
{{ with $path_data.post }}
- {{ $operation_params := merge $params (dict "method" "POST" "operation_data" . "anchor_base" $anchor_base) }}
+ {{ $operation_params := merge $params (dict "method" "POST" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
{{ with $path_data.put }}
- {{ $operation_params := merge $params (dict "method" "PUT" "operation_data" . "anchor_base" $anchor_base) }}
+ {{ $operation_params := merge $params (dict "method" "PUT" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
{{ with $path_data.delete }}
- {{ $operation_params := merge $params (dict "method" "DELETE" "operation_data" . "anchor_base" $anchor_base) }}
+ {{ $operation_params := merge $params (dict "method" "DELETE" "operation_data" . "anchor_base" $anchor_base "page" $page "module" $module) }}
{{ partial "openapi/render-operation" $operation_params }}
{{ end }}
diff --git a/layouts/_partials/openapi/render-operation.html b/layouts/_partials/openapi/render-operation.html
index c1e34ddf..d90a1d7e 100644
--- a/layouts/_partials/openapi/render-operation.html
+++ b/layouts/_partials/openapi/render-operation.html
@@ -7,6 +7,8 @@
* `operation_data`: the OpenAPI data for the operation
* `anchor_base`: an optional prefix for the HTML IDs generated by
this template.
+ * `page`: the (Hugo) Page object to store endpoint metadata in the Scratch of. Used to build the endpoints TOC.
+ * `module`: the current CS API module name, if any. Used to group endpoints in the TOC.
This template renders the operation as a `
` containing:
@@ -22,6 +24,8 @@
{{ $method := .method }}
{{ $endpoint := .endpoint }}
{{ $operation_data := .operation_data }}
+{{ $page := .page }}
+{{ $module := .module }}
{{ $anchor := "" }}
{{ if .anchor_base }}
@@ -29,6 +33,27 @@
{{ end }}
{{ $anchor = printf "%s%s%s" $anchor (lower $method) (anchorize $endpoint) }}
+{{/* Collect endpoints for the on-page endpoints TOC */}}
+{{ if $page }}
+ {{/* Store each endpoint's metadata in a scratch variable */}}
+ {{ $entry := dict "anchor" $anchor "method" $method "endpoint" $endpoint "summary" $operation_data.summary "deprecated" $operation_data.deprecated "module" $module }}
+ {{ if not ($page.Scratch.Get "api_endpoints_seen") }}
+ {{ $page.Scratch.Set "api_endpoints_seen" dict }}
+ {{ end }}
+ {{/* Keep a map of seen endpoints. This is necessary as this partial may be
+ rendered multiple times for the same endpoint (e.g. in the TOC and
+ in the main content), leading to duplicates. */}}
+ {{ $seen := $page.Scratch.Get "api_endpoints_seen" }}
+ {{ $key := printf "%s|%s" $method $endpoint }}
+ {{ if not (index $seen $key) }}
+ {{ if not (reflect.IsSlice ($page.Scratch.Get "api_endpoints")) }}
+ {{ $page.Scratch.Set "api_endpoints" (slice) }}
+ {{ end }}
+ {{ $page.Scratch.Add "api_endpoints" (slice $entry) }}
+ {{ $page.Scratch.SetInMap "api_endpoints_seen" $key true }}
+ {{ end }}
+{{ end }}
+
diff --git a/layouts/_partials/sidebar-tree.html b/layouts/_partials/sidebar-tree.html
index dba63f3a..e5f00807 100644
--- a/layouts/_partials/sidebar-tree.html
+++ b/layouts/_partials/sidebar-tree.html
@@ -1,37 +1,57 @@
{{- /*
- A modified version of the siderbar-tree.html partial in Docsy, adding:
-
- * The "toc.html" partial at L45.
+ A copy of the siderbar-tree.html partial in Docsy, modified to:
+
+ * Ignore the `sidebarRoot` parameter, because of this regression:
+
+ * Add the "toc.html" partial at L68.
*/ -}}
-{{/* We cache this partial for bigger sites and set the active class client side. */ -}}
-{{ $sidebarCacheLimit := .Site.Params.ui.sidebar_cache_limit | default 2000 -}}
-{{ $shouldDelayActive := ge (len .Site.Pages) $sidebarCacheLimit -}}
+{{ $context := .context -}}
+{{ $sidebarRoot := .sidebarRoot -}}
+{{ $sidebarRootID := .sidebarRootID -}}
+{{ $cacheSidebar := .cacheSidebar -}}
+
+{{ with $context -}}
+{{/* When the sidebar is cached, "active" class is set client side. */ -}}
+{{ $shouldDelayActive := $cacheSidebar -}}
+