Skip to content

Commit

Permalink
Make all headings in blog posts linkable
Browse files Browse the repository at this point in the history
It's nice to be able to link certain sections of a blog post
when trying to share ideas.

Followed the steps [here](https://blog.briandrupieski.com/generate-anchors-in-jekyll-blog-post)
to autogenerate links next to headers in posts

jquery-3.4.1.min.js is from [here](https://code.jquery.com/jquery-3.4.1.min.js)
anchor.min.js is from [here](https://github.com/bryanbraun/anchorjs/blob/4.2.0/anchor.min.js)
  • Loading branch information
chrisc11 committed Jun 13, 2019
1 parent 8b7376b commit 6bcce0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _layouts/post.html
Expand Up @@ -2,6 +2,7 @@
layout: default
---
<article id="post-page">
<script src="/js/anchor.min.js"></script>
<h2>{{ page.title }}</h2>
<time datetime="{{ page.date | date_to_xmlschema }}" class="by-line">{{ page.date | date_to_string }}</time>
<div class="content">
Expand Down Expand Up @@ -29,5 +30,7 @@ <h2>{{ page.title }}</h2>
d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
})();
anchors.options.visible = 'hover';
anchors.add('.post-content > h1, h2, h3, h4, h5, h6');
</script>

9 changes: 9 additions & 0 deletions js/anchor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6bcce0c

Please sign in to comment.