index.hbs

  1<!DOCTYPE HTML>
  2<html lang="{{ language }}" dir="{{ text_direction }}">
  3    <head>
  4        <!-- Book generated using mdBook -->
  5        <meta charset="UTF-8">
  6        <style>
  7            @view-transition {
  8                navigation: auto;
  9            }
 10            ::view-transition-old(root),
 11            ::view-transition-new(root) {
 12                animation-duration: 0.05s;
 13            }
 14        </style>
 15        <!-- Theme initialization - must run before any CSS loads to prevent flicker -->
 16        <script>
 17            (function() {
 18                var theme;
 19                try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
 20                if (theme === null || theme === undefined) {
 21                    theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
 22                }
 23                var html = document.documentElement;
 24                html.setAttribute('data-theme', theme);
 25                html.setAttribute('data-color-scheme', theme);
 26                html.className = theme;
 27            })();
 28        </script>
 29        <title>{{ title }}</title>
 30        {{#if is_print }}
 31        <meta name="robots" content="noindex">
 32        {{/if}}
 33        #noindex#
 34        {{#if base_url}}
 35        <base href="{{ base_url }}">
 36        {{/if}}
 37
 38
 39        <!-- Custom HTML head -->
 40        {{> head}}
 41
 42        <meta name="description" content="#description#">
 43        <meta name="viewport" content="width=device-width, initial-scale=1">
 44        <meta name="theme-color" content="#ffffff">
 45
 46        <link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
 47        <link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
 48        <link rel="stylesheet" href="{{ path_to_root }}css/general.css">
 49        <link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
 50        {{#if print_enable}}
 51        <link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
 52        {{/if}}
 53
 54        <!-- Fonts -->
 55        <link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
 56        {{#if copy_fonts}}
 57        <link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
 58        {{/if}}
 59
 60        <!-- Highlight.js Stylesheets -->
 61        <link rel="stylesheet" href="{{ path_to_root }}highlight.css">
 62        <link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
 63        <link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
 64
 65        <!-- Custom theme stylesheets -->
 66        {{#each additional_css}}
 67        <link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
 68        {{/each}}
 69
 70        {{#if mathjax_support}}
 71        <!-- MathJax -->
 72        <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
 73        {{/if}}
 74        <meta name="amplitude-key" content="#amplitude_key#" />
 75        <meta name="consent-io-instance" content="#consent_io_instance#" />
 76    </head>
 77    <body class="no-js">
 78    <div id="body-container">
 79        <div class="noise-pattern" style="background-image: url('https://cdn.zed.dev/images/noise.png');"></div>
 80
 81        <!-- Provide site root to javascript -->
 82        <script>
 83            var path_to_root = "{{ path_to_root }}";
 84            var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
 85            // Mark as JS-enabled
 86            document.body.classList.remove('no-js');
 87            document.body.classList.add('js');
 88        </script>
 89
 90        <header class="header-bar">
 91            <div class="left-container">
 92                <a href="/" class="logo-nav">
 93                    <img src="https://zed.dev/logo_icon.webp" class="icon-logo-img" alt="Zed Industries" style="height: 26px;">
 94                </a>
 95                <button id="sidebar-toggle" class="icon-button ib-hidden-desktop" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar" aria-expanded="false">
 96                    <i class="fa fa-bars"></i>
 97                </button>
 98            </div>
 99            {{#if search_enabled}}
100            <button id="search-toggle" class="search-button" type="button" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
101                <i class="icon fa fa-search"></i>
102                <span class="search-content-desktop">
103                    <span class="placeholder">Search docs…</span>
104                    <kbd>S</kbd>
105                </span>
106                <span class="search-content-mobile">
107                    <span class="placeholder">Search…</span>
108                </span>
109            </button>
110            {{/if}}
111            <div class="right-container">
112                <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">
113                    <i class="fa fa-paint-brush"></i>
114                </button>
115
116                <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
117                    <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
118                    <li role="none"><button role="menuitem" class="theme" id="dark">Dark</button></li>
119                </ul>
120
121                <button id="copy-markdown-toggle" class="icon-button ib-hidden-mobile" type="button" title="Copy Page as Markdown" aria-label="Copy page as markdown">
122                    <i class="fa fa-copy"></i>
123                </button>
124
125                <a class="download-button" href="https://zed.dev/download" title="Download Zed" aria-label="Download Zed">
126                    Download
127                </a>
128                {{#if git_repository_url}}
129                <a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
130                    <i id="git-repository-button" class="fa {{git_repository_icon}}"></i>
131                </a>
132                {{/if}}
133                {{#if git_repository_edit_url}}
134                <a href="{{git_repository_edit_url}}" title="Suggest an edit" aria-label="Suggest an edit">
135                    <i id="git-edit-button" class="fa fa-edit"></i>
136                </a>
137                {{/if}}
138            </div>
139        </header>
140
141        <div id="page-wrapper" class="page-wrapper">
142
143            {{#if search_enabled}}
144            <div class="search-container">
145                <div id="search-wrapper" class="search-modal hidden">
146                    <form id="searchbar-outer" class="searchbar-outer">
147                        <input type="search" id="searchbar" name="searchbar" placeholder="Search…" aria-controls="searchresults-outer" aria-describedby="searchresults-header">
148                    </form>
149                    <div id="searchresults-outer" class="searchresults-outer">
150                        <div id="searchresults-header" class="searchresults-header"></div>
151                        <ul id="searchresults">
152                        </ul>
153                    </div>
154                </div>
155            </div>
156            {{/if}}
157
158            <nav id="sidebar" class="sidebar" aria-label="Table of contents">
159                <div class="sidebar-scrollbox">
160                    {{#toc}}{{/toc}}
161                </div>
162                <div style="display: none;" id="sidebar-resize-handle" class="sidebar-resize-handle">
163                    <div class="sidebar-resize-indicator"></div>
164                </div>
165            </nav>
166
167            <!-- Mobile sidebar toggle -->
168            <script>
169                (function() {
170                    var sidebarToggle = document.getElementById('sidebar-toggle');
171                    var sidebar = document.getElementById('sidebar');
172
173                    sidebarToggle.addEventListener('click', function() {
174                        var isOpen = document.body.classList.toggle('sidebar-open');
175                        sidebarToggle.setAttribute('aria-expanded', isOpen);
176                        sidebar.setAttribute('aria-hidden', !isOpen);
177                    });
178
179                    // Close sidebar when clicking a link inside it (on mobile)
180                    sidebar.addEventListener('click', function(e) {
181                        if (e.target.tagName === 'A' && window.innerWidth < 620) {
182                            document.body.classList.remove('sidebar-open');
183                            sidebarToggle.setAttribute('aria-expanded', 'false');
184                            sidebar.setAttribute('aria-hidden', 'true');
185                        }
186                    });
187                })();
188            </script>
189
190            <!-- Search backdrop handlers -->
191            <script>
192                (function() {
193                    var searchWrapper = document.getElementById('search-wrapper');
194                    var searchContainer = document.querySelector('.search-container');
195                    var searchResults = document.getElementById('searchresults');
196
197                    if (!searchWrapper || !searchContainer) return;
198
199                    searchContainer.addEventListener('click', function(e) {
200                        if (e.target === searchContainer) {
201                            searchWrapper.classList.add('hidden');
202                        }
203                    });
204
205                    if (searchResults) {
206                        searchResults.addEventListener('click', function(e) {
207                            if (e.target.tagName === 'A' || e.target.closest('a')) {
208                                searchWrapper.classList.add('hidden');
209                            }
210                        });
211                    }
212                })();
213            </script>
214
215            <!-- Insert section spacers and apply collapsed state before scroll restoration to prevent layout shift/flicker -->
216            <script>
217                (function() {
218                    var chapterList = document.querySelector('#sidebar ol.chapter');
219                    if (!chapterList) return;
220
221                    var collapsedSections = [];
222                    try {
223                        var stored = sessionStorage.getItem('sidebar-collapsed-sections');
224                        if (stored) {
225                            collapsedSections = JSON.parse(stored);
226                        }
227                    } catch (e) {}
228
229                    var partTitles = chapterList.querySelectorAll('li.part-title');
230                    var previousPartTitle = null;
231
232                    partTitles.forEach(function(partTitle, index) {
233                        partTitle._sectionName = partTitle.textContent.trim();
234
235                        // Insert a spacer before this part-title (except for the first one)
236                        if (index > 0) {
237                            var spacer = document.createElement('li');
238                            spacer.className = 'section-spacer';
239                            partTitle.parentNode.insertBefore(spacer, partTitle);
240
241                            if (previousPartTitle) {
242                                previousPartTitle._spacerAfter = spacer;
243                            }
244                        }
245
246                        var isCollapsed = collapsedSections.includes(partTitle._sectionName);
247                        if (isCollapsed) {
248                            // Hide all siblings until next part-title
249                            var sibling = partTitle.nextElementSibling;
250                            while (sibling && !sibling.classList.contains('part-title')) {
251                                sibling.classList.add('section-hidden');
252                                sibling = sibling.nextElementSibling;
253                            }
254                            // Hide the spacer after this section (will be set on next iteration)
255                            partTitle._isCollapsed = true;
256                        }
257
258                        // If previous section was collapsed, hide its spacer
259                        if (previousPartTitle && previousPartTitle._isCollapsed && previousPartTitle._spacerAfter) {
260                            previousPartTitle._spacerAfter.classList.add('section-hidden');
261                        }
262
263                        previousPartTitle = partTitle;
264                    });
265
266                    // Handle the last section's spacer if it was collapsed
267                    if (previousPartTitle && previousPartTitle._isCollapsed && previousPartTitle._spacerAfter) {
268                        previousPartTitle._spacerAfter.classList.add('section-hidden');
269                    }
270                })();
271            </script>
272
273            <!-- Track and set sidebar scroll position -->
274            <script>
275                var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
276                sidebarScrollbox.addEventListener('click', function(e) {
277                    if (e.target.tagName === 'A') {
278                        sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
279                    }
280                }, { passive: true });
281                var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
282                sessionStorage.removeItem('sidebar-scroll');
283                if (sidebarScrollTop) {
284                    // preserve sidebar scroll position when navigating via links within sidebar
285                    sidebarScrollbox.scrollTop = sidebarScrollTop;
286                } else {
287                    // scroll sidebar to current active section when navigating via "next/previous chapter" buttons
288                    var activeSection = document.querySelector('#sidebar .active');
289                    if (activeSection) {
290                        activeSection.scrollIntoView({ block: 'center' });
291                    }
292                }
293            </script>
294
295            <div class="page">
296                <div id="content" class="content">
297                    <main>
298                      {{{ content }}}
299                        <div class="footer-buttons">
300                            {{#previous}}
301                            <a rel="prev" href="{{ path_to_root }}{{link}}" class="footer-button" title="{{title}}">
302                                <i class="fa fa-angle-left"></i>
303                                {{title}}
304                            </a>
305                            {{/previous}}
306                            {{#next}}
307                            <a rel="next" href="{{ path_to_root }}{{link}}" class="footer-button" title="{{title}}">
308                                {{title}}
309                                <i class="fa fa-angle-right"></i>
310                            </a>
311                            {{/next}}
312                        </div>
313                        <footer class="footer">
314                            <a href="/" class="logo-nav">
315                                <img
316                                    src="https://zed.dev/logo_icon.webp"
317                                    class="footer-logo"
318                                    alt="Zed Industries"
319                                />
320                            </a>
321                            <span class="footer-separator">•</span>
322                            <a class="footer-link" href="https://zed.dev"
323                                >Back to Site</a
324                            >
325                            <span class="footer-separator">•</span>
326                            <a
327                                class="footer-link"
328                                href="https://zed.dev/releases"
329                                >Releases</a
330                            >
331                            <span class="footer-separator">•</span>
332                            <a
333                                class="footer-link"
334                                href="https://zed.dev/roadmap"
335                                >Roadmap</a
336                            >
337                            <span class="footer-separator">•</span>
338                            <a
339                                class="footer-link"
340                                href="https://github.com/zed-industries/zed"
341                                >GitHub</a
342                            >
343                            <span class="footer-separator">•</span>
344                            <a
345                                class="footer-link"
346                                href="https://zed.dev/blog"
347                                >Blog</a
348                            >
349                            <span class="footer-separator">•</span>
350                            <button
351                                id="c15t-manage-consent-btn"
352                                class="footer-link"
353                            >
354                                Manage Site Cookies
355                            </button>
356                        </footer>
357                    </main>
358                    <div class="toc-container">
359                        <nav class="pagetoc"></nav>
360                    </div>
361                    <!-- Immediately detect if page has headins that are not h1 to prevent flicker -->
362                    <script>
363                        (function() {
364                            var tocContainer = document.querySelector('.toc-container');
365                            var headers = document.querySelectorAll('.header');
366                            var hasNonH1Headers = false;
367                            for (var i = 0; i < headers.length; i++) {
368                                var parent = headers[i].parentElement;
369                                if (parent && !parent.tagName.toLowerCase().startsWith('h1')) {
370                                    hasNonH1Headers = true;
371                                    break;
372                                }
373                            }
374                            if (hasNonH1Headers) {
375                                tocContainer.classList.add('has-toc');
376                            } else {
377                                tocContainer.classList.add('no-toc');
378                            }
379                        })();
380                    </script>
381                </div>
382            </div>
383        </div>
384
385        {{#if live_reload_endpoint}}
386        <!-- Livereload script (if served using the cli tool) -->
387        <script>
388            const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
389            const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
390            const socket = new WebSocket(wsAddress);
391            socket.onmessage = function (event) {
392                if (event.data === "reload") {
393                    socket.close();
394                    location.reload();
395                }
396            };
397
398            window.onbeforeunload = function() {
399                socket.close();
400            }
401        </script>
402        {{/if}}
403
404        {{#if playground_line_numbers}}
405        <script>
406            window.playground_line_numbers = true;
407        </script>
408        {{/if}}
409
410        {{#if playground_copyable}}
411        <script>
412            window.playground_copyable = true;
413        </script>
414        {{/if}}
415
416        {{#if playground_js}}
417        <script src="{{ path_to_root }}ace.js"></script>
418        <script src="{{ path_to_root }}editor.js"></script>
419        <script src="{{ path_to_root }}mode-rust.js"></script>
420        <script src="{{ path_to_root }}theme-dawn.js"></script>
421        <script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
422        {{/if}}
423
424        {{#if search_js}}
425        <script src="{{ path_to_root }}elasticlunr.min.js"></script>
426        <script src="{{ path_to_root }}mark.min.js"></script>
427        <script src="{{ path_to_root }}searcher.js"></script>
428
429        <script>
430           (function () {
431                // Check for focused search result and bring into the view
432                const ensureVisible = () => {
433                    const focused = document.querySelector("#searchresults li.focus");
434
435                    if (focused) {
436                        focused.scrollIntoView({
437                            block: "nearest",
438                            inline: "nearest"
439                        });
440                    }
441                };
442
443                // 1. Listen for arrow key events
444                // 2. Wait for DOM to update
445                // 3. Call envsureVisible
446                document.addEventListener("keydown", function (e) {
447                    if (e.key === "ArrowDown" || e.key === "ArrowUp") {
448                        requestAnimationFrame(ensureVisible);
449                    }
450                });
451            })();
452        </script>
453        {{/if}}
454
455        <script src="{{ path_to_root }}clipboard.min.js"></script>
456        <script src="{{ path_to_root }}highlight.js"></script>
457        <script src="{{ path_to_root }}book.js"></script>
458
459        <!-- Custom JS scripts -->
460        {{#each additional_js}}
461        <script src="{{ ../path_to_root }}{{this}}"></script>
462        {{/each}}
463
464        {{#if is_print}}
465        {{#if mathjax_support}}
466        <script>
467        window.addEventListener('load', function() {
468            MathJax.Hub.Register.StartupHook('End', function() {
469                window.setTimeout(window.print, 100);
470            });
471        });
472        </script>
473        {{else}}
474        <script>
475        window.addEventListener('load', function() {
476            window.setTimeout(window.print, 100);
477        });
478        </script>
479        {{/if}}
480        {{/if}}
481
482        <!-- c15t Consent Banner -->
483        <div id="c15t-banner" style="display: none;">
484            <div>
485                <p id="c15t-description">
486                    Zed uses cookies to improve your experience and for marketing. Read <a href="https://zed.dev/cookie-policy">our cookie policy</a> for more details.
487                </p>
488            </div>
489            <div id="c15t-configure-section" style="display: none">
490                <div>
491                    <label for="c15t-toggle-necessary"
492                        >Strictly Necessary</label
493                    >
494                    <label class="c15t-switch">
495                        <input
496                            type="checkbox"
497                            id="c15t-toggle-necessary"
498                            checked
499                            disabled
500                        />
501                        <span class="c15t-slider"></span>
502                    </label>
503                </div>
504                <div>
505                    <label for="c15t-toggle-measurement">Analytics</label>
506                    <label class="c15t-switch">
507                        <input
508                            type="checkbox"
509                            id="c15t-toggle-measurement"
510                        />
511                        <span class="c15t-slider"></span>
512                    </label>
513                </div>
514                <div>
515                    <label for="c15t-toggle-marketing">Marketing</label>
516                    <label class="c15t-switch">
517                        <input
518                            type="checkbox"
519                            id="c15t-toggle-marketing"
520                        />
521                        <span class="c15t-slider"></span>
522                    </label>
523                </div>
524            </div>
525            <div id="c15t-footer">
526                <button
527                    id="c15t-configure-btn"
528                    class="c15t-button icon"
529                    title="Configure"
530                >
531                    <svg
532                        xmlns="http://www.w3.org/2000/svg"
533                        width="14"
534                        height="14"
535                        viewBox="0 0 24 24"
536                        fill="none"
537                        stroke="currentColor"
538                        stroke-width="2"
539                        stroke-linecap="round"
540                        stroke-linejoin="round"
541                    >
542                        <path d="M20 7h-9" />
543                        <path d="M14 17H5" />
544                        <circle cx="17" cy="17" r="3" />
545                        <circle cx="7" cy="7" r="3" />
546                    </svg>
547                </button>
548                <div>
549                    <button id="c15t-decline" class="c15t-button">
550                        Reject all
551                    </button>
552                    <button id="c15t-accept" class="c15t-button primary">
553                        Accept all
554                    </button>
555                </div>
556            </div>
557        </div>
558    </div>
559    </body>
560</html>