2025-2-26-fixed
This commit is contained in:
39
themes/fluid/layout/_partials/plugins/anchorjs.ejs
Normal file
39
themes/fluid/layout/_partials/plugins/anchorjs.ejs
Normal file
@ -0,0 +1,39 @@
|
||||
<%
|
||||
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>
|
||||
`)
|
||||
%>
|
||||
Reference in New Issue
Block a user