Add menu-bar links

This commit is contained in:
Unisko PENG, 2023-03-29 10:23:35 +08:00
parent 46fcc478d0
commit 9e2ab10221
2 changed files with 246 additions and 231 deletions

View File

@ -113,9 +113,26 @@
</button> </button>
</div> </div>
<h1 class="menu-title">Yet another Chinese rust-lang book.</h1> <h3 class="menu-title">Yet another Chinese rust-lang book.</h3>
<div class="right-buttons"> <div class="right-buttons">
<a href="https://java.xfoss.com" title="Head First Java 中文版" aria-label="Head First Java 中文版">
☕·Head First Java 中文
</a>
<a href="https://ccna60d.xfoss.com" title="CCNA in 60 days" aria-label="CCNA 60 天">
🖧·60 天通过 CCNA
</a>
<a href="https://snippets.xfoss.com" title="代码片段与技术笔记code snippets and tech notes"
aria-label="代码片段与技术笔记code snippets and tech notes">
✨·代码片段与技术笔记
</a>
<a href="https://ts.xfoss.com" title="TypeScript 教程" aria-label="TypeScript 教程">
📜·TypeScript 教程
</a>
<a href="https://books.xfoss.com" title="捐赠donation" aria-label="捐赠donation">
🎁·捐赠donation
</a>
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>

View File

@ -58,7 +58,7 @@
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
<script> <script>
var path_to_root = "{{ path_to_root }}"; var path_to_root = "{{ path_to_root }}";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}"; var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
</script> </script>
<!-- Work around some values being stored in localStorage wrapped in quotes --> <!-- Work around some values being stored in localStorage wrapped in quotes -->
@ -80,27 +80,27 @@ var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ?
<!-- Set the theme before any content is loaded, prevents flash --> <!-- Set the theme before any content is loaded, prevents flash -->
<script> <script>
var theme; var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; } if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html'); var html = document.querySelector('html');
html.classList.remove('no-js') html.classList.remove('no-js')
html.classList.remove('{{ default_theme }}') html.classList.remove('{{ default_theme }}')
html.classList.add(theme); html.classList.add(theme);
html.classList.add('js'); html.classList.add('js');
</script> </script>
<!-- Hide / unhide sidebar before it is displayed --> <!-- Hide / unhide sidebar before it is displayed -->
<script> <script>
var html = document.querySelector('html'); var html = document.querySelector('html');
var sidebar = null; var sidebar = null;
if (document.body.clientWidth >= 1080) { if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible'; sidebar = sidebar || 'visible';
} else { } else {
sidebar = 'hidden'; sidebar = 'hidden';
} }
html.classList.remove('sidebar-visible'); html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar); html.classList.add("sidebar-" + sidebar);
</script> </script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
@ -140,11 +140,6 @@ html.classList.add("sidebar-" + sidebar);
<h3 class="menu-title">{{ book_title }}</h3> <h3 class="menu-title">{{ book_title }}</h3>
<div class="right-buttons"> <div class="right-buttons">
<a href="https://rust-lang.xfoss.com" title="Yet another Chinese rust-lang book"
aria-label="Yet another Chinese rust-lang book">
·Rust 官方书中文
</a>
<a href="https://java.xfoss.com" title="Head First Java 中文版" aria-label="Head First Java 中文版"> <a href="https://java.xfoss.com" title="Head First Java 中文版" aria-label="Head First Java 中文版">
☕·Head First Java 中文 ☕·Head First Java 中文
</a> </a>
@ -158,6 +153,9 @@ html.classList.add("sidebar-" + sidebar);
<a href="https://ts.xfoss.com" title="TypeScript 教程" aria-label="TypeScript 教程"> <a href="https://ts.xfoss.com" title="TypeScript 教程" aria-label="TypeScript 教程">
📜·TypeScript 教程 📜·TypeScript 教程
</a> </a>
<a href="https://books.xfoss.com" title="捐赠donation" aria-label="捐赠donation">
🎁·捐赠donation
</a>
{{#if print_enable}} {{#if print_enable}}
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book"> <a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
@ -194,10 +192,10 @@ html.classList.add("sidebar-" + sidebar);
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script> <script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible'); document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible'); document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) { Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1); link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
}); });
</script> </script>
<div id="content" class="content"> <div id="content" class="content">
@ -244,18 +242,18 @@ Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
<!-- Livereload script (if served using the cli tool) --> <!-- Livereload script (if served using the cli tool) -->
<script> <script>
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}"; const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
const socket = new WebSocket(wsAddress); const socket = new WebSocket(wsAddress);
socket.onmessage = function (event) { socket.onmessage = function (event) {
if (event.data === "reload") { if (event.data === "reload") {
socket.close(); socket.close();
location.reload(); location.reload();
} }
}; };
window.onbeforeunload = function() { window.onbeforeunload = function() {
socket.close(); socket.close();
} }
</script> </script>
{{/if}} {{/if}}
@ -264,9 +262,9 @@ window.onbeforeunload = function() {
<script> <script>
var localAddrs = ["localhost", "127.0.0.1", ""]; var localAddrs = ["localhost", "127.0.0.1", ""];
// make sure we don't activate google analytics if the developer is // make sure we don't activate google analytics if the developer is
// inspecting the book locally... // inspecting the book locally...
if (localAddrs.indexOf(document.location.hostname) === -1) { if (localAddrs.indexOf(document.location.hostname) === -1) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
@ -274,7 +272,7 @@ if (localAddrs.indexOf(document.location.hostname) === -1) {
ga('create', '{{google_analytics}}', 'auto'); ga('create', '{{google_analytics}}', 'auto');
ga('send', 'pageview'); ga('send', 'pageview');
} }
</script> </script>
{{/if}} {{/if}}