Add a simple way to customize anchor injection#75
Add a simple way to customize anchor injection#75kitt-cat wants to merge 1 commit intotoshimaru:mainfrom
Conversation
e3d1091 to
d68bb90
Compare
d68bb90 to
02c24ea
Compare
|
|
||
| ```liquid | ||
| <!-- Append an anchor pilcrow after the heading text, Sphinx style: --> | ||
| {{ heading_text }} <a class="anchor" aria-hidden="true" href="{{ page.url }}{{ heading_id }}">¶</a> |
There was a problem hiding this comment.
I'm wondering why you need to configure page.url.
I think anchor's href should be #heading-title, for instance. 🤔
There was a problem hiding this comment.
In this example, the idea is for the anchor to provide an absolute reference so right click -> copy link gives something which can be pasted anywhere. Of course, the goal is for customization; you could of course just use #{{ heading_id }} to get a relative reference, if that is what one wishes.
|
@Gandalf3 How do you think about using anchor.js? Does this meet your requirement? |
|
@toshimaru I was also looking for a way to do this in jekyll to avoid (imo unnecessary) javascript. That said I understand if most are happy with a javascript solution, and I can live with using my patched version for my own purposes if you decide this feature doesn't fit in jekyll-toc. |
Implementation for #43
This change adds a setting for a liquid template to be used for anchor injection:
The template is supplied with the original text content (
heading_text) and id (heading_id) for each heading element:The above template, when injected on an
<h1>, yields html like the following: