Skip to content

Commit db8d8b7

Browse files
committed
install page: Automatically link to correct OS directions
Add a script that will update the homepage / sidebar links to the appropriate OS-specific link. This falls back gracefully: if the script doesn't run, you can just go to /install/ and click on the appropriate page. Signed-off-by: Julia Evans <[email protected]>
1 parent 6f024fd commit db8d8b7

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

assets/js/application.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ $(document).ready(function() {
3636
Forms.init();
3737
Downloads.init();
3838
DownloadBox.init();
39+
InstallPageLink.init();
3940
PostelizeAnchor.init();
4041
Print.init();
4142
});
@@ -809,6 +810,22 @@ var Graphviz = {
809810
}
810811
}
811812

813+
var InstallPageLink = {
814+
init: function() {
815+
const installLink = document.querySelector('.install-link');
816+
if (!installLink) return;
817+
818+
const os = window.session?.browser?.os;
819+
if (os === "Mac") {
820+
installLink.href = installLink.href.replace('/install', '/install/mac');
821+
} else if (os === "Windows") {
822+
installLink.href = installLink.href.replace('/install', '/install/win');
823+
} else if (os === "Linux") {
824+
installLink.href = installLink.href.replace('/install', '/install/linux');
825+
}
826+
}
827+
}
828+
812829
var Print = {
813830
init: function() {
814831
Print.tagline = $("#tagline");

layouts/partials/sidebar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<a href="{{ relURL "docs" }}"{{ if or (eq .Params.Subsection "reference") (eq .Params.Subsection "manual") }} class="active"{{ end }}>Reference</a>
5555
</li>
5656
<li>
57-
<a href="{{ relURL "install" }}"{{ if (eq $section "install") }} class="active"{{ end }}>Install</a>
57+
<a href="{{ relURL "install" }}" class="install-link{{ if (eq $section "install") }} active{{ end }}">Install</a>
5858
</li>
5959
<li>
6060
<a href="{{ relURL "community" }}"{{ if (eq $section "community") }} class="active"{{ end }}>Community</a>

layouts/partials/site-root.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h3>Reference</h3>
3131
</a>
3232
</li>
3333
<li>
34-
<a href="{{ relURL "install" }}">
34+
<a class="install-link" href="{{ relURL "install" }}">
3535
<img src="{{ relURL "images/icons/fa-down-long.svg" }}" width="74" height="74" />
3636
<h3>Install</h3>
3737
<p>Binary releases for all major platforms.</p>

0 commit comments

Comments
 (0)