Closed Movelocity closed 11 months ago
Demo: http://139.159.188.217:7900/2023/10/09/hexo/hexo-tricks/
使用 hexo 引擎内置函数 toc(), <%- toc(page.content) %>,位于 node_modeules/hexo/plugins/helper/toc.js。可以简单地在sidebar sticky 部分加入一个 toc,方便看长篇博客的时候快速导航。
<%- toc(page.content) %>
修改 _partial/sidebar.ejs,渲染时加入判断,如果是toc就取消cache,防止内部获取不到page变量
在 css/_partial/sidebar.styl 修改toc侧栏的 <ol> 样式,防止toc渲染过程中出现<ol>自带的数字干扰
<ol>
在配置模板s idebar 中增加了toc的配置选项
增加 toc 对应的简中繁中翻译
感谢 PR,我可能需要再调整一下样式
增加 toc 目录为 sidebar 的可选组件
Demo: http://139.159.188.217:7900/2023/10/09/hexo/hexo-tricks/
原理
使用 hexo 引擎内置函数 toc(),
<%- toc(page.content) %>
,位于 node_modeules/hexo/plugins/helper/toc.js。可以简单地在sidebar sticky 部分加入一个 toc,方便看长篇博客的时候快速导航。改动说明
修改 _partial/sidebar.ejs,渲染时加入判断,如果是toc就取消cache,防止内部获取不到page变量
在 css/_partial/sidebar.styl 修改toc侧栏的
<ol>
样式,防止toc渲染过程中出现<ol>
自带的数字干扰在配置模板s idebar 中增加了toc的配置选项
增加 toc 对应的简中繁中翻译