Skip to content

Commit

Permalink
Added name attributes to anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
jahilldev committed Feb 18, 2021
1 parent cf91b76 commit 37a0513
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = function (config) {
permalinkBefore: true,
permalinkClass: 'title-anchor',
permalinkSymbol: '',
permalinkAttrs: (slug) => ({ name: normaliseTitleAnchors(slug) }),
slugify: slugifyTitleAnchors,
})
);
Expand Down Expand Up @@ -120,3 +121,15 @@ function slugifyTitleAnchors(value) {
.replace(/-+$/, '')
);
}

/* -----------------------------------
*
* Anchors
*
* -------------------------------- */

function normaliseTitleAnchors(value) {
const result = value.replace(/-/g, ' ');

return result.charAt(0).toUpperCase() + result.slice(1);
}

0 comments on commit 37a0513

Please sign in to comment.