index.hbs

  1<!DOCTYPE HTML>
  2<html lang="{{ language }}" data-theme="{{ default_theme }}" data-color-scheme="{{ 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        <!-- Support dark mode -->
 60        <script>
 61            var theme;
 62            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
 63            if (theme === null || theme === undefined) {
 64                theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
 65            }
 66            var html = document.querySelector('html');
 67            html.classList.remove('light', 'dark')
 68            html.classList.add(theme);
 69            var body = document.querySelector('body');
 70            body.classList.remove('no-js')
 71            body.classList.add('js');
 72        </script>
 73
 74        <input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
 75
 76        <!-- Hide / unhide sidebar before it is displayed -->
 77        <script>
 78            var body = document.querySelector('body');
 79            var sidebar = null;
 80            var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
 81            if (document.body.clientWidth >= 1080) {
 82                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
 83                sidebar = sidebar || 'visible';
 84            } else {
 85                sidebar = 'hidden';
 86            }
 87            sidebar_toggle.checked = sidebar === 'visible';
 88            body.classList.remove('sidebar-visible');
 89            body.classList.add("sidebar-" + sidebar);
 90        </script>
 91
 92        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
 93            <div class="sidebar-scrollbox">
 94                {{#toc}}{{/toc}}
 95            </div>
 96            <div style="display: none;" id="sidebar-resize-handle" class="sidebar-resize-handle">
 97                <div class="sidebar-resize-indicator"></div>
 98            </div>
 99        </nav>
100
101        <!-- Track and set sidebar scroll position -->
102        <script>
103            var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
104            sidebarScrollbox.addEventListener('click', function(e) {
105                if (e.target.tagName === 'A') {
106                    sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
107                }
108            }, { passive: true });
109            var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
110            sessionStorage.removeItem('sidebar-scroll');
111            if (sidebarScrollTop) {
112                // preserve sidebar scroll position when navigating via links within sidebar
113                sidebarScrollbox.scrollTop = sidebarScrollTop;
114            } else {
115                // scroll sidebar to current active section when navigating via "next/previous chapter" buttons
116                var activeSection = document.querySelector('#sidebar .active');
117                if (activeSection) {
118                    activeSection.scrollIntoView({ block: 'center' });
119                }
120            }
121        </script>
122
123        <div id="page-wrapper" class="page-wrapper">
124            <div class="page">
125                {{> header}}
126                <div id="menu-bar-hover-placeholder"></div>
127                <div id="menu-bar" class="menu-bar sticky">
128                    <div class="left-buttons">
129
130                        <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">
131                            <i class="fa fa-bars"></i>
132                        </label>
133
134                        <button 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">
135                            <i class="fa fa-paint-brush"></i>
136                        </button>
137                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
138                            <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
139                            <li role="none"><button role="menuitem" class="theme" id="dark">Dark</button></li>
140                        </ul>
141
142                        <button id="copy-markdown-toggle" class="icon-button" type="button" title="Copy Page as Markdown" aria-label="Copy page as markdown">
143                            <i class="fa fa-copy"></i>
144                        </button>
145
146                        {{#if search_enabled}}
147                        <button id="search-toggle" class="icon-button" type="button" title="Search (s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
148                            <i class="fa fa-search"></i>
149                        </button>
150                        {{/if}}
151                    </div>
152
153                    <header class="menu-title">
154                        <a href="/">
155                            <img src="https://zed.dev/logo_wordmark_1500.webp" alt="Zed Industries" style="height: 28px;">
156                        </a>
157                    </header>
158
159                    <div class="right-buttons">
160                        <a class="download-button" href="https://zed.dev/download" title="Download Zed" aria-label="Download Zed">
161                            Download
162                        </a>
163                        {{#if git_repository_url}}
164                        <a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
165                            <i id="git-repository-button" class="fa {{git_repository_icon}}"></i>
166                        </a>
167                        {{/if}}
168                        {{#if git_repository_edit_url}}
169                        <a href="{{git_repository_edit_url}}" title="Suggest an edit" aria-label="Suggest an edit">
170                            <i id="git-edit-button" class="fa fa-edit"></i>
171                        </a>
172                        {{/if}}
173                    </div>
174                </div>
175
176                {{#if search_enabled}}
177                <div id="search-wrapper" class="hidden">
178                    <form id="searchbar-outer" class="searchbar-outer">
179                        <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
180                    </form>
181                    <div id="searchresults-outer" class="searchresults-outer hidden">
182                        <div id="searchresults-header" class="searchresults-header"></div>
183                        <ul id="searchresults">
184                        </ul>
185                    </div>
186                </div>
187                {{/if}}
188
189                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
190                <script>
191                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
192                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
193                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
194                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
195                    });
196                </script>
197
198                <div id="content" class="content">
199                    <main>
200                      <div class="sidetoc">
201                          <nav class="pagetoc">
202                            <p class="toc-title">On this page</p>
203                          </nav>
204                      </div>
205                      {{{ content }}}
206                        <div class="footer-buttons">
207                            {{#previous}}
208                            <a rel="prev" href="{{ path_to_root }}{{link}}" class="footer-button" title="{{title}}">
209                                <i class="fa fa-angle-left"></i>
210                                {{title}}
211                            </a>
212                            {{/previous}}
213                            {{#next}}
214                            <a rel="next" href="{{ path_to_root }}{{link}}" class="footer-button" title="{{title}}">
215                                {{title}}
216                                <i class="fa fa-angle-right"></i>
217                            </a>
218                            {{/next}}
219                        </div>
220                    </main>
221                </div>
222            </div>
223        </div>
224
225        {{#if live_reload_endpoint}}
226        <!-- Livereload script (if served using the cli tool) -->
227        <script>
228            const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
229            const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
230            const socket = new WebSocket(wsAddress);
231            socket.onmessage = function (event) {
232                if (event.data === "reload") {
233                    socket.close();
234                    location.reload();
235                }
236            };
237
238            window.onbeforeunload = function() {
239                socket.close();
240            }
241        </script>
242        {{/if}}
243
244        {{#if playground_line_numbers}}
245        <script>
246            window.playground_line_numbers = true;
247        </script>
248        {{/if}}
249
250        {{#if playground_copyable}}
251        <script>
252            window.playground_copyable = true;
253        </script>
254        {{/if}}
255
256        {{#if playground_js}}
257        <script src="{{ path_to_root }}ace.js"></script>
258        <script src="{{ path_to_root }}editor.js"></script>
259        <script src="{{ path_to_root }}mode-rust.js"></script>
260        <script src="{{ path_to_root }}theme-dawn.js"></script>
261        <script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
262        {{/if}}
263
264        {{#if search_js}}
265        <script src="{{ path_to_root }}elasticlunr.min.js"></script>
266        <script src="{{ path_to_root }}mark.min.js"></script>
267        <script src="{{ path_to_root }}searcher.js"></script>
268        {{/if}}
269
270        <script src="{{ path_to_root }}clipboard.min.js"></script>
271        <script src="{{ path_to_root }}highlight.js"></script>
272        <script src="{{ path_to_root }}book.js"></script>
273
274        <!-- Custom JS scripts -->
275        {{#each additional_js}}
276        <script src="{{ ../path_to_root }}{{this}}"></script>
277        {{/each}}
278
279        {{#if is_print}}
280        {{#if mathjax_support}}
281        <script>
282        window.addEventListener('load', function() {
283            MathJax.Hub.Register.StartupHook('End', function() {
284                window.setTimeout(window.print, 100);
285            });
286        });
287        </script>
288        {{else}}
289        <script>
290        window.addEventListener('load', function() {
291            window.setTimeout(window.print, 100);
292        });
293        </script>
294        {{/if}}
295        {{/if}}
296
297        <script>
298          (function() {
299            var theme = localStorage.getItem('mdbook-theme');
300            var html = document.querySelector('html');
301            if (theme) {
302              html.setAttribute('data-theme', theme);
303              html.setAttribute('data-color-scheme', theme);
304              html.className = theme;
305            } else {
306              var systemPreference = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
307              html.setAttribute('data-theme', systemPreference);
308              html.setAttribute('data-color-scheme', systemPreference);
309              html.className = systemPreference;
310            }
311          })();
312        </script>
313
314        <!-- Amplitude Analytics -->
315        <script>
316          (function() {
317            var amplitudeKey = '#amplitude_key#';
318            if (amplitudeKey && amplitudeKey.indexOf('#') === -1) {
319              var script = document.createElement('script');
320              script.src = 'https://cdn.amplitude.com/script/' + amplitudeKey + '.js';
321              script.onload = function() {
322                window.amplitude.init(amplitudeKey, {
323                  fetchRemoteConfig: true,
324                  autocapture: true
325                });
326              };
327              document.head.appendChild(script);
328            }
329          })();
330        </script>
331    </div>
332    </body>
333</html>