Ultima attività 1730626955

通过HEXO内置Generator生成,更加快捷,不需要json包

friend-json-generator.js Raw
1const blacklist = ["友站名称1", "友站名称2", "友站名称3"];
2const path = "friend.json";
3
4function genFriendJSON(locals) {
5 var friends = [];
6 var data = locals.data.link;
7 data.forEach((entry, index) => {
8 let lastIndex = 2;
9 if (index < lastIndex) {
10 const filteredLinkList = entry.link_list.filter(
11 (linkItem) => !blacklist.includes(linkItem.name)
12 );
13 friends = friends.concat(filteredLinkList);
14 }
15 });
16 const friendData = {
17 friends: friends.map((item) => {
18 return [item.name, item.link, item.avatar];
19 }),
20 };
21 console.log("friend.json 文件已生成。");
22 return [{
23 path: path,
24 data: JSON.stringify(friendData, null),
25 }, ];
26}
27
28hexo.extend.generator.register("friend_circle", genFriendJSON);