|
3 | 3 | <article class="doc"> |
4 | 4 | <h1 class="page">{{{or page.title 'Page Not Found'}}}</h1> |
5 | 5 | <div class="paragraph"> |
6 | | -<p>The page you're looking for does not exist. It may have been moved.</p> |
| 6 | +<p>The page you’re looking for does not exist. It may have been moved. You can{{#with site.homeUrl}} return to the <a id="return-link" href="{{{this}}}">start page</a>, or{{/with}} follow one of the links in the navigation above.</p> |
7 | 7 | </div> |
8 | 8 | <div class="paragraph"> |
9 | | -<p>If you arrived on this page by clicking on a link, please notify the owner of the site that the link is broken. |
| 9 | +<p>If you arrived on this page by clicking a link on another site, please notify the owner of that site that the link is broken. |
10 | 10 | If you typed the URL of this page manually, please double check that you entered the address correctly.</p> |
11 | 11 | </div> |
12 | 12 | </article> |
| 13 | +<script> |
| 14 | +;(function (pathname, returnLink) { |
| 15 | + if (!returnLink) return |
| 16 | + var startPages = [ |
| 17 | + {{#each site.components}} |
| 18 | + { name: "{{{./name}}}", title: "{{{./title}}}", url: "{{{@root.site.path}}}{{{./url}}}", prefix: "{{{@root.site.path}}}/{{{./name}}}" }, |
| 19 | + {{#each ./versions}} |
| 20 | + {{#unless (eq ./version 'master')}} |
| 21 | + { name: "{{{./name}}}", title: "{{{./title}}}", version: "{{{./version}}}", url: "{{{@root.site.path}}}{{{./url}}}", prefix: "{{{@root.site.path}}}/{{{./name}}}/{{{./version}}}" }, |
| 22 | + {{/unless}} |
| 23 | + {{/each}} |
| 24 | + {{/each}} |
| 25 | + ].reduce(function (accum, it) { |
| 26 | + var prefix = it.prefix |
| 27 | + delete it.prefix |
| 28 | + if (('version' in it) && !it.url.startsWith(prefix + '/')) { |
| 29 | + var prefixSegments = prefix.split('/') |
| 30 | + var versionSegmentIdx = prefixSegments.findIndex((segment) => segment === it.version) |
| 31 | + prefixSegments.splice(versionSegmentIdx, 1, it.url.split('/')[versionSegmentIdx]) |
| 32 | + prefix = prefixSegments.join('/') |
| 33 | + } |
| 34 | + accum[prefix] = it |
| 35 | + return accum |
| 36 | + }, {}) |
| 37 | + var returnTo |
| 38 | + var segments = pathname.split('/').slice(0, -1) |
| 39 | + while (segments.length > 1) { |
| 40 | + if ((returnTo = startPages[segments.join('/')])) break |
| 41 | + segments.pop() |
| 42 | + } |
| 43 | + if (returnTo) { |
| 44 | + returnLink.href = returnTo.url |
| 45 | + returnLink.innerText = |
| 46 | + 'start page for the ' + returnTo.title + ' ' + |
| 47 | + (returnTo.version ? returnTo.version + ' ' : '') + |
| 48 | + 'documentation' |
| 49 | + } |
| 50 | +})(window.location.pathname, document.getElementById('return-link')) |
| 51 | +</script> |
13 | 52 | </main> |
14 | 53 | </div> |
0 commit comments