mirror of
https://github.com/daydreamer-json/ak-endfield-api-archive.git
synced 2026-05-14 01:23:40 +02:00
refactor(pages): decompose index.ts into specialized renderers and utils
This commit is contained in:
16
pages/src/assets/ts/utils/ui.ts
Normal file
16
pages/src/assets/ts/utils/ui.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { MirrorFileEntry } from '../types.js';
|
||||
|
||||
export function generateDownloadLinks(url: string, mirrorFileDb: MirrorFileEntry[]) {
|
||||
const cleanUrl = new URL(url);
|
||||
cleanUrl.search = '';
|
||||
const mirrorEntry = mirrorFileDb.find((g) => g.orig.includes(cleanUrl.toString()));
|
||||
|
||||
const links: string[] = [];
|
||||
if (!mirrorEntry || mirrorEntry.origStatus === true) {
|
||||
links.push(`<a href="${url}" target="_blank">Orig</a>`);
|
||||
}
|
||||
if (mirrorEntry) {
|
||||
links.push(`<a href="${mirrorEntry.mirror}" target="_blank">Mirror</a>`);
|
||||
}
|
||||
return links.join(' / ');
|
||||
}
|
||||
Reference in New Issue
Block a user