|
89 | 89 | } |
90 | 90 |
|
91 | 91 | let locale = $state(initialLocale) |
92 | | - let isMounted = $state(false) |
93 | 92 | let copiedCommand = $state(undefined) |
| 93 | + let copyFallbackCommand = $state(undefined) |
94 | 94 |
|
95 | 95 | function applyLocale(nextLocale) { |
96 | 96 | locale = nextLocale |
|
103 | 103 | const nextLocale = locale || getInitialLocale() |
104 | 104 | applyLocale(nextLocale) |
105 | 105 | syncLocaleToUrl(nextLocale) |
106 | | -
|
107 | | - isMounted = true |
108 | 106 | }) |
109 | 107 |
|
110 | 108 | $effect(() => { |
111 | | - if (!isMounted) return |
| 109 | + if (!locale) return |
112 | 110 |
|
113 | 111 | document.documentElement.lang = $LL.meta.lang() |
114 | 112 | document.title = $LL.meta.title() |
|
144 | 142 | } |
145 | 143 |
|
146 | 144 | async function copyCommand(command) { |
| 145 | + copiedCommand = command |
| 146 | + copyFallbackCommand = undefined |
| 147 | +
|
147 | 148 | try { |
148 | 149 | await navigator.clipboard.writeText(command) |
149 | | - copiedCommand = command |
150 | 150 | window.setTimeout(() => { |
151 | 151 | if (copiedCommand === command) copiedCommand = undefined |
152 | 152 | }, 1800) |
153 | 153 | } catch { |
154 | | - copiedCommand = undefined |
| 154 | + copyFallbackCommand = command |
| 155 | + window.prompt($LL.download.copyPrompt(), command) |
155 | 156 | } |
156 | 157 | } |
157 | 158 | </script> |
158 | 159 |
|
159 | | -{#if locale && isMounted} |
| 160 | +{#if locale} |
160 | 161 | <main class="site"> |
161 | 162 | <header class="site-nav" id="top"> |
162 | 163 | <a class="brand" href="#top" onclick={(event) => scrollToSection(event, 'top')}>ServerBox</a> |
163 | 164 | <nav> |
164 | 165 | <a href="#features" onclick={(event) => scrollToSection(event, 'features')}>{$LL.nav.features()}</a> |
165 | 166 | <a href="#capabilities" onclick={(event) => scrollToSection(event, 'capabilities')}>{$LL.nav.capabilities()}</a> |
166 | 167 | <a href="#download" onclick={(event) => scrollToSection(event, 'download')}>{$LL.nav.download()}</a> |
| 168 | + <a href="/docs/">Docs</a> |
167 | 169 | </nav> |
168 | 170 | <div class="nav-actions"> |
169 | 171 | <label class="language-switcher"> |
|
270 | 272 | aria-label={`${group.label} ${source.label}`} |
271 | 273 | onclick={() => copyCommand(source.command)} |
272 | 274 | > |
273 | | - <span>{copiedCommand === source.command ? $LL.download.copied() : source.label}</span> |
| 275 | + <span> |
| 276 | + {#if copyFallbackCommand === source.command} |
| 277 | + {source.command} |
| 278 | + {:else if copiedCommand === source.command} |
| 279 | + {$LL.download.copied()} |
| 280 | + {:else} |
| 281 | + {source.label} |
| 282 | + {/if} |
| 283 | + </span> |
274 | 284 | </button> |
275 | 285 | {:else} |
276 | 286 | <a class="download-icon-btn" href={source.href} aria-label={`${group.label} ${source.label}`}> |
|
0 commit comments