From c02607bee1697c30559847e773b4e37752180623 Mon Sep 17 00:00:00 2001 From: Ash Keel Date: Mon, 6 Mar 2023 17:01:31 +0100 Subject: [PATCH] versioned api ref --- content/api/v31.md | 9 ++ data/api/{v310 => v31}/api.json | 0 layouts/api/list.html | 88 +---------------- layouts/api/single.html | 116 +++++++++++++++++++++++ static/script/apiselector.js | 4 + themes/strimertul/assets/scss/guide.scss | 13 +++ 6 files changed, 145 insertions(+), 85 deletions(-) create mode 100644 content/api/v31.md rename data/api/{v310 => v31}/api.json (100%) create mode 100644 layouts/api/single.html create mode 100644 static/script/apiselector.js diff --git a/content/api/v31.md b/content/api/v31.md new file mode 100644 index 0000000..2d1693d --- /dev/null +++ b/content/api/v31.md @@ -0,0 +1,9 @@ +--- +menu: apiversions + +title: v3.1.x +version: v31 +aliases: + - latest + - api/ +--- diff --git a/data/api/v310/api.json b/data/api/v31/api.json similarity index 100% rename from data/api/v310/api.json rename to data/api/v31/api.json diff --git a/layouts/api/list.html b/layouts/api/list.html index 5adb5fa..5ff15e1 100644 --- a/layouts/api/list.html +++ b/layouts/api/list.html @@ -1,99 +1,17 @@ -{{ define "schema" }} - {{ with .description }}
{{ . }}
{{ end }} - - {{ with .element }} - {{ with $.name }} -
{{ . }}:
- {{ end }} - {{ if (eq $.kind "array") }} - arrayOf [ - {{ template "schema" . }} - ] - {{ end }} - {{ if (eq $.kind "dictionary") }} - dictionary -
- < - - {{ $.key.name }}, {{ template "schema" . }}> -
- {{ end }} - {{ else }} - {{ if (eq .name .kind) }} - {{ .kind }} - {{ else }} - {{ with .name }} -
- {{ . }}{{ if $.isPointer }} - * - {{ end }}: -
- {{ end }} - {{ if (eq $.kind "enum") }} - enum ( - {{ with $.enumValues }}{{ delimit . " | " }}{{ end }} - ) - {{ else }} - {{ .kind }} - {{ end }} - {{ end }} - {{ with .keys }} - { - {{ range . }} - - {{ end }} - } - {{ end }} - {{ end }} -
-{{ end }} - {{ define "main" }} - {{ $keys := .Site.Data.api.v310.api }}
{{ .Content }}
-
- {{ range $key, $spec := $keys }} -
-
-

- # - {{ $key }} {{ range .tags }} - {{ . }} - {{ end }} -

- {{ with .description }} -
{{ . }}
- {{ end }} - {{ with .schema }} -
- {{ template "schema" . }} -
- {{ end }} -
-
- {{ end }} -
{{ end }} diff --git a/layouts/api/single.html b/layouts/api/single.html new file mode 100644 index 0000000..e772fad --- /dev/null +++ b/layouts/api/single.html @@ -0,0 +1,116 @@ +{{ define "schema" }} + {{ with .description }}
{{ . }}
{{ end }} + + {{ with .element }} + {{ with $.name }} +
{{ . }}:
+ {{ end }} + {{ if (eq $.kind "array") }} + arrayOf [ + {{ template "schema" . }} + ] + {{ end }} + {{ if (eq $.kind "dictionary") }} + dictionary +
+ < + + {{ $.key.name }}, {{ template "schema" . }}> +
+ {{ end }} + {{ else }} + {{ if (eq .name .kind) }} + {{ .kind }} + {{ else }} + {{ with .name }} +
+ {{ . }}{{ if $.isPointer }} + * + {{ end }}: +
+ {{ end }} + {{ if (eq $.kind "enum") }} + enum ( + {{ with $.enumValues }}{{ delimit . " | " }}{{ end }} + ) + {{ else }} + {{ .kind }} + {{ end }} + {{ end }} + {{ with .keys }} + { + {{ range . }} + + {{ end }} + } + {{ end }} + {{ end }} +
+{{ end }} + +{{ define "main" }} + {{ $datafile := index .Site.Data.api .Params.version }} + {{ $keys := $datafile.api }} +
+ +
+
+

strimertül {{ .Title }} API

+ {{ .Content }} +
+
+ {{ range $key, $spec := $keys }} +
+
+

+ # + {{ $key }} {{ range .tags }} + {{ . }} + {{ end }} +

+ {{ with .description }} +
{{ . }}
+ {{ end }} + {{ with .schema }} +
+ {{ template "schema" . }} +
+ {{ end }} +
+
+ {{ end }} +
+
+
+ +{{ end }} diff --git a/static/script/apiselector.js b/static/script/apiselector.js new file mode 100644 index 0000000..178f33b --- /dev/null +++ b/static/script/apiselector.js @@ -0,0 +1,4 @@ +const apiselect = document.getElementById("api-version"); +apiselect.addEventListener("change", (ev) => { + location.href = ev.target.value; +}); diff --git a/themes/strimertul/assets/scss/guide.scss b/themes/strimertul/assets/scss/guide.scss index 4d157f0..60973f6 100644 --- a/themes/strimertul/assets/scss/guide.scss +++ b/themes/strimertul/assets/scss/guide.scss @@ -21,6 +21,8 @@ padding: 1rem; } & > nav { + display: flex; + flex-direction: column; background-color: $gray2; padding: 0; grid-column: 1; @@ -97,6 +99,17 @@ } } +select { + background-color: $gray2; + color: $gray12; + border-radius: 4px; +} + +#api-version { + margin: 1rem; + margin-bottom: 0; +} + .schema { margin-top: 1rem; code > ul:first-of-type > li > blockquote {