Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nexmoe committed Sep 30, 2022
2 parents db5f5aa + 553a229 commit 9e6eac1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion scripts/tag/links.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
"use strict";

/**
* Shuffles array in place. ES6 version
* @param {Array} a items An array containing the items.
*/
const shuffle = (a) => {
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
};

hexo.extend.tag.register(
"links",
function (args, content) {
let items = "";
let data = JSON.parse(content);
let data = [];
try {
data = JSON.parse(content);
} catch (e) {
return e;
}
if (args.includes("shuffle")) {
console.warn(" [Nexmoe] Links tag is using shuffle mode");
data = shuffle(data);
}

let tooltip = "";
for (let i = 0; i < data.length; i++) {
tooltip = data[i].des
Expand Down

0 comments on commit 9e6eac1

Please sign in to comment.