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

21 lines
541 B
JavaScript
Raw Permalink 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 || {}
2024-01-14 17:21:19 +08:00
let basePath = ctx.theme.config.site_tree.author.base_dir
2024-01-04 22:50:57 +08:00
// 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
}