Skip to content

Commit

Permalink
ergonomic header anchors with visible change on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
pdaoust committed Mar 28, 2024
1 parent ccff3dc commit 8acaefd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion 11ty-extensions/markdown-it-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export default function(eleventyConfig) {

//Configure markdown-it plugins
mdLib.use(markdownItAttrs);
mdLib.use(markdownItAnchor, { tabIndex: false, slugify: s => slugify(s) });
mdLib.use(markdownItAnchor, {
tabIndex: false,
slugify: s => slugify(s),
permalink: markdownItAnchor.permalink.headerLink(),
});
mdLib.use(markdownItContainer, "intro");
mdLib.use(markdownItContainer, "orientation");
mdLib.use(markdownItContainer, "storystep");
Expand Down
17 changes: 17 additions & 0 deletions src/scss/_base-element-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ a {
svg {
height: 100%;
}

&.header-anchor {
text-decoration: none;
color: inherit;

&:hover, &:focus {
text-decoration: underline;

&::before {
display: block;
float: left;
width: 0.75em;
margin-left: -0.75em;
content: '#';
}
}
}
}

button {
Expand Down

0 comments on commit 8acaefd

Please sign in to comment.