Add manual heading anchor paired shortcode
This commit is contained in:
parent
42ef599363
commit
ddf10203f9
|
@ -61,6 +61,14 @@ module.exports = function (eleventyConfig) {
|
||||||
// Shortcode: <cite> tag
|
// Shortcode: <cite> tag
|
||||||
eleventyConfig.addShortcode('cite', (str) => `<cite>${str}</cite>`);
|
eleventyConfig.addShortcode('cite', (str) => `<cite>${str}</cite>`);
|
||||||
|
|
||||||
|
// Paired shortcode: Manual heading anchor
|
||||||
|
eleventyConfig.addPairedShortcode('headingAnchor', (title, hLevel, id) => {
|
||||||
|
return `<div class="heading-wrapper h${hLevel}">
|
||||||
|
<h${hLevel} id="${id}">${title}</h2>
|
||||||
|
<a class="heading-anchor" href="#${id}" aria-labelledby="${id}"><span hidden="">#</span></a>
|
||||||
|
</div>`;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dir: {
|
dir: {
|
||||||
input: "src"
|
input: "src"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% for log in changelogList | reverse %}
|
{% for log in changelogList | reverse %}
|
||||||
<div class="heading-wrapper h2">
|
{% headingAnchor 2, log.fileSlug %}
|
||||||
<h2 id="{{ log.fileSlug }}">{{ log.date | formatDate }}</h2>
|
{{ log.date | formatDate }}
|
||||||
<a class="heading-anchor" href="#{{ log.fileSlug }}" aria-labelledby="{{ log.fileSlug }}"><span hidden="">#</span></a>
|
{% endheadingAnchor %}
|
||||||
</div>
|
|
||||||
{{ log.templateContent | safe }}
|
{{ log.templateContent | safe }}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
Loading…
Reference in New Issue