From da7cd111cb9a9b15ffaf6dc1306d59270cf53809 Mon Sep 17 00:00:00 2001 From: Pete Lumbis Date: Tue, 13 Sep 2022 17:35:20 -0400 Subject: [PATCH] new template components specific to docs pages Signed-off-by: Pete Lumbis --- .../layouts/partials/docs/github-edit.html | 7 + .../layouts/partials/docs/js-footer.html | 136 ++++++++++++++++++ .../layouts/partials/docs/version-alert.html | 22 +++ .../docs/versions-dropdown-selector.html | 63 ++++++++ 4 files changed, 228 insertions(+) create mode 100644 themes/crossplane/layouts/partials/docs/github-edit.html create mode 100644 themes/crossplane/layouts/partials/docs/js-footer.html create mode 100644 themes/crossplane/layouts/partials/docs/version-alert.html create mode 100644 themes/crossplane/layouts/partials/docs/versions-dropdown-selector.html diff --git a/themes/crossplane/layouts/partials/docs/github-edit.html b/themes/crossplane/layouts/partials/docs/github-edit.html new file mode 100644 index 00000000..a189a5d8 --- /dev/null +++ b/themes/crossplane/layouts/partials/docs/github-edit.html @@ -0,0 +1,7 @@ +
+ {{- if eq .Page.Params.version "master" -}} + Edit on GitHub + {{- else -}} + Edit on GitHub + {{- end -}} +
\ No newline at end of file diff --git a/themes/crossplane/layouts/partials/docs/js-footer.html b/themes/crossplane/layouts/partials/docs/js-footer.html new file mode 100644 index 00000000..2d0840d4 --- /dev/null +++ b/themes/crossplane/layouts/partials/docs/js-footer.html @@ -0,0 +1,136 @@ + \ No newline at end of file diff --git a/themes/crossplane/layouts/partials/docs/version-alert.html b/themes/crossplane/layouts/partials/docs/version-alert.html new file mode 100644 index 00000000..1d26357b --- /dev/null +++ b/themes/crossplane/layouts/partials/docs/version-alert.html @@ -0,0 +1,22 @@ +{{- if eq .Page.Params.version "master" -}} +
+

+ PLEASE NOTE: This document applies to an unreleased version of Crossplane. It is strongly recommended that you only use official releases of Crossplane, as unreleased versions are subject to changes and incompatibilities that will not be supported in the official releases. +

+

+ If you are using an official release version of Crossplane, you should refer to the documentation for your specific version. +

+ + Documentation for other releases can be found by using the version selector in the top right of any doc page. + +
+{{- else if lt .Page.Params.version .Site.Params.latest -}} +
+

+ PLEASE NOTE: This document applies to version {{ .Page.Params.version }} and not to the latest release {{.Site.Params.latest}} +

+ + Documentation for other releases can be found by using the version selector in the top right of any doc page. + +
+{{- end -}} diff --git a/themes/crossplane/layouts/partials/docs/versions-dropdown-selector.html b/themes/crossplane/layouts/partials/docs/versions-dropdown-selector.html new file mode 100644 index 00000000..83465be2 --- /dev/null +++ b/themes/crossplane/layouts/partials/docs/versions-dropdown-selector.html @@ -0,0 +1,63 @@ +{{ $versionList := slice }} +{{ $master_ver := false }} + + +{{ range .Site.Sections }} + {{ if eq .Page.Params.version "master" }} + + {{ $master_ver = true }} + {{ else if ne .Page.Params.version nil }} + {{/* Semver slicing from https://discourse.gohugo.io/t/sort-strings-based-on-semver/14425 */}} + {{- $ver_major_minor := (float (replaceRE "([0-9]+\\.[0-9]+).*" "${1}" .Page.Params.version)) -}} + {{- $ver_micro_str := (replaceRE "[0-9]+\\.[0-9]+(.*)" "${1}" .Page.Params.version | replaceRE "-DEV" "-0.01") -}} + {{- $ver_micro := (div (float (or $ver_micro_str "0")) 100.00) -}} + {{- $ver_float := (add $ver_major_minor $ver_micro) -}} + {{- $versionList = $versionList | append $ver_float -}} + {{ end }} +{{ end }} + + +{{ $version_dict := slice }} +{{ range (uniq $versionList) }} + {{ $version_dict = $version_dict | append (dict "ver" .)}} +{{ end }} + + +{{ $sorted_list := slice }} +{{ range sort $version_dict "ver" "desc" }} + {{ range $k, $v := . }} + {{ $sorted_list = $sorted_list | append $v }} + {{ end }} +{{ end }} + +{{ $cur_ver := .Page.Params.version }} +
+
+

Documentation

+ {{ if eq .Site.Params.latest $cur_ver }} +
+ {{ else }} +
+ {{ end }} +
+
+
+