File tree Expand file tree Collapse file tree 4 files changed +178
-182
lines changed Expand file tree Collapse file tree 4 files changed +178
-182
lines changed Original file line number Diff line number Diff line change @@ -37,19 +37,28 @@ module.exports = function (eleventyConfig) {
37
37
eleventyConfig . addPlugin ( pluginRss ) ;
38
38
eleventyConfig . addPlugin ( syntaxHighlight ) ;
39
39
40
- //Slugify (add strict mode)
41
- const markdownItAnchorOptions = {
42
- level : [ 1 , 2 , 3 ] ,
40
+ //Replace Markdown with custom configurations
41
+ const md = markdownIt ( {
42
+ html : true ,
43
+ linkify : true ,
44
+ typographer : true
45
+ } ) . use ( markdownItAnchor , {
46
+ level : [ 2 , 3 , 4 , 5 , 6 ] ,
43
47
slugify : ( str ) =>
44
48
slugify ( str , {
45
49
lower : true ,
46
50
strict : true ,
47
51
remove : / [ " ] / g,
48
52
} ) ,
49
- } ;
53
+ permalink : markdownItAnchor . permalink . linkInsideHeader ( {
54
+ symbol : ' #' ,
55
+ placement : 'after' ,
56
+ ariaHidden : true ,
57
+ class : 'header-anchor' ,
58
+ } ) ,
59
+ } ) ;
50
60
51
- //Replace Markdown with custom configurations
52
- eleventyConfig . setLibrary ( "md" , markdownIt ( ) . use ( markdownItAnchor , markdownItAnchorOptions ) )
61
+ eleventyConfig . setLibrary ( "md" , md ) ;
53
62
54
63
//Search: pageFind
55
64
eleventyConfig . on ( 'eleventy.after' , ( ) => {
Original file line number Diff line number Diff line change 42
42
},
43
43
"dependencies" : {
44
44
"eleventy-plugin-youtube-embed" : " ^1.11.0" ,
45
+ "markdown-it" : " ^14.1.0" ,
46
+ "markdown-it-attrs" : " ^4.3.1" ,
45
47
"remove" : " ^0.1.5" ,
46
48
"slugify" : " ^1.6.6"
47
49
},
Original file line number Diff line number Diff line change 57
57
text-decoration : none;
58
58
color : # 7f7f7f ;
59
59
}
60
+
61
+ .header-anchor {
62
+ text-decoration : none;
63
+ margin-left : 0.25em ;
64
+ font-weight : normal;
65
+ visibility : hidden;
66
+ }
67
+
68
+ h2 : hover .header-anchor ,
69
+ h3 : hover .header-anchor ,
70
+ h4 : hover .header-anchor ,
71
+ h5 : hover .header-anchor ,
72
+ h6 : hover .header-anchor {
73
+ visibility : visible;
74
+ }
You can’t perform that action at this time.
0 commit comments