mirror of
https://github.com/gnu4cn/rust-lang-zh_CN.git
synced 2025-02-10 03:20:14 +08:00
Update theme/index.hbs
This commit is contained in:
parent
9dc9533290
commit
46fcc478d0
@ -58,7 +58,7 @@
|
||||
<!-- Provide site root to javascript -->
|
||||
<script>
|
||||
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>
|
||||
|
||||
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
||||
@ -80,27 +80,27 @@
|
||||
<!-- Set the theme before any content is loaded, prevents flash -->
|
||||
<script>
|
||||
var theme;
|
||||
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
||||
if (theme === null || theme === undefined) { theme = default_theme; }
|
||||
var html = document.querySelector('html');
|
||||
html.classList.remove('no-js')
|
||||
html.classList.remove('{{ default_theme }}')
|
||||
html.classList.add(theme);
|
||||
html.classList.add('js');
|
||||
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
||||
if (theme === null || theme === undefined) { theme = default_theme; }
|
||||
var html = document.querySelector('html');
|
||||
html.classList.remove('no-js')
|
||||
html.classList.remove('{{ default_theme }}')
|
||||
html.classList.add(theme);
|
||||
html.classList.add('js');
|
||||
</script>
|
||||
|
||||
<!-- Hide / unhide sidebar before it is displayed -->
|
||||
<script>
|
||||
var html = document.querySelector('html');
|
||||
var sidebar = null;
|
||||
if (document.body.clientWidth >= 1080) {
|
||||
var sidebar = null;
|
||||
if (document.body.clientWidth >= 1080) {
|
||||
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
||||
sidebar = sidebar || 'visible';
|
||||
} else {
|
||||
} else {
|
||||
sidebar = 'hidden';
|
||||
}
|
||||
html.classList.remove('sidebar-visible');
|
||||
html.classList.add("sidebar-" + sidebar);
|
||||
}
|
||||
html.classList.remove('sidebar-visible');
|
||||
html.classList.add("sidebar-" + sidebar);
|
||||
</script>
|
||||
|
||||
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
||||
@ -140,7 +140,25 @@
|
||||
<h3 class="menu-title">{{ book_title }}</h3>
|
||||
|
||||
<div class="right-buttons">
|
||||
<a href="https://java.xfoss.com" title="Head First Java 中文版" title="Head First Java 中文版">Head First Java 中文</a>
|
||||
<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 中文版">
|
||||
☕·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>
|
||||
|
||||
{{#if print_enable}}
|
||||
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
|
||||
<i id="print-button" class="fa fa-print"></i>
|
||||
@ -176,10 +194,10 @@
|
||||
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
||||
<script>
|
||||
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
||||
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
||||
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
||||
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
||||
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
||||
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="content" class="content">
|
||||
@ -226,18 +244,18 @@
|
||||
<!-- Livereload script (if served using the cli tool) -->
|
||||
<script>
|
||||
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
|
||||
const socket = new WebSocket(wsAddress);
|
||||
socket.onmessage = function (event) {
|
||||
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
|
||||
const socket = new WebSocket(wsAddress);
|
||||
socket.onmessage = function (event) {
|
||||
if (event.data === "reload") {
|
||||
socket.close();
|
||||
location.reload();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
window.onbeforeunload = function() {
|
||||
window.onbeforeunload = function() {
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{{/if}}
|
||||
|
||||
@ -246,9 +264,9 @@
|
||||
<script>
|
||||
var localAddrs = ["localhost", "127.0.0.1", ""];
|
||||
|
||||
// make sure we don't activate google analytics if the developer is
|
||||
// inspecting the book locally...
|
||||
if (localAddrs.indexOf(document.location.hostname) === -1) {
|
||||
// make sure we don't activate google analytics if the developer is
|
||||
// inspecting the book locally...
|
||||
if (localAddrs.indexOf(document.location.hostname) === -1) {
|
||||
(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),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
@ -256,7 +274,7 @@
|
||||
|
||||
ga('create', '{{google_analytics}}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{{/if}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user