blog-hexo/themes/hexo-theme-cosy/scripts/generate_nav.js

25 lines
626 B
JavaScript
Raw Normal View History

2023-11-10 13:44:10 +08:00
hexo.extend.helper.register('generate_nav', function (categories) {
// 获取主题配置
const nav_meta = hexo.theme.config['nav_meta'] ?? {}
const specialMap = {
'timeline': "archives",
}
let result = '<ul>';
for (let key in nav_meta) {
const value = nav_meta[key]
// 设定为 false 不显示否则为svg icon 的 path
if (value !== false) {
result += `<li data-path="${key}">
<a href="/${specialMap[key] ?? key}">
${value}
<div class="ellipsis">${this.__('text-' + key)}</div>
</a>
</li>`
}
}
result += '</ul>';
return result;
});