Skip to content

Commit

Permalink
Fix multi-version navigation
Browse files Browse the repository at this point in the history
Updating version selector dropdown
* Allowing switching between historical versions of the same page

Removing hardcoded "v" from version code
* Potentially, not all versions will need to start with "v"

Updating hero.html
* correcting "Docs" button size

fixes: #82

Signed-off-by: Nate W <4453979+nate-double-u@users.noreply.github.com>
  • Loading branch information
nate-double-u committed Dec 30, 2020
1 parent 8d5bbc1 commit 4ee4190
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Latency from the etcd leader is the most important metric to track and the built
unsafe = true

[params.versions]
latest = "3.4.0"
all = ["3.4.0", "3.3.13", "3.3.12", "3.2.17", "3.1.12", "2"]
latest = "v3.4.0"
all = ["v3.4.0", "v3.3.13", "v3.3.12", "v3.2.17", "v3.1.12", "v2"]

[params.logos]
hero = "https://raw.githubusercontent.com/cncf/artwork/master/projects/etcd/horizontal/white/etcd-horizontal-white.png"
Expand Down
2 changes: 2 additions & 0 deletions content/docs/v2/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: etcd version 2
cascade:
version: v2
---

These docs cover everything from setting up and running an etcd cluster to using etcd in your applications. Improvements to these docs are encouraged through [pull requests](https://help.github.com/en/articles/about-pull-requests) to the [etcd project](https://github.com/etcd-io/etcd) on GitHub.
4 changes: 3 additions & 1 deletion content/docs/v3.1.12/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: etcd version 3.1.12
cascade:
version: v3.1.12
---

These docs cover everything from setting up and running an etcd cluster to using etcd in your applications. Improvements to these docs are encouraged through [pull requests](https://help.github.com/en/articles/about-pull-requests) to the [etcd project](https://github.com/etcd-io/etcd) on GitHub.
These docs cover everything from setting up and running an etcd cluster to using etcd in your applications. Improvements to these docs are encouraged through [pull requests](https://help.github.com/en/articles/about-pull-requests) to the [etcd project](https://github.com/etcd-io/etcd) on GitHub.
2 changes: 2 additions & 0 deletions content/docs/v3.2.17/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: etcd version 3.2.17
cascade:
version: v3.2.17
---

These docs cover everything from setting up and running an etcd cluster to using etcd in your applications. Improvements to these docs are encouraged through [pull requests](https://help.github.com/en/articles/about-pull-requests) to the [etcd project](https://github.com/etcd-io/etcd) on GitHub.
2 changes: 2 additions & 0 deletions content/docs/v3.3.12/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: etcd version 3.3.12
cascade:
version: v3.3.12
---

These docs cover everything from setting up and running an etcd cluster to using etcd in your applications. Improvements to these docs are encouraged through [pull requests](https://help.github.com/en/articles/about-pull-requests) to the [etcd project](https://github.com/etcd-io/etcd) on GitHub.
2 changes: 2 additions & 0 deletions content/docs/v3.3.13/_index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
title: etcd version 3.3.13
cascade:
version: v3.3.13
---
2 changes: 2 additions & 0 deletions content/docs/v3.4.0/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: etcd version 3.4.0
cascade:
version: v3.4.0
---

These docs cover everything from setting up and running an etcd cluster to using etcd in applications. Improvements to these docs are encouraged through [pull requests](https://help.github.com/en/articles/about-pull-requests) to the [etcd project](https://github.com/etcd-io/etcd) on GitHub.
24 changes: 13 additions & 11 deletions layouts/partials/docs/nav-panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{{ $editUrl := printf "https://github.com/etcd-io/website/edit/master/content/%s" .File.Path }}
{{ $latest := site.Params.versions.latest }}
{{ $ghUrl := printf "https://github.com/etcd-io/etcd/releases/tag/v%s" $latest }}
{{ $versions := site.Params.versions.all }}
{{ $version := index (split .Path "/") 1 }}
{{ $allDocs := where site.Sections "Section" "docs" }}
{{ $currentUrl := .RelPermalink }}
Expand Down Expand Up @@ -31,19 +30,22 @@

<div class="dropdown-menu">
<div class="dropdown-content">
{{ range $versions }}
{{ $v := printf "v%s" . }}
{{ $latest := printf "v%s" $latest }}
{{ $isLatest := eq $v $latest }}
<a class="navbar-item" href="/docs/v{{ . }}">
{{ . }}
{{ if $isLatest }}
(<strong>latest</strong>)
{{ end }}
</a>
{{/*
Version dropdown modified based on the work https://github.com/tbatard did on the velero site:
https://github.com/vmware-tanzu/velero/blob/main/site/layouts/docs/versions.html
*/}}
{{ $original_version := printf "/%s/" .CurrentSection.Params.version }}
{{ $latest_url := replace .Params.url .CurrentSection.Params.version .Site.Params.latest | relURL }}
{{ $currentUrl := .Permalink }}

{{ range .Site.Params.versions.all }}
{{ $new_version := printf "/%s/" . }}
<a class="navbar-item"
href="{{ replace $currentUrl $original_version $new_version | relURL }}">{{ . }}</a>
{{ end }}
</div>
</div>

</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/docs/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Home
</a>

<a class="navbar-item" href="/docs/v{{ $latest }}">
<a class="navbar-item" href="/docs/{{ $latest }}">
Docs home
</a>

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/home/hero.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<br />

<div class="buttons is-centered">
<a class="button is-primary is-inverted is-large is-radiusless" href="/docs/v{{ $latest }}">
<a class="button is-primary is-inverted is-medium is-radiusless" href="/docs/{{ $latest }}">
<span class="icon">
<i class="fas fa-info"></i>
</span>
Expand Down
4 changes: 2 additions & 2 deletions layouts/shortcodes/versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<ul>
{{ range $versions }}
<li>
<a href="/docs/v{{ . }}">
v{{ . }}
<a href="/docs/{{ . }}">
{{ . }}
</a>
</li>
{{ end }}
Expand Down

0 comments on commit 4ee4190

Please sign in to comment.