-
Notifications
You must be signed in to change notification settings - Fork 0
/
link.js
50 lines (43 loc) · 1.12 KB
/
link.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
41
42
43
44
45
46
47
48
49
50
const YML = require("yamljs");
const fs = require("fs");
const blacklist = [
"Node.js",
"GitHub",
"Netlify",
"Vercel",
"Cloudflare",
"npm",
"VScode",
"腾讯云",
"多吉云",
"How To Cook",
"996.ICU",
"萌国ICP备案",
]; // 由于某种原因,不想订阅的列表
let friends = [],
data_f = YML.parse(
fs
.readFileSync("source/_data/link.yml")
.toString()
.replace(/(?<=rss:)\s*\n/g, ' ""\n')
);
data_f.forEach((entry, index) => {
let lastIndex = 3;
if (index < lastIndex) {
const filteredLinkList = entry.link_list.filter(
(linkItem) => !blacklist.includes(linkItem.name)
);
friends = friends.concat(filteredLinkList);
}
});
// 根据规定的格式构建 JSON 数据
const friendData = {
friends: friends.map((item) => {
return [item.name, item.link, item.avatar];
}),
};
// 将 JSON 对象转换为字符串
const friendJSON = JSON.stringify(friendData, null, 2);
// 写入 friend.json 文件
fs.writeFileSync("./source/friend.json", friendJSON);
console.log("friend.json 文件已生成。");