hexo-theme-stellar/scripts/events/lib/authors.js

21 lines
532 B
JavaScript
Raw Normal View History

2024-01-04 22:50:57 +08:00
/**
* authors.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/
*/
'use strict';
module.exports = ctx => {
var authors = ctx.locals.get('data').authors || {}
let basePath = ctx.config.author_dir || 'author'
// url
for (let key of Object.keys(authors)) {
let author = authors[key]
author.path = `${basePath}/${key}/index.html`
}
// default author
const keys = Object.keys(authors)
if (keys.length > 0) {
ctx.theme.config.default_author = authors[keys[0]]
}
ctx.theme.config.authors = authors
}