From b3c855d4f9294cc480d57c74baa7bc4982ba8e08 Mon Sep 17 00:00:00 2001 From: xdavidwu Date: Wed, 23 Sep 2020 11:11:49 +0800 Subject: [PATCH] ruby-based anchor --- _plugins/anchor.rb | 5 +++++ assets/js/_main.js | 13 ------------- 2 files changed, 5 insertions(+), 13 deletions(-) create mode 100644 _plugins/anchor.rb diff --git a/_plugins/anchor.rb b/_plugins/anchor.rb new file mode 100644 index 0000000..93779a4 --- /dev/null +++ b/_plugins/anchor.rb @@ -0,0 +1,5 @@ +class Jekyll::MarkdownHeader < Jekyll::Converters::Markdown + def convert(content) + super.gsub(/(.*)<\/h(\d)>/, '\3Permalink') + end +end diff --git a/assets/js/_main.js b/assets/js/_main.js index 44d3275..3eb971c 100644 --- a/assets/js/_main.js +++ b/assets/js/_main.js @@ -117,17 +117,4 @@ $(document).ready(function() { closeOnContentClick: true, midClick: true // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source. })*/; - - // Add anchors for headings - $('.page__content').find('h1, h2, h3, h4, h5, h6').each(function() { - var id = $(this).attr('id'); - if (id) { - var anchor = document.createElement("a"); - anchor.className = 'header-link'; - anchor.href = '#' + id; - anchor.innerHTML = 'Permalink'; - anchor.title = "Permalink"; - $(this).append(anchor); - } - }); }); -- 2.43.0