Skip to content

Commit dc51744

Browse files
author
r00ster91
committed
feat: better No Results Found page
This adds some helpful links to the page and makes it look nicer by using <kbd> etc.
1 parent 7e07f3d commit dc51744

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/docs/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,13 @@ <h2>Search Results</h2>
654654
</div>
655655
<div id="sectSearchNoResults" class="hidden">
656656
<h2>No Results Found</h2>
657-
<p>Press escape to exit search and then '?' to see more options.</p>
657+
<p>Here are some things you can try:</p>
658+
<ul>
659+
<li>Check out the <a id="langRefLink">Language Reference</a> for the language itself.</li>
660+
<li>Check out the <a href="https://ziglang.org/learn/">Learn page</a> for other helpful resources for learning Zig.</li>
661+
<li>Use your search engine.</li>
662+
</ul>
663+
<p>Press <kbd>?</kbd> to see keyboard shortcuts and <kbd>Esc</kbd> to return.</p>
658664
</div>
659665
<div id="sectFields" class="hidden">
660666
<h2>Fields</h2>

lib/docs/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ var zigAnalysis;
5151
const domHdrName = document.getElementById("hdrName");
5252
const domHelpModal = document.getElementById("helpModal");
5353
const domSearchPlaceholder = document.getElementById("searchPlaceholder");
54+
const domLangRefLink = document.getElementById("langRefLink");
5455

5556
let searchTimer = null;
5657
let searchTrimResults = true;
@@ -161,6 +162,13 @@ var zigAnalysis;
161162
window.addEventListener("keydown", onWindowKeyDown, false);
162163
onHashChange();
163164

165+
let langRefVersion = zigAnalysis.params.zigVersion;
166+
if (!/^\d+\.\d+\.\d+$/.test(langRefVersion)) {
167+
// the version is probably not released yet
168+
langRefVersion = "master";
169+
}
170+
domLangRefLink.href = `https://ziglang.org/documentation/${langRefVersion}/`;
171+
164172
function renderTitle() {
165173
let list = curNav.pkgNames.concat(curNav.declNames);
166174
let suffix = " - Zig";

0 commit comments

Comments
 (0)