Commit dc5174440c

r00ster91 <r00ster91@proton.me>
2022-08-14 11:28:12
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
Changed files (2)
lib/docs/index.html
@@ -654,7 +654,13 @@
             </div>
             <div id="sectSearchNoResults" class="hidden">
               <h2>No Results Found</h2>
-              <p>Press escape to exit search and then '?' to see more options.</p>
+              <p>Here are some things you can try:</p>
+              <ul>
+                <li>Check out the <a id="langRefLink">Language Reference</a> for the language itself.</li>
+                <li>Check out the <a href="https://ziglang.org/learn/">Learn page</a> for other helpful resources for learning Zig.</li>
+                <li>Use your search engine.</li>
+              </ul>
+              <p>Press <kbd>?</kbd> to see keyboard shortcuts and <kbd>Esc</kbd> to return.</p>
             </div>
             <div id="sectFields" class="hidden">
               <h2>Fields</h2>
lib/docs/main.js
@@ -51,6 +51,7 @@ var zigAnalysis;
   const domHdrName = document.getElementById("hdrName");
   const domHelpModal = document.getElementById("helpModal");
   const domSearchPlaceholder = document.getElementById("searchPlaceholder");
+  const domLangRefLink = document.getElementById("langRefLink");
 
   let searchTimer = null;
   let searchTrimResults = true;
@@ -161,6 +162,13 @@ var zigAnalysis;
   window.addEventListener("keydown", onWindowKeyDown, false);
   onHashChange();
 
+  let langRefVersion = zigAnalysis.params.zigVersion;
+  if (!/^\d+\.\d+\.\d+$/.test(langRefVersion)) {
+    // the version is probably not released yet
+    langRefVersion = "master";
+  }
+  domLangRefLink.href = `https://ziglang.org/documentation/${langRefVersion}/`;
+
   function renderTitle() {
     let list = curNav.pkgNames.concat(curNav.declNames);
     let suffix = " - Zig";