index.hbs

  1<!DOCTYPE HTML>
  2<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}">
  3    <head>
  4        <!-- Book generated using mdBook -->
  5        <meta charset="UTF-8">
  6        <title>{{ title }}</title>
  7        {{#if is_print }}
  8        <meta name="robots" content="noindex">
  9        {{/if}}
 10        {{#if base_url}}
 11        <base href="{{ base_url }}">
 12        {{/if}}
 13
 14
 15        <!-- Custom HTML head -->
 16        {{> head}}
 17
 18        <meta name="description" content="{{ description }}">
 19        <meta name="viewport" content="width=device-width, initial-scale=1">
 20        <meta name="theme-color" content="#ffffff">
 21
 22        <link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
 23        <link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
 24        <link rel="stylesheet" href="{{ path_to_root }}css/general.css">
 25        <link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
 26        {{#if print_enable}}
 27        <link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
 28        {{/if}}
 29
 30        <!-- Fonts -->
 31        <link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
 32        {{#if copy_fonts}}
 33        <link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
 34        {{/if}}
 35
 36        <!-- Highlight.js Stylesheets -->
 37        <link rel="stylesheet" href="{{ path_to_root }}highlight.css">
 38        <link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
 39        <link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
 40
 41        <!-- Custom theme stylesheets -->
 42        {{#each additional_css}}
 43        <link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
 44        {{/each}}
 45
 46        {{#if mathjax_support}}
 47        <!-- MathJax -->
 48        <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 49        {{/if}}
 50    </head>
 51    <body class="sidebar-visible no-js">
 52    <div id="body-container">
 53        <!-- Provide site root to javascript -->
 54        <script>
 55            var path_to_root = "{{ path_to_root }}";
 56            var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
 57        </script>
 58
 59        <!-- Set the theme before any content is loaded, prevents flash -->
 60        <script>
 61            var theme;
 62            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
 63            if (theme === null || theme === undefined) { theme = default_theme; }
 64            var html = document.querySelector('html');
 65            html.classList.remove('{{ default_theme }}')
 66            html.classList.add(theme);
 67            var body = document.querySelector('body');
 68            body.classList.remove('no-js')
 69            body.classList.add('js');
 70        </script>
 71
 72        <input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
 73
 74        <!-- Hide / unhide sidebar before it is displayed -->
 75        <script>
 76            var body = document.querySelector('body');
 77            var sidebar = null;
 78            var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
 79            if (document.body.clientWidth >= 1080) {
 80                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
 81                sidebar = sidebar || 'visible';
 82            } else {
 83                sidebar = 'hidden';
 84            }
 85            sidebar_toggle.checked = sidebar === 'visible';
 86            body.classList.remove('sidebar-visible');
 87            body.classList.add("sidebar-" + sidebar);
 88        </script>
 89
 90        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
 91            <div class="sidebar-scrollbox">
 92                {{#toc}}{{/toc}}
 93            </div>
 94            <div style="display: none;" id="sidebar-resize-handle" class="sidebar-resize-handle">
 95                <div class="sidebar-resize-indicator"></div>
 96            </div>
 97        </nav>
 98
 99        <!-- Track and set sidebar scroll position -->
100        <script>
101            var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
102            sidebarScrollbox.addEventListener('click', function(e) {
103                if (e.target.tagName === 'A') {
104                    sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
105                }
106            }, { passive: true });
107            var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
108            sessionStorage.removeItem('sidebar-scroll');
109            if (sidebarScrollTop) {
110                // preserve sidebar scroll position when navigating via links within sidebar
111                sidebarScrollbox.scrollTop = sidebarScrollTop;
112            } else {
113                // scroll sidebar to current active section when navigating via "next/previous chapter" buttons
114                var activeSection = document.querySelector('#sidebar .active');
115                if (activeSection) {
116                    activeSection.scrollIntoView({ block: 'center' });
117                }
118            }
119        </script>
120
121        <div id="page-wrapper" class="page-wrapper">
122            <div class="page">
123                {{> header}}
124                <div id="menu-bar-hover-placeholder"></div>
125                <div id="menu-bar" class="menu-bar sticky">
126                    <div class="left-buttons">
127                        <label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
128                            <i class="fa fa-bars"></i>
129                        </label>
130                        <button style="display: none;" id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
131                            <i class="fa fa-paint-brush"></i>
132                        </button>
133                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
134                            <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
135                            <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
136                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
137                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
138                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
139                        </ul>
140                        {{#if search_enabled}}
141                        <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
142                            <i class="fa fa-search"></i>
143                        </button>
144                        {{/if}}
145                    </div>
146
147                    <header class="menu-title">
148                        <a href="/">
149                            <img src="https://zed.dev/logo_wordmark_36.webp" alt="Zed Industries" style="height: 28px;">
150                        </a>
151                    </header>
152
153                    <div class="right-buttons">
154                        <a class="download-button" href="https://zed.dev/download" title="Download Zed" aria-label="Download Zed">
155                            Download
156                        </a>
157                        {{#if git_repository_url}}
158                        <a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
159                            <i id="git-repository-button" class="fa {{git_repository_icon}}"></i>
160                        </a>
161                        {{/if}}
162                        {{#if git_repository_edit_url}}
163                        <a href="{{git_repository_edit_url}}" title="Suggest an edit" aria-label="Suggest an edit">
164                            <i id="git-edit-button" class="fa fa-edit"></i>
165                        </a>
166                        {{/if}}
167                    </div>
168                </div>
169
170                {{#if search_enabled}}
171                <div id="search-wrapper" class="hidden">
172                    <form id="searchbar-outer" class="searchbar-outer">
173                        <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
174                    </form>
175                    <div id="searchresults-outer" class="searchresults-outer hidden">
176                        <div id="searchresults-header" class="searchresults-header"></div>
177                        <ul id="searchresults">
178                        </ul>
179                    </div>
180                </div>
181                {{/if}}
182
183                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
184                <script>
185                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
186                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
187                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
188                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
189                    });
190                </script>
191
192                <div id="content" class="content">
193                    <main>
194                      <div class="sidetoc">
195                          <nav class="pagetoc">
196                            <p class="toc-title">On this page</p>
197                          </nav>
198                      </div>
199                      {{{ content }}}
200                    </main>
201                </div>
202            </div>
203        </div>
204
205        {{#if live_reload_endpoint}}
206        <!-- Livereload script (if served using the cli tool) -->
207        <script>
208            const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
209            const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
210            const socket = new WebSocket(wsAddress);
211            socket.onmessage = function (event) {
212                if (event.data === "reload") {
213                    socket.close();
214                    location.reload();
215                }
216            };
217
218            window.onbeforeunload = function() {
219                socket.close();
220            }
221        </script>
222        {{/if}}
223
224        {{#if playground_line_numbers}}
225        <script>
226            window.playground_line_numbers = true;
227        </script>
228        {{/if}}
229
230        {{#if playground_copyable}}
231        <script>
232            window.playground_copyable = true;
233        </script>
234        {{/if}}
235
236        {{#if playground_js}}
237        <script src="{{ path_to_root }}ace.js"></script>
238        <script src="{{ path_to_root }}editor.js"></script>
239        <script src="{{ path_to_root }}mode-rust.js"></script>
240        <script src="{{ path_to_root }}theme-dawn.js"></script>
241        <script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
242        {{/if}}
243
244        {{#if search_js}}
245        <script src="{{ path_to_root }}elasticlunr.min.js"></script>
246        <script src="{{ path_to_root }}mark.min.js"></script>
247        <script src="{{ path_to_root }}searcher.js"></script>
248        {{/if}}
249
250        <script src="{{ path_to_root }}clipboard.min.js"></script>
251        <script src="{{ path_to_root }}highlight.js"></script>
252        <script src="{{ path_to_root }}book.js"></script>
253
254        <!-- Custom JS scripts -->
255        {{#each additional_js}}
256        <script src="{{ ../path_to_root }}{{this}}"></script>
257        {{/each}}
258
259        {{#if is_print}}
260        {{#if mathjax_support}}
261        <script>
262        window.addEventListener('load', function() {
263            MathJax.Hub.Register.StartupHook('End', function() {
264                window.setTimeout(window.print, 100);
265            });
266        });
267        </script>
268        {{else}}
269        <script>
270        window.addEventListener('load', function() {
271            window.setTimeout(window.print, 100);
272        });
273        </script>
274        {{/if}}
275        {{/if}}
276
277    </div>
278    </body>
279</html>