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
123            <div class="page">
124                {{> header}}
125                <div id="menu-bar-hover-placeholder"></div>
126                <div id="menu-bar" class="menu-bar sticky">
127                    <div class="left-buttons" style="height: 36px; margin-top: 16px">
128                        <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">
129                            <i class="fa fa-bars"></i>
130                        </label>
131                        <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">
132                            <i class="fa fa-paint-brush"></i>
133                        </button>
134                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
135                            <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
136                            <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
137                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
138                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
139                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
140                        </ul>
141                        {{#if search_enabled}}
142                        <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">
143                            <i class="fa fa-search"></i>
144                        </button>
145                        {{/if}}
146                    </div>
147
148                    <h1 class="menu-title">
149                        <a href="/">
150                            <img src="https://zed.dev/logo_wordmark_36.webp" alt="Zed Industries" style="margin-top: 24px; height: 36px;">
151                        </a>
152                    </h1>
153
154                    <div class="right-buttons">
155                        <a class="download-button" href="https://zed.dev/download" title="Download Zed" aria-label="Download Zed">
156                            Download
157                        </a>
158                        {{#if git_repository_url}}
159                        <a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
160                            <i id="git-repository-button" class="fa {{git_repository_icon}}"></i>
161                        </a>
162                        {{/if}}
163                        {{#if git_repository_edit_url}}
164                        <a href="{{git_repository_edit_url}}" title="Suggest an edit" aria-label="Suggest an edit">
165                            <i id="git-edit-button" class="fa fa-edit"></i>
166                        </a>
167                        {{/if}}
168                    </div>
169                </div>
170
171                {{#if search_enabled}}
172                <div id="search-wrapper" class="hidden">
173                    <form id="searchbar-outer" class="searchbar-outer">
174                        <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
175                    </form>
176                    <div id="searchresults-outer" class="searchresults-outer hidden">
177                        <div id="searchresults-header" class="searchresults-header"></div>
178                        <ul id="searchresults">
179                        </ul>
180                    </div>
181                </div>
182                {{/if}}
183
184                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
185                <script>
186                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
187                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
188                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
189                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
190                    });
191                </script>
192
193                <div id="content" class="content">
194                    <main>
195                        {{{ content }}}
196                    </main>
197                </div>
198            </div>
199        </div>
200
201        {{#if live_reload_endpoint}}
202        <!-- Livereload script (if served using the cli tool) -->
203        <script>
204            const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
205            const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
206            const socket = new WebSocket(wsAddress);
207            socket.onmessage = function (event) {
208                if (event.data === "reload") {
209                    socket.close();
210                    location.reload();
211                }
212            };
213
214            window.onbeforeunload = function() {
215                socket.close();
216            }
217        </script>
218        {{/if}}
219
220        {{#if playground_line_numbers}}
221        <script>
222            window.playground_line_numbers = true;
223        </script>
224        {{/if}}
225
226        {{#if playground_copyable}}
227        <script>
228            window.playground_copyable = true;
229        </script>
230        {{/if}}
231
232        {{#if playground_js}}
233        <script src="{{ path_to_root }}ace.js"></script>
234        <script src="{{ path_to_root }}editor.js"></script>
235        <script src="{{ path_to_root }}mode-rust.js"></script>
236        <script src="{{ path_to_root }}theme-dawn.js"></script>
237        <script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
238        {{/if}}
239
240        {{#if search_js}}
241        <script src="{{ path_to_root }}elasticlunr.min.js"></script>
242        <script src="{{ path_to_root }}mark.min.js"></script>
243        <script src="{{ path_to_root }}searcher.js"></script>
244        {{/if}}
245
246        <script src="{{ path_to_root }}clipboard.min.js"></script>
247        <script src="{{ path_to_root }}highlight.js"></script>
248        <script src="{{ path_to_root }}book.js"></script>
249
250        <!-- Custom JS scripts -->
251        {{#each additional_js}}
252        <script src="{{ ../path_to_root }}{{this}}"></script>
253        {{/each}}
254
255        {{#if is_print}}
256        {{#if mathjax_support}}
257        <script>
258        window.addEventListener('load', function() {
259            MathJax.Hub.Register.StartupHook('End', function() {
260                window.setTimeout(window.print, 100);
261            });
262        });
263        </script>
264        {{else}}
265        <script>
266        window.addEventListener('load', function() {
267            window.setTimeout(window.print, 100);
268        });
269        </script>
270        {{/if}}
271        {{/if}}
272
273    </div>
274    </body>
275</html>