Spaces:
Paused
Paused
Download web/src/lib/changelogs.ts from Lordgrim7/cobalt-api: direct link, hf CLI and curl.
- Browser
- Download file 724 Bytes
-
https://huggingface.co/spaces/Lordgrim7/cobalt-api/resolve/main/web/src/lib/changelogs.ts
- Command line
-
hf download hf://spaces/Lordgrim7/cobalt-api/web/src/lib/changelogs.ts
-
curl -L -o changelogs.ts https://huggingface.co/spaces/Lordgrim7/cobalt-api/resolve/main/web/src/lib/changelogs.ts
724 Bytes
| 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; | |
| } | |