diff --git a/web/src/components/misc/ChangelogEntry.svelte b/web/src/components/misc/ChangelogEntry.svelte new file mode 100644 index 00000000..1b278498 --- /dev/null +++ b/web/src/components/misc/ChangelogEntry.svelte @@ -0,0 +1,36 @@ + + +
+

{ version }: { title }

+

{ date }

+ {#if banner} + {banner.alt} + {/if} +
+ +
+
\ No newline at end of file diff --git a/web/src/components/misc/ChangelogEntryWrapper.svelte b/web/src/components/misc/ChangelogEntryWrapper.svelte new file mode 100644 index 00000000..3821fa42 --- /dev/null +++ b/web/src/components/misc/ChangelogEntryWrapper.svelte @@ -0,0 +1,11 @@ + + + + + diff --git a/web/src/lib/changelogs.ts b/web/src/lib/changelogs.ts new file mode 100644 index 00000000..78e7df75 --- /dev/null +++ b/web/src/lib/changelogs.ts @@ -0,0 +1,22 @@ +import { compareVersions } from 'compare-versions'; + +export function getVersionFromPath(path: string) { + return path.split('/').pop()?.split('.md').shift()!; +} + +export function getAllChangelogs() { + const changelogImports = import.meta.glob("/changelogs/*.md"); + + const sortedVersions = Object.keys(changelogImports) + .map(path => [path, getVersionFromPath(path)]) + .sort(([, a], [, b]) => compareVersions(a, b)); + + const sortedChangelogs = sortedVersions.reduce( + (obj, [path, version]) => ({ + [version]: changelogImports[path], + ...obj + }), {} as typeof changelogImports + ); + + return sortedChangelogs; +} diff --git a/web/src/lib/types/changelogs.ts b/web/src/lib/types/changelogs.ts new file mode 100644 index 00000000..3dd41afc --- /dev/null +++ b/web/src/lib/types/changelogs.ts @@ -0,0 +1,19 @@ +import type { SvelteComponent } from "svelte" + +export interface ChangelogMetadata { + title: string, + date?: string + banner?: { + file: string, + alt: string + } +}; + +export interface MarkdownMetadata { + metadata: ChangelogMetadata +}; + +export type ChangelogImport = { + default: SvelteComponent, + metadata: ChangelogMetadata +} | undefined; diff --git a/web/src/routes/updates/+page.svelte b/web/src/routes/updates/+page.svelte index dc9670fa..4809d0fa 100644 --- a/web/src/routes/updates/+page.svelte +++ b/web/src/routes/updates/+page.svelte @@ -1,13 +1,61 @@ - + + - {$t("general.cobalt")}: {$t("tabs.donate")} + {$t("general.cobalt")}: {$t("tabs.updates")} - +
+ {#if changelog} + + {/if} + {#if versions[currentIndex + 1]} + + {/if} +
\ No newline at end of file