diff --git a/_data/links.yml b/_data/links.yml
new file mode 100644
index 0000000..d6f2061
--- /dev/null
+++ b/_data/links.yml
@@ -0,0 +1,7 @@
+
+'示例':
+ - title: XAOXUU
+ avatar: https://bu.dusays.com/2021/09/24/2f74810ceb3d3.png
+ url: https://xaoxuu.com
+ screenshot: https://bu.dusays.com/2022/10/23/63542895cfd29.png
+ description:
diff --git a/scripts/tags/friends.js b/scripts/tags/friends.js
index e8a83cf..095945b 100644
--- a/scripts/tags/friends.js
+++ b/scripts/tags/friends.js
@@ -1,92 +1,56 @@
/**
- * friends.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
+ * friends.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/
* 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
*
- * {% friends [only:group1] [not:group2] %}
+ * {% friends [group] [repo:owner/repo] [data:http] %}
*/
'use strict';
hexo.extend.tag.register('friends', function(args) {
- args = hexo.args.map(args, ['only', 'not', 'repo', 'api']);
- if (args.only) {
- args.only = args.only.split(',');
+ args = hexo.args.map(args, ['repo', 'data'], ['group']);
+ var links = hexo.locals.get('data').links;
+ if (links == undefined) {
+ links = {};
}
- if (args.not) {
- args.not = args.not.split(',');
- }
- var friends = hexo.locals.get('data').friends;
- if (friends == undefined) {
- friends = {};
- }
- if (args.repo) {
- friends = {
- group: {
- api: args.api,
- repo: args.repo
- }
- }
+ var data;
+ if (args.data) {
+ data = args.data;
+ } else if (args.repo) {
+ data = 'https://raw.github.xaoxuu.com/' + args.repo + '/output/v2/data.json';
}
+
var el = '
';
- function groupHeader(group) {
- var header = '';
- return header;
- }
- function cell(friend) {
- if (friend.url && friend.title) {
- var cell = '
'
- return cell;
- } else {
- return '';
- }
- }
- for (let groupId of Object.keys(friends)) {
- function f() {
- if (args.not && args.not.includes(groupId)) {
- return;
- }
- if (groupId in friends) {
- let group = friends[groupId];
- if ((typeof group == 'object') && group.constructor == Array) {
- group = {items: group};
- }
- if (group.title || group.description) {
- el += groupHeader(group);
- }
- if (group.repo) {
- el += '
';
- } else if (group.items) {
- el += '
';
- group.items.forEach((friend, i) => {
- el += cell(friend);
- });
- el += '
';
- }
+ if (data) {
+ el += '
';
+ } else if (args.group) {
+ function cell(item) {
+ if (item.url && item.title) {
+ var cell = '
'
+ return cell;
+ } else {
+ return '';
}
}
- if (args.only) {
- if (args.only.includes(groupId)) {
- f();
- }
- } else {
- f();
- }
+ el += '
';
+ const items = links[args.group] || [];
+ console.log('links', links);
+ console.log('group', args.group);
+ console.log('items', items);
+ items.forEach((item, i) => {
+ el += cell(item);
+ });
+ el += '
';
}
+
el += '
';
return el;
});
diff --git a/scripts/tags/issues.js b/scripts/tags/issues.js
deleted file mode 100644
index 660df93..0000000
--- a/scripts/tags/issues.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * issues.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
- * 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
- *
- * {% issues [sites/timeline/friends] api:xxx [group:key=value1,value2,value3] %}
- *
- * example:
- * {% issues sites api:https://api.github.com/repos/volantis-x/examples/issues?sort=updated&state=open&page=1&per_page=100 group:version=版本:^4.0,版本:^3.0,版本:^2.0 %}
- */
-
-'use strict';
-
-hexo.extend.tag.register('issues', function(args) {
- args = hexo.args.map(args, ['api', 'group'], ['type']);
- // 所有支持的参数
- let type = args.type || '';
- let api = args.api || '';
- let group = args.group || '';
- if (type.length == 0 || api.length == 0) {
- return;
- }
- // 布局
- var el = ' 0) {
- el += 'group="' + group + '"';
- }
- el += '>
';
- return el;
-});
diff --git a/scripts/tags/sites.js b/scripts/tags/sites.js
index e5e84c9..beb3639 100644
--- a/scripts/tags/sites.js
+++ b/scripts/tags/sites.js
@@ -1,96 +1,57 @@
/**
- * sites.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
+ * sites.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/
* 格式与官方标签插件一致使用空格分隔,中括号内的是可选参数(中括号不需要写出来)
*
- * {% sites [only:group1] [not:group2] %}
+ * {% sites [group] [repo:owner/repo] [data:http] %}
*/
'use strict';
hexo.extend.tag.register('sites', function(args) {
- args = hexo.args.map(args, ['only', 'not', 'repo', 'api']);
- if (args.only) {
- args.only = args.only.split(',');
+ args = hexo.args.map(args, ['repo', 'data'], ['group']);
+ var links = hexo.locals.get('data').links;
+ if (links == undefined) {
+ links = {};
}
- if (args.not) {
- args.not = args.not.split(',');
- }
- var sites = hexo.locals.get('data').sites;
- if (sites == undefined) {
- sites = {};
- }
- if (args.repo) {
- sites = {
- group: {
- api: args.api,
- repo: args.repo
- }
- }
+ var data;
+ if (args.data) {
+ data = args.data;
+ } else if (args.repo) {
+ data = 'https://raw.github.xaoxuu.com/' + args.repo + '/output/v2/data.json';
}
+
var el = '';
- function groupHeader(group) {
- var header = '';
- return header;
- }
- function cell(site) {
- if (site.url && site.title) {
- var cell = '
'
- return cell;
- } else {
- return '';
- }
- }
- for (let groupId of Object.keys(sites)) {
- function f() {
- if (args.not && args.not.includes(groupId)) {
- return;
- }
- if (groupId in sites) {
- let group = sites[groupId];
- if ((typeof group == 'object') && group.constructor == Array) {
- group = {items: group};
- }
- if (group.title || group.description) {
- el += groupHeader(group);
- }
- if (group.repo) {
- el += '
';
- } else if (group.items) {
- el += '
';
- group.items.forEach((site, i) => {
- el += cell(site);
- });
- el += '
';
- }
+ if (data) {
+ el += '
';
+ } else if (args.group) {
+ function cell(item) {
+ if (item.url && item.title) {
+ var cell = '
'
+ return cell;
+ } else {
+ return '';
}
}
- if (args.only) {
- if (args.only.includes(groupId)) {
- f();
- }
- } else {
- f();
- }
+ el += '
';
+ const items = links[args.group] || [];
+ items.forEach((item, i) => {
+ el += cell(item);
+ });
+ el += '
';
}
+
el += '
';
return el;
});