frontend: setup initial updates page
This commit is contained in:
22
web/src/lib/changelogs.ts
Normal file
22
web/src/lib/changelogs.ts
Normal file
@@ -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;
|
||||
}
|
||||
19
web/src/lib/types/changelogs.ts
Normal file
19
web/src/lib/types/changelogs.ts
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user