LiuShen hat die Gist bearbeitet . Zu Änderung gehen
1 file changed, 28 insertions
friend-json-generator.js(Datei erstellt)
@@ -0,0 +1,28 @@ | |||
1 | + | const blacklist = ["友站名称1", "友站名称2", "友站名称3"]; | |
2 | + | const path = "friend.json"; | |
3 | + | ||
4 | + | function 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 | + | ||
28 | + | hexo.extend.generator.register("friend_circle", genFriendJSON); |
Neuer
Älter