diff --git a/i18n/en.yaml b/i18n/en.yaml index 1a2d50bb..be71b92b 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -89,6 +89,8 @@ translation: "Link" - id: code translation: "Code" +- id: latest + translation: "latest" # 404 page - id: pageNotFound diff --git a/i18n/nl.yaml b/i18n/nl.yaml index 11e824bc..d27db5fa 100644 --- a/i18n/nl.yaml +++ b/i18n/nl.yaml @@ -79,6 +79,8 @@ translation: "Link" - id: code translation: "Code" +- id: latest + translation: "meest recente" # 404 page - id: pageNotFound diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 528e11c1..224162af 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,6 +1,7 @@ {{- $section := .Section }} -{{- with partial "utilities/GetMenu" . }}{{ $.Scratch.Set "sidebar" . }}{{ end -}} -{{ $.Scratch.Set "version" (site.Param (printf "%s.version" .Section)) }} +{{- $version := partial "utilities/GetVersion.html" (dict "page" . "base" true) -}} +{{- $.Scratch.Set "version" $version -}} +{{ with partial "utilities/GetMenu" (dict "page" . "version" $version) }}{{ $.Scratch.Set "sidebar" . }}{{ end }} diff --git a/layouts/partials/assets/navbar.html b/layouts/partials/assets/navbar.html index 5fbe39f4..2f061898 100644 --- a/layouts/partials/assets/navbar.html +++ b/layouts/partials/assets/navbar.html @@ -48,6 +48,39 @@ {{- end -}} + +{{- define "partials/navbar-versions.html" -}} + {{- $size := .size -}} + {{- $collapsed := .collapsed -}} + {{- $page := .page -}} + {{- $list := site.Params.docs.releases -}} + {{- $version := partial "utilities/GetVersion.html" (dict "page" $page) -}} + + +{{- end -}} + {{- $supportedFlags := slice "true" "false" -}} {{- $id := printf "navbar-collapse-%d" 0 -}} @@ -112,6 +145,12 @@ {{- end -}} {{- end -}} +{{- $enableVersions := false -}} +{{ $list := site.Params.docs.releases }} +{{ if $list }} + {{- $enableVersions = gt (len $list ) 1 -}} +{{ end }} + {{- $enableLanguage := or $page.IsTranslated site.IsMultiLingual -}} {{- $logo := site.Params.navigation.logo -}} @@ -185,7 +224,7 @@ {{- end -}} - {{- if or $enableLanguage $enableDarkMode -}} + {{- if or $enableLanguage $enableVersions -}} @@ -216,8 +255,20 @@ {{- end -}} + + {{- if $enableVersions -}} + {{- partial "partials/navbar-versions.html" (dict "page" $page "size" $size "collapsed" true ) -}} + {{- partial "partials/navbar-versions.html" (dict "page" $page "size" $size "collapsed" false) -}} + {{- end -}} + {{- if $enableDarkMode -}} + + +
  • + {{- partial "partials/navbar-mode.html" (dict "size" $size "collapsed" true) -}} {{- partial "partials/navbar-mode.html" (dict "size" $size "collapsed" false) -}} {{- end -}} diff --git a/layouts/partials/utilities/GetMenu.html b/layouts/partials/utilities/GetMenu.html index b81a0c64..344a335e 100644 --- a/layouts/partials/utilities/GetMenu.html +++ b/layouts/partials/utilities/GetMenu.html @@ -1,6 +1,12 @@ +{{- $page := .page -}} +{{- $version := .version -}} + {{- $menu := "" -}} -{{- if .IsPage -}} - {{- $menu = index .Site.Data .Section -}} +{{- if $page.IsPage -}} + {{- $menu = index site.Data (printf "%s-%s" $page.Section $version) -}} + {{ if not $menu }} + {{ $menu = index site.Data $page.Section }} + {{ end }} {{- end -}} {{- return $menu -}} \ No newline at end of file diff --git a/layouts/partials/utilities/GetVersion.html b/layouts/partials/utilities/GetVersion.html new file mode 100644 index 00000000..523cdd07 --- /dev/null +++ b/layouts/partials/utilities/GetVersion.html @@ -0,0 +1,34 @@ + + +{{- $page := .page -}} +{{- $base := .base -}} +{{- $version := "" -}} + +{{- $docsPath := strings.TrimPrefix "/" site.Params.docs.contentPath -}} +{{- if and $page.File (strings.HasPrefix $page.File.Dir $docsPath) -}} + {{- $currentPath := strings.TrimPrefix $docsPath $page.File.Dir -}} + {{- $currentVersion := index (split $currentPath "/") 0 -}} + {{- $versionPath := path.Join site.Params.docs.contentPath $currentVersion -}} + + {{- $list := site.Params.docs.releases -}} + {{- range $index, $item := $list -}} + {{- $url := strings.TrimSuffix "/" $item.url -}} + {{- if eq $url $versionPath -}} + {{- if $base }}{{ $version = path.Base $item.url }}{{ else }}{{ $version = $item.label }}{{ end -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- if not $version -}} + {{- $list := site.Params.docs.releases -}} + {{- range $item := $list -}} + {{- if $item.latest -}} + {{- if $base }}{{ $version = path.Base $item.url }}{{ else }}{{ $version = $item.label }}{{ end -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- return $version -}} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 12c6849d..0561bf57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gethinode/hinode", - "version": "0.14.7", + "version": "0.15.0-alpha", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gethinode/hinode", - "version": "0.14.7", + "version": "0.15.0-alpha", "license": "MIT", "devDependencies": { "@fortawesome/fontawesome-free": "^6.4.0", diff --git a/package.json b/package.json index 8da6c3bf..c8987450 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gethinode/hinode", - "version": "0.14.7", + "version": "0.15.0-alpha", "description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator", "keywords": [ "hugo",