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        </nav>
 95
 96        <!-- Track and set sidebar scroll position -->
 97        <script>
 98            var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
 99            sidebarScrollbox.addEventListener('click', function(e) {
100                if (e.target.tagName === 'A') {
101                    sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
102                }
103            }, { passive: true });
104            var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
105            sessionStorage.removeItem('sidebar-scroll');
106            if (sidebarScrollTop) {
107                // preserve sidebar scroll position when navigating via links within sidebar
108                sidebarScrollbox.scrollTop = sidebarScrollTop;
109            } else {
110                // scroll sidebar to current active section when navigating via "next/previous chapter" buttons
111                var activeSection = document.querySelector('#sidebar .active');
112                if (activeSection) {
113                    activeSection.scrollIntoView({ block: 'center' });
114                }
115            }
116        </script>
117
118        <div id="page-wrapper" class="page-wrapper">
119
120            <div class="page">
121                {{> header}}
122                <div id="menu-bar-hover-placeholder"></div>
123                <div id="menu-bar" class="menu-bar sticky">
124                    <div class="left-buttons" style="height: 36px; margin-top: 16px">
125                        <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">
126                            <i class="fa fa-bars"></i>
127                        </label>
128                        {{#if search_enabled}}
129                        <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">
130                            <i class="fa fa-search"></i>
131                        </button>
132                        {{/if}}
133                    </div>
134
135                    <h1 class="menu-title">
136                        <a href="/">
137                            <img src="https://zed.dev/logo_wordmark_36.webp" alt="Zed Industries" style="margin-top: 24px; height: 36px;">
138                        </a>
139                    </h1>
140
141                    <div class="right-buttons">
142                        <a class="download-button" href="https://zed.dev/download" title="Download Zed" aria-label="Download Zed">
143                            Download
144                        </a>
145                        {{#if git_repository_url}}
146                        <a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
147                            <i id="git-repository-button" class="fa {{git_repository_icon}}"></i>
148                        </a>
149                        {{/if}}
150                        {{#if git_repository_edit_url}}
151                        <a href="{{git_repository_edit_url}}" title="Suggest an edit" aria-label="Suggest an edit">
152                            <i id="git-edit-button" class="fa fa-edit"></i>
153                        </a>
154                        {{/if}}
155                    </div>
156                </div>
157
158                {{#if search_enabled}}
159                <div id="search-wrapper" class="hidden">
160                    <form id="searchbar-outer" class="searchbar-outer">
161                        <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
162                    </form>
163                    <div id="searchresults-outer" class="searchresults-outer hidden">
164                        <div id="searchresults-header" class="searchresults-header"></div>
165                        <ul id="searchresults">
166                        </ul>
167                    </div>
168                </div>
169                {{/if}}
170
171                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
172                <script>
173                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
174                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
175                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
176                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
177                    });
178                </script>
179
180                <div id="content" class="content">
181                    <main>
182                        {{{ content }}}
183                    </main>
184                </div>
185            </div>
186        </div>
187
188        {{#if live_reload_endpoint}}
189        <!-- Livereload script (if served using the cli tool) -->
190        <script>
191            const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
192            const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
193            const socket = new WebSocket(wsAddress);
194            socket.onmessage = function (event) {
195                if (event.data === "reload") {
196                    socket.close();
197                    location.reload();
198                }
199            };
200
201            window.onbeforeunload = function() {
202                socket.close();
203            }
204        </script>
205        {{/if}}
206
207        {{#if playground_line_numbers}}
208        <script>
209            window.playground_line_numbers = true;
210        </script>
211        {{/if}}
212
213        {{#if playground_copyable}}
214        <script>
215            window.playground_copyable = true;
216        </script>
217        {{/if}}
218
219        {{#if playground_js}}
220        <script src="{{ path_to_root }}ace.js"></script>
221        <script src="{{ path_to_root }}editor.js"></script>
222        <script src="{{ path_to_root }}mode-rust.js"></script>
223        <script src="{{ path_to_root }}theme-dawn.js"></script>
224        <script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
225        {{/if}}
226
227        {{#if search_js}}
228        <script src="{{ path_to_root }}elasticlunr.min.js"></script>
229        <script src="{{ path_to_root }}mark.min.js"></script>
230        <script src="{{ path_to_root }}searcher.js"></script>
231        {{/if}}
232
233        <script src="{{ path_to_root }}clipboard.min.js"></script>
234        <script src="{{ path_to_root }}highlight.js"></script>
235        <script src="{{ path_to_root }}book.js"></script>
236
237        <!-- Custom JS scripts -->
238        {{#each additional_js}}
239        <script src="{{ ../path_to_root }}{{this}}"></script>
240        {{/each}}
241
242        {{#if is_print}}
243        {{#if mathjax_support}}
244        <script>
245        window.addEventListener('load', function() {
246            MathJax.Hub.Register.StartupHook('End', function() {
247                window.setTimeout(window.print, 100);
248            });
249        });
250        </script>
251        {{else}}
252        <script>
253        window.addEventListener('load', function() {
254            window.setTimeout(window.print, 100);
255        });
256        </script>
257        {{/if}}
258        {{/if}}
259
260    </div>
261    </body>
262</html>