Spaces:
Sleeping
Sleeping
File size: 724 Bytes
43a06dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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;
}
|