2023-10-03 11:14:36 +08:00
|
|
|
<%
|
|
|
|
import_script(`
|
|
|
|
<script>
|
|
|
|
Fluid.utils.createScript('${ url_join(theme.static_prefix.anchor, 'anchor.min.js') }', function() {
|
|
|
|
window.anchors.options = {
|
|
|
|
placement: CONFIG.anchorjs.placement,
|
|
|
|
visible : CONFIG.anchorjs.visible
|
|
|
|
};
|
|
|
|
if (CONFIG.anchorjs.icon) {
|
|
|
|
window.anchors.options.icon = CONFIG.anchorjs.icon;
|
|
|
|
}
|
|
|
|
var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
|
|
|
|
var res = [];
|
|
|
|
for (var item of el) {
|
|
|
|
res.push('.markdown-body > ' + item.trim());
|
|
|
|
}
|
|
|
|
if (CONFIG.anchorjs.placement === 'left') {
|
|
|
|
window.anchors.options.class = 'anchorjs-link-left';
|
|
|
|
}
|
|
|
|
window.anchors.add(res.join(', '));
|
|
|
|
|
|
|
|
Fluid.events.registerRefreshCallback(function() {
|
|
|
|
if ('anchors' in window) {
|
|
|
|
anchors.removeAll();
|
|
|
|
var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
|
|
|
|
var res = [];
|
|
|
|
for (var item of el) {
|
|
|
|
res.push('.markdown-body > ' + item.trim());
|
|
|
|
}
|
|
|
|
if (CONFIG.anchorjs.placement === 'left') {
|
|
|
|
anchors.options.class = 'anchorjs-link-left';
|
|
|
|
}
|
|
|
|
anchors.add(res.join(', '));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
`)
|
|
|
|
%>
|