|
20 | 20 | <meta name="theme-color" content="#251e17">
|
21 | 21 |
|
22 | 22 | {{#if favicon_svg}}
|
23 |
| - <link rel="icon" href="{{ path_to_root }}favicon.svg"> |
| 23 | + <link rel="icon" href="{{ resource "favicon.svg" }}"> |
24 | 24 | {{/if}}
|
25 | 25 | {{#if favicon_png}}
|
26 |
| - <link rel="shortcut icon" href="{{ path_to_root }}favicon.png"> |
| 26 | + <link rel="shortcut icon" href="{{ resource "favicon.png" }}"> |
27 | 27 | {{/if}}
|
28 |
| - <link rel="stylesheet" href="{{ path_to_root }}css/variables.css"> |
29 |
| - <link rel="stylesheet" href="{{ path_to_root }}css/general.css"> |
30 |
| - <link rel="stylesheet" href="{{ path_to_root }}css/chrome.css"> |
| 28 | + <link rel="stylesheet" href="{{ resource "css/variables.css" }}"> |
| 29 | + <link rel="stylesheet" href="{{ resource "css/general.css" }}"> |
| 30 | + <link rel="stylesheet" href="{{ resource "css/chrome.css" }}"> |
31 | 31 | {{#if print_enable}}
|
32 |
| - <link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print"> |
| 32 | + <link rel="stylesheet" href="{{ resource "css/print.css" }}" media="print"> |
33 | 33 | {{/if}}
|
34 | 34 |
|
35 | 35 | <!-- Fonts -->
|
36 |
| - <link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css"> |
| 36 | + <link rel="stylesheet" href="{{ resource "FontAwesome/css/font-awesome.css" }}"> |
37 | 37 | {{#if copy_fonts}}
|
38 |
| - <link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css"> |
| 38 | + <link rel="stylesheet" href="{{ resource "fonts/fonts.css" }}"> |
39 | 39 | {{/if}}
|
40 | 40 |
|
41 | 41 | <!-- Highlight.js Stylesheets -->
|
42 |
| - <link rel="stylesheet" href="{{ path_to_root }}highlight.css"> |
43 |
| - <link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css"> |
44 |
| - <link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css"> |
| 42 | + <link rel="stylesheet" id="highlight-css" href="{{ resource "highlight.css" }}"> |
| 43 | + <link rel="stylesheet" id="tomorrow-night-css" href="{{ resource "tomorrow-night.css" }}"> |
| 44 | + <link rel="stylesheet" id="ayu-highlight-css" href="{{ resource "ayu-highlight.css" }}"> |
45 | 45 |
|
46 | 46 | <!-- Custom theme stylesheets -->
|
47 | 47 | {{#each additional_css}}
|
48 |
| - <link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}"> |
| 48 | + <link rel="stylesheet" href="{{ resource this }}"> |
49 | 49 | {{/each}}
|
50 | 50 |
|
51 | 51 | {{#if mathjax_support}}
|
52 | 52 | <!-- MathJax -->
|
53 | 53 | <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
54 | 54 | {{/if}}
|
55 |
| - </head> |
56 |
| - <body class="sidebar-visible no-js"> |
57 |
| - <div id="body-container"> |
58 |
| - <!-- Provide site root to javascript --> |
| 55 | + |
| 56 | + <!-- Provide site root and default themes to javascript --> |
59 | 57 | <script>
|
60 |
| - var path_to_root = "{{ path_to_root }}"; |
| 58 | + const path_to_root = "{{ path_to_root }}"; |
| 59 | + const default_light_theme = "{{ default_theme }}"; |
| 60 | + const default_dark_theme = "{{ preferred_dark_theme }}"; |
61 | 61 | </script>
|
62 |
| - |
| 62 | + <!-- Start loading toc.js asap --> |
| 63 | + <script src="{{ resource "toc.js" }}"></script> |
| 64 | + </head> |
| 65 | + <body> |
| 66 | + <div id="body-container"> |
63 | 67 | <!-- Work around some values being stored in localStorage wrapped in quotes -->
|
64 | 68 | <script>
|
65 | 69 | try {
|
66 |
| - var sidebar = localStorage.getItem('mdbook-sidebar'); |
| 70 | + let sidebar = localStorage.getItem('mdbook-sidebar'); |
67 | 71 |
|
68 | 72 | if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
69 | 73 | localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|
82 | 86 |
|
83 | 87 | <!-- Hide / unhide sidebar before it is displayed -->
|
84 | 88 | <script>
|
85 |
| - var body = document.querySelector('body'); |
86 |
| - var sidebar = null; |
87 |
| - var sidebar_toggle = document.getElementById("sidebar-toggle-anchor"); |
| 89 | + let sidebar = null; |
| 90 | + const sidebar_toggle = document.getElementById("sidebar-toggle-anchor"); |
88 | 91 | if (document.body.clientWidth >= 1080) {
|
89 | 92 | try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
90 | 93 | sidebar = sidebar || 'visible';
|
91 | 94 | } else {
|
92 | 95 | sidebar = 'hidden';
|
93 | 96 | }
|
94 | 97 | sidebar_toggle.checked = sidebar === 'visible';
|
95 |
| - body.classList.remove('sidebar-visible'); |
96 |
| - body.classList.add("sidebar-" + sidebar); |
| 98 | + html.classList.remove('sidebar-visible'); |
| 99 | + html.classList.add("sidebar-" + sidebar); |
97 | 100 | </script>
|
98 | 101 |
|
99 | 102 | <nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
100 |
| - <div class="sidebar-scrollbox"> |
101 |
| - {{#toc}}{{/toc}} |
102 |
| - </div> |
| 103 | + <!-- populated by js --> |
| 104 | + <mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox> |
| 105 | + <noscript> |
| 106 | + <iframe class="sidebar-iframe-outer" src="{{ path_to_root }}toc.html"></iframe> |
| 107 | + </noscript> |
103 | 108 | </nav>
|
104 | 109 |
|
105 |
| - <!-- Track and set sidebar scroll position --> |
106 |
| - <script> |
107 |
| - var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox'); |
108 |
| - sidebarScrollbox.addEventListener('click', function(e) { |
109 |
| - if (e.target.tagName === 'A') { |
110 |
| - sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop); |
111 |
| - } |
112 |
| - }, { passive: true }); |
113 |
| - var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll'); |
114 |
| - sessionStorage.removeItem('sidebar-scroll'); |
115 |
| - if (sidebarScrollTop) { |
116 |
| - // preserve sidebar scroll position when navigating via links within sidebar |
117 |
| - sidebarScrollbox.scrollTop = sidebarScrollTop; |
118 |
| - } else { |
119 |
| - // scroll sidebar to current active section when navigating via "next/previous chapter" buttons |
120 |
| - var activeSection = document.querySelector('#sidebar .active'); |
121 |
| - if (activeSection) { |
122 |
| - activeSection.scrollIntoView({ block: 'center' }); |
123 |
| - } |
124 |
| - } |
125 |
| - </script> |
126 |
| - |
127 | 110 | <div id="page-wrapper" class="page-wrapper">
|
128 | 111 |
|
129 | 112 | <div class="page">
|
|
220 | 203 | {{/if}}
|
221 | 204 |
|
222 | 205 | {{#if playground_js}}
|
223 |
| - <script src="{{ path_to_root }}ace.js"></script> |
224 |
| - <script src="{{ path_to_root }}editor.js"></script> |
225 |
| - <script src="{{ path_to_root }}mode-rust.js"></script> |
226 |
| - <script src="{{ path_to_root }}theme-dawn.js"></script> |
227 |
| - <script src="{{ path_to_root }}theme-tomorrow_night.js"></script> |
| 206 | + <script src="{{ resource "ace.js" }}"></script> |
| 207 | + <script src="{{ resource "editor.js" }}"></script> |
| 208 | + <script src="{{ resource "mode-rust.js" }}"></script> |
| 209 | + <script src="{{ resource "theme-dawn.js" }}"></script> |
| 210 | + <script src="{{ resource "theme-tomorrow_night.js" }}"></script> |
228 | 211 | {{/if}}
|
229 | 212 |
|
230 | 213 | {{#if search_js}}
|
231 |
| - <script src="{{ path_to_root }}elasticlunr.min.js"></script> |
232 |
| - <script src="{{ path_to_root }}mark.min.js"></script> |
233 |
| - <script src="{{ path_to_root }}searcher.js"></script> |
| 214 | + <script src="{{ resource "elasticlunr.min.js" }}"></script> |
| 215 | + <script src="{{ resource "mark.min.js" }}"></script> |
| 216 | + <script src="{{ resource "searcher.js" }}"></script> |
234 | 217 | {{/if}}
|
235 | 218 |
|
236 |
| - <script src="{{ path_to_root }}clipboard.min.js"></script> |
237 |
| - <script src="{{ path_to_root }}highlight.js"></script> |
238 |
| - <script src="{{ path_to_root }}book.js"></script> |
| 219 | + <script src="{{ resource "clipboard.min.js" }}"></script> |
| 220 | + <script src="{{ resource "highlight.js" }}"></script> |
| 221 | + <script src="{{ resource "book.js" }}"></script> |
239 | 222 |
|
240 | 223 | <!-- Custom JS scripts -->
|
241 | 224 | {{#each additional_js}}
|
242 |
| - <script src="{{ ../path_to_root }}{{this}}"></script> |
| 225 | + <script src="{{ resource this}}"></script> |
243 | 226 | {{/each}}
|
244 | 227 |
|
245 | 228 | {{#if is_print}}
|
|
0 commit comments