[opt] links: friends & sites
This commit is contained in:
parent
dc0e43688f
commit
4c10b83e14
|
@ -5,6 +5,7 @@
|
||||||
hexo.on('generateBefore', () => {
|
hexo.on('generateBefore', () => {
|
||||||
// Merge config.
|
// Merge config.
|
||||||
require('./lib/config')(hexo);
|
require('./lib/config')(hexo);
|
||||||
|
require('./lib/links')(hexo);
|
||||||
require('./lib/doc_tree')(hexo);
|
require('./lib/doc_tree')(hexo);
|
||||||
require('./lib/utils')(hexo);
|
require('./lib/utils')(hexo);
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
/**
|
||||||
|
* doc_tree.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = ctx => {
|
||||||
|
var allLinks = {}
|
||||||
|
const data = ctx.locals.get('data')
|
||||||
|
for (let key of Object.keys(data)) {
|
||||||
|
if (key.startsWith('links/')) {
|
||||||
|
let newKey = key.replace('links/', '')
|
||||||
|
allLinks[newKey] = data[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.theme.config.links = allLinks
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
module.exports = ctx => function(args) {
|
module.exports = ctx => function(args) {
|
||||||
args = ctx.args.map(args, ['repo', 'api'], ['group'])
|
args = ctx.args.map(args, ['repo', 'api'], ['group'])
|
||||||
var links = ctx.locals.get('data').links
|
var links = ctx.theme.config.links
|
||||||
if (links == undefined) {
|
if (links == undefined) {
|
||||||
links = {}
|
links = {}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ module.exports = ctx => function(args) {
|
||||||
if (item.url && item.title) {
|
if (item.url && item.title) {
|
||||||
var cell = '<div class="user-card">'
|
var cell = '<div class="user-card">'
|
||||||
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">'
|
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">'
|
||||||
cell += '<img src="' + (item.avatar || ctx.theme.config.default.avatar) + '" onerror="javascript:this.removeAttribute("data-src")this.src="' + ctx.theme.config.default.avatar + '""/>'
|
cell += '<img src="' + (item.icon || item.avatar || ctx.theme.config.default.avatar) + '" onerror="javascript:this.removeAttribute("data-src")this.src="' + ctx.theme.config.default.avatar + '""/>'
|
||||||
cell += '<div class="name"><span>' + item.title + '</span></div>'
|
cell += '<div class="name"><span>' + item.title + '</span></div>'
|
||||||
cell += '</a></div>'
|
cell += '</a></div>'
|
||||||
return cell
|
return cell
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
module.exports = ctx => function(args) {
|
module.exports = ctx => function(args) {
|
||||||
args = ctx.args.map(args, ['repo', 'api'], ['group'])
|
args = ctx.args.map(args, ['repo', 'api'], ['group'])
|
||||||
var links = ctx.locals.get('data').links
|
var links = ctx.theme.config.links
|
||||||
if (links == undefined) {
|
if (links == undefined) {
|
||||||
links = {}
|
links = {}
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ module.exports = ctx => function(args) {
|
||||||
if (item.url && item.title) {
|
if (item.url && item.title) {
|
||||||
var cell = '<div class="site-card">'
|
var cell = '<div class="site-card">'
|
||||||
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">'
|
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">'
|
||||||
cell += '<img src="' + (item.screenshot || ('https://api.vlts.cc/screenshot?url=' + item.url + '&width=1280&height=720')) + '" onerror="javascript:this.removeAttribute("data-src");this.src="' + ctx.theme.config.default.cover + '";"/>'
|
cell += '<img src="' + (item.cover || item.screenshot || ('https://api.vlts.cc/screenshot?url=' + item.url + '&width=1280&height=720')) + '" onerror="javascript:this.removeAttribute("data-src");this.src="' + ctx.theme.config.default.cover + '";"/>'
|
||||||
cell += '<div class="info">'
|
cell += '<div class="info">'
|
||||||
cell += '<img src="' + (item.avatar || ctx.theme.config.default.link) + '" onerror="javascript:this.removeAttribute("data-src");this.src="' + ctx.theme.config.default.link + '";"/>'
|
cell += '<img src="' + (item.icon || item.avatar || ctx.theme.config.default.link) + '" onerror="javascript:this.removeAttribute("data-src");this.src="' + ctx.theme.config.default.link + '";"/>'
|
||||||
cell += '<span class="title">' + item.title + '</span>'
|
cell += '<span class="title">' + item.title + '</span>'
|
||||||
cell += '<span class="desc">' + (item.description || item.url) + '</span>'
|
cell += '<span class="desc">' + (item.description || item.url) + '</span>'
|
||||||
cell += '</div>'
|
cell += '</div>'
|
||||||
|
|
|
@ -52,7 +52,7 @@ const friendsjs = {
|
||||||
var user = '<div class="user-card">';
|
var user = '<div class="user-card">';
|
||||||
user += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer"';
|
user += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer"';
|
||||||
user += ' href="' + (item.html_url || item.url) + '">';
|
user += ' href="' + (item.html_url || item.url) + '">';
|
||||||
user += '<img src="' + (item.avatar_url || item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';">';
|
user += '<img src="' + (item.avatar_url || item.avatar || item.icon || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';">';
|
||||||
user += '<div class="name"><span>' + (item.title || item.login) + '</span></div>';
|
user += '<div class="name"><span>' + (item.title || item.login) + '</span></div>';
|
||||||
user += '</a>';
|
user += '</a>';
|
||||||
user += '</div>';
|
user += '</div>';
|
||||||
|
|
|
@ -51,9 +51,9 @@ const sitesjs = {
|
||||||
arr.forEach((item, i) => {
|
arr.forEach((item, i) => {
|
||||||
var cell = '<div class="site-card">';
|
var cell = '<div class="site-card">';
|
||||||
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">';
|
cell += '<a class="card-link" target="_blank" rel="external nofollow noopener noreferrer" href="' + item.url + '">';
|
||||||
cell += '<img src="' + (item.screenshot || ('https://api.vlts.cc/screenshot?url=' + item.url + '&width=1280&height=720')) + '" onerror="javascript:this.src=\'' + cfg.screenshot + '\';"/>';
|
cell += '<img src="' + (item.cover || item.screenshot || ('https://api.vlts.cc/screenshot?url=' + item.url + '&width=1280&height=720')) + '" onerror="javascript:this.src=\'' + cfg.screenshot + '\';"/>';
|
||||||
cell += '<div class="info">';
|
cell += '<div class="info">';
|
||||||
cell += '<img src="' + (item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';"/>';
|
cell += '<img src="' + (item.icon || item.avatar || cfg.avatar) + '" onerror="javascript:this.src=\'' + cfg.avatar + '\';"/>';
|
||||||
cell += '<span class="title">' + item.title + '</span>';
|
cell += '<span class="title">' + item.title + '</span>';
|
||||||
cell += '<span class="desc">' + (item.description || item.url) + '</span>';
|
cell += '<span class="desc">' + (item.description || item.url) + '</span>';
|
||||||
cell += '</div>';
|
cell += '</div>';
|
||||||
|
|
Loading…
Reference in New Issue