|
15 | 15 | import KofiIcon from '../kit-docs/kofiLogo.svelte'
|
16 | 16 | import { Button, KitDocs, KitDocsLayout, createSidebarContext } from '@svelteness/kit-docs'
|
17 | 17 | import { SLOGAN } from '$lib/strings'
|
| 18 | + import HeadMeta from '../components/HeadMeta.svelte' |
18 | 19 |
|
19 | 20 | export let data
|
20 | 21 |
|
21 |
| - $: ({ meta, sidebar } = data) |
22 |
| -
|
23 | 22 | const links = [
|
24 |
| - { title: 'Home', slug: '/', icon: false }, |
25 |
| - { title: 'Documentation', slug: '/docs', icon: false }, |
26 |
| - { title: 'Discord', slug: '/discord', icon: DiscordIcon }, |
27 |
| - { title: 'Source', slug: '/source', icon: GithubIcon }, |
28 |
| - { title: 'Ko-fi', slug: 'https://ko-fi.com/snavesutit', icon: KofiIcon }, |
| 23 | + { label: 'Home', title: 'Home', slug: '/', match: /^\/$/, icon: false }, |
| 24 | + { |
| 25 | + label: 'Documentation', |
| 26 | + title: 'Documentation', |
| 27 | + slug: '/docs', |
| 28 | + match: /^\/docs\S*/, |
| 29 | + icon: false, |
| 30 | + }, |
| 31 | + { icon: DiscordIcon, title: 'Join our Discord!', slug: '/discord', match: /^\/discord$/ }, |
| 32 | + { |
| 33 | + icon: GithubIcon, |
| 34 | + title: 'View Source Code (Github)', |
| 35 | + slug: '/source', |
| 36 | + match: /^\/source$/, |
| 37 | + }, |
| 38 | + { icon: KofiIcon, title: 'Support Us!', slug: '/support-us', match: /^\/support-us$/ }, |
29 | 39 | ]
|
30 | 40 |
|
31 |
| - console.log(KofiIcon) |
| 41 | + let currentRelease = '1.X.X' |
| 42 | +
|
| 43 | + const PACKAGE_URL = |
| 44 | + 'https://raw.githubusercontent.com/Animated-Java/animated-java/refs/heads/main/package.json' |
| 45 | +
|
| 46 | + function getCurrentRelease() { |
| 47 | + try { |
| 48 | + fetch(PACKAGE_URL) |
| 49 | + .then(res => res.json()) |
| 50 | + .then(data => { |
| 51 | + currentRelease = data.version |
| 52 | + }) |
| 53 | + } catch (error) { |
| 54 | + console.error(error) |
| 55 | + } |
| 56 | + } |
32 | 57 |
|
33 |
| - const { activeCategory } = createSidebarContext(sidebar) |
| 58 | + getCurrentRelease() |
34 | 59 |
|
35 |
| - $: category = $activeCategory ? `${$activeCategory}: ` : '' |
36 |
| - $: title = meta ? `Animated Java | ${category}${meta.title}` : 'Animated Java' |
37 |
| - $: description = meta?.description || SLOGAN |
| 60 | + const { activeCategory } = createSidebarContext(data.sidebar) |
| 61 | + $: category = $activeCategory ? `${$activeCategory} — ` : '' |
| 62 | + $: title = data.meta ? `Animated Java | ${category}${data.meta.title}` : 'Animated Java' |
| 63 | + $: description = data.meta?.description || SLOGAN |
38 | 64 | </script>
|
39 | 65 |
|
40 |
| -<svelte:head> |
41 |
| - {#key $page.url.pathname} |
42 |
| - {#if title} |
43 |
| - <title>{title}</title> |
44 |
| - {/if} |
45 |
| - {#if description} |
46 |
| - <meta name="description" content={description} /> |
47 |
| - {/if} |
48 |
| - <meta property="og:type" content="website" /> |
49 |
| - <meta content={title} property="og:title" /> |
50 |
| - <meta content={description} property="og:description" /> |
51 |
| - <meta content={$page.url} property="og:url" /> |
52 |
| - <meta |
53 |
| - content="https://animated-java.github.io/img/animated_java_animated_icon.png" |
54 |
| - property="og:image" |
55 |
| - /> |
56 |
| - <meta content="#00ACED" data-react-helmet="true" name="theme-color" /> |
57 |
| - {/key} |
58 |
| -</svelte:head> |
| 66 | +<HeadMeta {title} {description} /> |
59 | 67 |
|
60 |
| -<KitDocs {meta}> |
61 |
| - <KitDocsLayout navbar={{ links: [] }} {sidebar} search> |
| 68 | +<KitDocs meta={data.meta}> |
| 69 | + <KitDocsLayout navbar={{ links: [] }} sidebar={data.sidebar} search> |
62 | 70 | <Algolia
|
63 | 71 | appId={PUBLIC_ALGOLIA_ID}
|
64 | 72 | apiKey={PUBLIC_ALGOLIA_SEARCH_KEY}
|
|
70 | 78 | <ul slot="navbar-right" class="nav-links">
|
71 | 79 | {#each links as link}
|
72 | 80 | <li>
|
73 |
| - <a class={link.slug === $page.url.pathname ? 'active' : ''} href={link.slug}> |
74 |
| - {link.title} |
| 81 | + <a |
| 82 | + class={!!link.match.exec($page.url.pathname) ? 'active' : ''} |
| 83 | + title={link.title} |
| 84 | + href={link.slug} |
| 85 | + > |
| 86 | + {link.label ?? ''} |
75 | 87 | <svelte:component this={link.icon} />
|
76 | 88 | </a>
|
77 | 89 | </li>
|
|
102 | 114 |
|
103 | 115 | <div class="footer" slot="main-bottom">
|
104 | 116 | {#if $page.url.pathname !== '/'}
|
105 |
| - <div class="footer-wip-warning" style="margin-top: 16px;"> |
106 |
| - ⚠️ This site only contains the documentation for the latest release of Animated |
107 |
| - Java. ⚠️ |
| 117 | + <div class="footer-version-warning"> |
| 118 | + This documentation is for the latest release of Animated Java. |
108 | 119 | <br />
|
109 |
| - Older versions may have different features or behavior. |
| 120 | + Versions older than {currentRelease}, or |
| 121 | + <a class="link" href="/docs/legacy-releases/versions">legacy</a> versions may have |
| 122 | + different features or behavior. |
110 | 123 | </div>
|
111 | 124 | {/if}
|
112 |
| - <div class="footer-social"> |
113 |
| - <div class="social-container"> |
114 |
| - <Button title="Join our Discord Server!" href="/discord"> |
115 |
| - <svelte:component this={DiscordIcon} class="social-icon" /> |
116 |
| - </Button> |
117 |
| - <Button title="Check out our Source Code!" href="/source"> |
118 |
| - <svelte:component this={GithubIcon} class="social-icon" /> |
119 |
| - </Button> |
120 |
| - <Button title="Support Us on Ko-fi!" href="https://ko-fi.com/snavesutit"> |
121 |
| - <div class="social-icon"> |
122 |
| - <KofiIcon /> |
123 |
| - </div> |
124 |
| - </Button> |
125 |
| - </div> |
126 |
| - </div> |
127 | 125 | <p class="footer-copywrite">
|
128 | 126 | © 2025 Titus Evans. All rights reserved. <br />Animated Java is not affiliated with
|
129 | 127 | Mojang Studios.
|
|
157 | 155 | }
|
158 | 156 | .nav-links > li {
|
159 | 157 | list-style: none;
|
| 158 | + display: flex; |
160 | 159 | color: rgb(var(--kd-color-soft) / var(--tw-text-opacity));
|
161 | 160 | }
|
162 | 161 | .nav-links > li > a {
|
|
258 | 257 | align-items: center;
|
259 | 258 | }
|
260 | 259 |
|
261 |
| - .footer-wip-warning { |
| 260 | + .footer-version-warning { |
262 | 261 | text-align: center;
|
263 |
| - } |
264 |
| -
|
265 |
| - .footer-social { |
266 |
| - display: flex; |
267 |
| - flex-direction: column; |
268 |
| - justify-content: center; |
269 |
| - margin-top: 2rem; |
270 |
| - margin-bottom: 2rem; |
| 262 | + border: 2px dashed #facc15aa; |
| 263 | + padding: 4px 8px; |
| 264 | + border-radius: 8px; |
| 265 | + font-style: italic; |
| 266 | + margin-top: -32px; |
| 267 | + color: var(--kd-color-subtle); |
271 | 268 | }
|
272 | 269 |
|
273 | 270 | .footer-copywrite {
|
274 | 271 | margin: 32px;
|
275 | 272 | color: var(--kd-color-subtle);
|
| 273 | + text-align: center; |
276 | 274 | }
|
277 | 275 |
|
278 | 276 | .header-container {
|
|
288 | 286 | justify-content: center;
|
289 | 287 | margin-left: 1rem;
|
290 | 288 | }
|
291 |
| -
|
292 |
| - .social-container { |
293 |
| - display: flex; |
294 |
| - flex-direction: row; |
295 |
| - justify-content: center; |
296 |
| - gap: 2rem; |
297 |
| - } |
298 |
| -
|
299 |
| - .social-container > :global(a) { |
300 |
| - font-size: 2rem; |
301 |
| - } |
302 | 289 | </style>
|
0 commit comments