Files
talk/docs/themes/coral/scripts/toc.js
T
2018-02-20 15:59:44 -07:00

20 lines
450 B
JavaScript

/* global hexo */
const cheerio = require('cheerio');
// This helper replaces the ol tags outputted by the base toc helper with ui
// tags.
hexo.extend.helper.register('oltoul', function(source) {
const $ = cheerio.load(source);
// Sourced from https://stackoverflow.com/a/12679823
$(
$('ol')
.get()
.reverse()
).each(function() {
$(this).replaceWith($('<ul>' + $(this).html() + '</ul>'));
});
return $.html();
});