|
| 1 | +--- |
| 2 | +import { logos } from "virtual:starlight/user-images"; |
| 3 | +import config from "virtual:starlight/user-config"; |
| 4 | +import VersionInfo from "./VersionInfo.astro"; |
| 5 | +const { siteTitle, siteTitleHref } = Astro.locals.starlightRoute; |
| 6 | +--- |
| 7 | + |
| 8 | +<a href={siteTitleHref} class="site-title sl-flex"> |
| 9 | + { |
| 10 | + config.logo && logos.dark && ( |
| 11 | + <> |
| 12 | + <img |
| 13 | + class:list={{ |
| 14 | + "light:sl-hidden print:hidden": !("src" in config.logo), |
| 15 | + }} |
| 16 | + alt={config.logo.alt} |
| 17 | + src={logos.dark.src} |
| 18 | + width={logos.dark.width} |
| 19 | + height={logos.dark.height} |
| 20 | + /> |
| 21 | + {/* Show light alternate if a user configure both light and dark logos. */} |
| 22 | + {!("src" in config.logo) && ( |
| 23 | + <img |
| 24 | + class="dark:sl-hidden print:block" |
| 25 | + alt={config.logo.alt} |
| 26 | + src={logos.light?.src} |
| 27 | + width={logos.light?.width} |
| 28 | + height={logos.light?.height} |
| 29 | + /> |
| 30 | + )} |
| 31 | + </> |
| 32 | + ) |
| 33 | + } |
| 34 | + <span class:list={{ "sr-only": config.logo?.replacesTitle }} translate="no"> |
| 35 | + {siteTitle} |
| 36 | + </span> |
| 37 | +</a> |
| 38 | +<select id="version-selector"> |
| 39 | + <option value="https://vscode-elements.github.io/docs-archive/v1">v1.x</option |
| 40 | + > |
| 41 | + <option selected value="https://vscode-elements.github.io" |
| 42 | + >v<VersionInfo /></option |
| 43 | + > |
| 44 | +</select> |
| 45 | + |
| 46 | +<style> |
| 47 | + @layer starlight.core { |
| 48 | + .site-title { |
| 49 | + align-items: center; |
| 50 | + gap: var(--sl-nav-gap); |
| 51 | + font-size: var(--sl-text-h4); |
| 52 | + font-weight: 600; |
| 53 | + color: var(--sl-color-text-accent); |
| 54 | + text-decoration: none; |
| 55 | + white-space: nowrap; |
| 56 | + min-width: 0; |
| 57 | + } |
| 58 | + span { |
| 59 | + overflow: hidden; |
| 60 | + } |
| 61 | + img { |
| 62 | + height: calc(var(--sl-nav-height) - 2 * var(--sl-nav-pad-y)); |
| 63 | + width: auto; |
| 64 | + max-width: 100%; |
| 65 | + object-fit: contain; |
| 66 | + object-position: 0 50%; |
| 67 | + } |
| 68 | + select { |
| 69 | + background-color: transparent; |
| 70 | + border: 0; |
| 71 | + margin-left: 10px; |
| 72 | + padding-left: 10px; |
| 73 | + padding-right: 10px; |
| 74 | + } |
| 75 | + } |
| 76 | +</style> |
| 77 | + |
| 78 | +<script> |
| 79 | + const sl = document.querySelector<HTMLSelectElement>("#version-selector"); |
| 80 | + sl?.addEventListener("input", () => { |
| 81 | + window.location.href = sl.value; |
| 82 | + }); |
| 83 | +</script> |
0 commit comments