This commit is contained in:
xaoxuu 2022-10-29 17:23:32 +08:00
parent 33243bb13e
commit 63ceaf5352
9 changed files with 56 additions and 43 deletions

View File

@ -1,5 +1,5 @@
--- ---
name: Any Question name: Any Question【问题反馈】
about: 主题使用方面任何问题或建议 about: 主题使用方面任何问题或建议
title: '' title: ''
labels: '' labels: ''

View File

@ -1,5 +1,5 @@
--- ---
name: Article Share name: Article Share【文章分享】
about: 与Stellar相关的文章分享 about: 与Stellar相关的文章分享
title: '[分享] ' title: '[分享] '
labels: '教程' labels: '教程'

View File

@ -45,6 +45,7 @@ function og_args() {
%> %>
<head> <head>
<%- meta_generator() %> <%- meta_generator() %>
<meta name="hexo-theme" content="<%- stellar_info('tree') %>">
<meta charset="utf-8"> <meta charset="utf-8">
<%- generate_robots() %> <%- generate_robots() %>
@ -60,6 +61,7 @@ function og_args() {
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#f8f8f8"> <meta name="theme-color" content="#f8f8f8">
<title><%- generate_title() %></title> <title><%- generate_title() %></title>
<% if (theme.open_graph && theme.open_graph.enable) { %> <% if (theme.open_graph && theme.open_graph.enable) { %>

View File

@ -90,6 +90,7 @@
} }
} }
}; };
stellar.version = '<%- theme.stellar.version %>';
stellar.github = 'https://github.com/xaoxuu/hexo-theme-stellar/tree/<%- theme.stellar.version %>'; stellar.github = 'https://github.com/xaoxuu/hexo-theme-stellar/tree/<%- theme.stellar.version %>';
stellar.config = { stellar.config = {
date_suffix: { date_suffix: {

View File

@ -25,7 +25,7 @@ module.exports = hexo => {
warning('caching', '`relative_link` option in Hexo `_config.yml`'); warning('caching', '`relative_link` option in Hexo `_config.yml`');
hexo.config.relative_link = false; hexo.config.relative_link = false;
} }
hexo.config.meta_generator = false; // hexo.config.meta_generator = false;
// merge data // merge data
const data = hexo.locals.get('data'); const data = hexo.locals.get('data');

View File

@ -42,9 +42,6 @@ hexo.extend.tag.register('friends', function(args) {
} }
el += '<div class="group-body">'; el += '<div class="group-body">';
const items = links[args.group] || []; const items = links[args.group] || [];
console.log('links', links);
console.log('group', args.group);
console.log('items', items);
items.forEach((item, i) => { items.forEach((item, i) => {
el += cell(item); el += cell(item);
}); });

View File

@ -36,14 +36,14 @@ function layoutNodeContent(content) {
function postTimeline(args, content) { function postTimeline(args, content) {
args = hexo.args.map(args, ['api', 'user', 'type', 'limit']); args = hexo.args.map(args, ['api', 'user', 'type', 'limit', 'hide']);
var el = ''; var el = '';
if (!args.type) { if (!args.type) {
args.type = 'timeline'; args.type = 'timeline';
} }
if (args.api && args.api.length > 0) { if (args.api && args.api.length > 0) {
el += '<div class="tag-plugin timeline stellar-' + args.type + '-api"'; el += '<div class="tag-plugin timeline stellar-' + args.type + '-api"';
el += ' ' + hexo.args.joinTags(args, ['api', 'user', 'limit']).join(' '); el += ' ' + hexo.args.joinTags(args, ['api', 'user', 'limit', 'hide']).join(' ');
el += '>'; el += '>';
} else { } else {
el += '<div class="tag-plugin timeline">'; el += '<div class="tag-plugin timeline">';

View File

@ -1,4 +1,4 @@
console.log('hexo-theme-stellar:\n' + stellar.github); console.log('\n' + '%c Stellar v' + stellar.version + ' %c\n' + stellar.github + '\n', 'color:#e8fafe;background:#03c7fa;padding:8px;border-radius:4px', 'margin-top:8px');
// utils // utils
const util = { const util = {

View File

@ -57,12 +57,18 @@ const StellarTimeline = {
$(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>'); $(el).append('<div class="loading-wrap"><svg xmlns="http://www.w3.org/2000/svg" width="2rem" height="2rem" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"><path stroke-dasharray="60" stroke-dashoffset="60" stroke-opacity=".3" d="M12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3Z"><animate fill="freeze" attributeName="stroke-dashoffset" dur="1.3s" values="60;0"/></path><path stroke-dasharray="15" stroke-dashoffset="15" d="M12 3C16.9706 3 21 7.02944 21 12"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0"/><animateTransform attributeName="transform" dur="1.5s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/></path></g></svg></div>');
StellarTimeline.requestAPI(cfg.api, function(data) { StellarTimeline.requestAPI(cfg.api, function(data) {
$(el).find('.loading-wrap').remove(); $(el).find('.loading-wrap').remove();
const query = new URL(cfg.api).search;
const arr = data.content || data; const arr = data.content || data;
var users = []; var users = [];
const filter = el.getAttribute('user'); const filter = el.getAttribute('user');
if (filter && filter.length > 0) { if (filter && filter.length > 0) {
users = filter.split(","); users = filter.split(",");
} }
var hide = [];
const hideStr = el.getAttribute('hide');
if (hideStr && hideStr.length > 0) {
hide = hideStr.split(",");
}
arr.forEach((item, i) => { arr.forEach((item, i) => {
if (item.user && item.user.login && users.length > 0) { if (item.user && item.user.login && users.length > 0) {
if (!users.includes(item.user.login)) { if (!users.includes(item.user.login)) {
@ -81,46 +87,53 @@ const StellarTimeline = {
cell += '<p>' + date.toString().replace(/\sGMT([^.]*)/i, "") + '</p>'; cell += '<p>' + date.toString().replace(/\sGMT([^.]*)/i, "") + '</p>';
cell += '</div>'; cell += '</div>';
cell += '<div class="body">'; cell += '<div class="body">';
cell += '<p class="title">'; if (!hide.includes('title')) {
cell += '<a href="' + item.html_url + '" target="_blank" rel="external nofollow noopener noreferrer">'; cell += '<p class="title">';
cell += item.title || item.name || item.tag_name; cell += '<a href="' + item.html_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
cell += '</a>'; cell += item.title || item.name || item.tag_name;
cell += '</p>'; cell += '</a>';
cell += '</p>';
}
cell += marked.parse(item.body); cell += marked.parse(item.body);
cell += '<div class="footer">'; if (!hide.includes('footer')) {
cell += '<div class="flex left">'; cell += '<div class="footer">';
if (item.labels) { cell += '<div class="flex left">';
item.labels.forEach((label, i) => { if (item.labels) {
cell += '<div class="item label ' + label.name + '" style="background:#' + label.color + '18;border-color:#' + label.color + '36">'; item.labels.forEach((label, i) => {
cell += '<span>' + label.name + '</span>'; if (!query || !query.includes(encodeURI(label.name))) {
cell += '</div>'; cell += '<div class="item label ' + label.name + '" style="background:#' + label.color + '18;border-color:#' + label.color + '36">';
}); cell += '<span>' + label.name + '</span>';
} else if (item.zipball_url) { cell += '</div>';
cell += '<a class="item download" href="' + item.zipball_url + '" target="_blank" rel="external nofollow noopener noreferrer">'; }
cell += '<span>📦 ' + item.tag_name + '.zip</span>'; });
cell += '</a>'; } else if (item.zipball_url) {
} cell += '<a class="item download" href="' + item.zipball_url + '" target="_blank" rel="external nofollow noopener noreferrer">';
cell += '</div>'; cell += '<span>📦 ' + item.tag_name + '.zip</span>';
cell += '<div class="flex right">'; cell += '</a>';
if (item.reactions && item.reactions.total_count > 0) { }
for (let key of Object.keys(StellarTimeline.reactions)) { cell += '</div>';
let num = item.reactions[key]; cell += '<div class="flex right">';
if (num > 0) { if (item.reactions && item.reactions.total_count > 0) {
cell += '<div class="item reaction ' + key + '">'; for (let key of Object.keys(StellarTimeline.reactions)) {
cell += '<span>' + StellarTimeline.reactions[key] + ' ' + item.reactions[key] + '</span>'; let num = item.reactions[key];
cell += '</div>'; if (num > 0) {
cell += '<div class="item reaction ' + key + '">';
cell += '<span>' + StellarTimeline.reactions[key] + ' ' + item.reactions[key] + '</span>';
cell += '</div>';
}
} }
} }
} if (item.comments != null) {
if (item.comments != null) { cell += '<a class="item comments last" href="' + item.html_url + '#issuecomment-new" target="_blank" rel="external nofollow noopener noreferrer">';
cell += '<a class="item comments last" href="' + item.html_url + '#issuecomment-new" target="_blank" rel="external nofollow noopener noreferrer">'; cell += '<span><svg t="1666270368054" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2528" width="200" height="200"><path d="M952 64H72C32.3 64 0 96.3 0 136v508c0 39.7 32.3 72 72 72h261l128 128c14 14 32.5 21.1 50.9 21.1s36.9-7 50.9-21.1l128-128h261c39.7 0 72-32.3 72-72V136c0.2-39.7-32.1-72-71.8-72zM222 462c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72-32.2 72-72 72z m290-7.7c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z m290 8c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z" p-id="2529"></path></svg> ' + (item.comments || 0) + '</span>';
cell += '<span><svg t="1666270368054" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2528" width="200" height="200"><path d="M952 64H72C32.3 64 0 96.3 0 136v508c0 39.7 32.3 72 72 72h261l128 128c14 14 32.5 21.1 50.9 21.1s36.9-7 50.9-21.1l128-128h261c39.7 0 72-32.3 72-72V136c0.2-39.7-32.1-72-71.8-72zM222 462c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72-32.2 72-72 72z m290-7.7c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z m290 8c-39.8 0-72-32.2-72-72s32.2-72 72-72 72 32.2 72 72c0 39.7-32.2 72-72 72z" p-id="2529"></path></svg> ' + (item.comments || 0) + '</span>'; cell += '</a>';
cell += '</a>'; }
cell += '</div>';
cell += '</div>';
} }
cell += '</div>';
cell += '</div>';
cell += '</div>'; cell += '</div>';
cell += '</div>'; cell += '</div>';
$(el).append(cell); $(el).append(cell);