blog-hexo/themes/hexo-theme-cosy/scripts/generate_nav.js
2023-11-10 13:44:10 +08:00

25 lines
626 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
});