-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocess-libis.mts
29 lines (25 loc) · 960 Bytes
/
process-libis.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { readdir } from "node:fs/promises";
import { cwd } from "node:process";
import { join } from "node:path";
const manifestsToProcess = [
// Add new lines for more manifests to process
...(await readdir(join(cwd(), "apps/iiif/manifests/collective-access/objects"))).map((r) => {
return join(cwd(), "apps/iiif/manifests/collective-access/objects", r);
}),
];
for (const manifestPath of manifestsToProcess) {
const file = Bun.file(manifestPath);
try {
const manifestJson = await file.json();
if (manifestJson && !manifestJson.label && manifestJson.metadata) {
const foundMetadata = manifestJson.metadata.find((m: any) => m.label === "Titel" || m.label === "Title");
if (foundMetadata && foundMetadata.value) {
manifestJson.label = foundMetadata.value;
await Bun.write(file, JSON.stringify(manifestJson, null, 2));
}
}
console.log(manifestPath);
} catch (e) {
console.error(e);
}
}