forked from Stuyk/gtav-image-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (33 loc) · 983 Bytes
/
index.js
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
30
31
32
33
34
35
36
37
38
39
40
const glob = require("fast-glob");
const fs = require("fs");
const folders = ["clothes", "heads", "vehicles", "weapons"];
const HTMLBoiler = `
<html>
<head>
<title>Stuyk's GTA:V Image Archive</title>
</head>
<body>
<h2>
<a href="index.html">< Back</a><br/>
</h2>
<!-- Replace Me -->
<h2>
<a href="index.html">< Back</a><br/>
</h2>
</body>
</html>
`;
for (let folder of folders) {
let content = "";
const files = glob.sync(`./${folder}/**/*.webp`);
for (let file of files) {
const fileSplit = file.split("/");
const fileWithExt = fileSplit[fileSplit.length - 1];
const fileName = fileWithExt.split(".")[0];
const url = `https://cdn.jsdelivr.net/gh/Stuyk/gtav-image-archive/${folder}/${fileWithExt}`;
content += `${fileName}<br />\n`;
content += `<img src="${url}"/><br />\n`;
}
const data = HTMLBoiler.replace("<!-- Replace Me -->", content);
fs.writeFileSync(`${folder}.html`, data);
}