123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <div class="sidebar-wrapper">
- {{ $currentPage := . }}
- <nav role="navigation" class="sidebar">
- <ul>
- <div id="docsearch"></div>
- <select id="version-select" class="version-dropdown" style="width: 100%; box-sizing: border-box;">
- </select>
- <br><br>
- {{ range .Site.Menus.main.ByWeight }}
- <li class="level-1 {{if .HasChildren }}has-children{{ else }}no-children{{ end }}">
- <a {{with .URL}}href="{{.}}"{{end}} class="{{if $currentPage.IsMenuCurrent "main" .}}active{{end}}">
- {{- if .HasChildren }}
- {{ readFile "static/images/icon_sidebar_expander.svg" | safeHTML }}
- {{ end }}
- {{.Name | markdownify}}
- </a>
- {{- if .HasChildren }}
- <ul>
- {{- range .Children }}
- <li class="level-2 {{if .HasChildren }}has-children{{ else }}no-children{{ end }}">
- <a {{with .URL}}href="{{.}}"{{end}} class="{{if $currentPage.IsMenuCurrent "main" .}}active{{end}}">
- {{- if .HasChildren }}
- {{ readFile "static/images/icon_sidebar_expander.svg" | safeHTML }}
- {{ end }}
- {{.Name | markdownify}}
- </a>
- {{- if .HasChildren }}
- <ul>
- {{- range .Children }}
- <li class="level-3 {{if .HasChildren }}has-children{{ else }}no-children{{ end }}">
- <a {{with .URL}}href="{{.}}"{{end}} class="{{if $currentPage.IsMenuCurrent "main" .}}active{{end}}">
- {{- if .HasChildren }}
- {{ readFile "static/images/icon_sidebar_expander.svg" | safeHTML }}
- {{ end }}
- {{.Name | markdownify}}
- </a>
- {{- if .HasChildren }}
- <ul>
- {{- range .Children }}
- <li class="level-4">
- <a href="{{.URL}}" class="{{if $currentPage.IsMenuCurrent "main" .}}active{{end}}">
- {{.Name | markdownify}}
- </a>
- </li>
- {{- end}}
- </ul>
- {{- end}}
- </li>
- {{- end}}
- </ul>
- {{- end}}
- </li>
- {{- end}}
- </ul>
- {{- end}}
- </li>
- {{- end}}
- </ul>
- </nav>
- <button class="close-topics" aria-label="Close the topics sidebar">
- <svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512"><title>Close</title><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 368L144 144M368 144L144 368"/></svg>
- </button>
- </div>
- <script>
- document.addEventListener('DOMContentLoaded', function () {
- const versionSelect = document.getElementById('version-select');
- const currentPath = window.location.pathname;
- fetch('/docs/versions.json')
- .then( response => {
- if (!response.ok) {
- throw new Error('File not found');
- }
- return response.json();
- })
- .catch(() => {
- return fetch('{{ .Site.BaseURL }}versions.json')
- .then(response => {
- if (!response.ok) {
- throw new Error('Fallback file not found');
- }
- return response.json();
- });
- })
- .then(versions => {
- versions.forEach(version => {
- const option = document.createElement('option');
- option.value = version.base_url;
- option.textContent = version.name;
- versionSelect.appendChild(option);
- });
- const currentVersion = versions.filter(version => currentPath.includes(version.base_url))?.at(-1)?.base_url;
- if (currentVersion) {
- versionSelect.value = currentVersion;
- }
- versionSelect.addEventListener('change', function () {
- const baseUrl = '{{ .Site.BaseURL }}';
- const strippedBaseUrl = baseUrl.endsWith(currentVersion) ? baseUrl.slice(0, -currentVersion.length) : baseUrl;
- const selectedBaseUrl = strippedBaseUrl + versionSelect.value;
- if (selectedBaseUrl) {
- window.location.href = selectedBaseUrl;
- }
- });
- })
- .catch(error => console.error('Error fetching versions:', error));
- });
- </script>
|