mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/updates: update hash on navigation, navigate if present on load
This commit is contained in:
parent
a22b0e5136
commit
3305bba28a
1 changed files with 12 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
|||
<script lang="ts">
|
||||
import { SvelteComponent, onMount } from 'svelte';
|
||||
import type { ChangelogImport, ChangelogMetadata } from '$lib/types/changelogs';
|
||||
import { onMount } from 'svelte';
|
||||
import type { ChangelogImport } from '$lib/types/changelogs';
|
||||
import { t } from '$lib/i18n/translations';
|
||||
import { page } from '$app/stores';
|
||||
import { getAllChangelogs } from '$lib/changelogs';
|
||||
|
||||
const changelogs = getAllChangelogs();
|
||||
|
@ -9,6 +10,13 @@
|
|||
|
||||
let changelog: ChangelogImport & { version: string } | undefined;
|
||||
let currentIndex = -1;
|
||||
{
|
||||
const hash = $page.url.hash.replace("#", "");
|
||||
const versionIndex = versions.indexOf(hash);
|
||||
if (versionIndex !== -1 && currentIndex !== versionIndex) {
|
||||
currentIndex = versionIndex;
|
||||
}
|
||||
}
|
||||
|
||||
const loadChangelog = async () => {
|
||||
const version = versions[currentIndex];
|
||||
|
@ -21,6 +29,8 @@
|
|||
...log,
|
||||
version
|
||||
};
|
||||
|
||||
window.location.hash = version;
|
||||
}
|
||||
|
||||
const nextChangelog = async () => {
|
||||
|
|
Loading…
Reference in a new issue