Skip to content

Commit 491942e

Browse files
committed
Move TOC links to the left.
1 parent ff2705c commit 491942e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tasks/build.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,23 @@ grunt.registerHelper( "parse-markdown", function( src, generateToc ) {
147147
return false;
148148
}
149149

150+
// Store original text and create an id for linking
150151
item.tocText = item.text;
151152
item.tocId = item.text
152153
.replace( /\W+/g, "-" )
153154
.replace( /^-+|-+$/, "" )
154155
.toLowerCase();
155-
item.text += " <a href='#" + item.tocId + "' id='" + item.tocId + "'>link</a>";
156+
157+
// Convert to HTML
158+
item.type = "html";
159+
item.pre = false;
160+
161+
// Insert the link
162+
item.text = "<h" + item.depth + " class='toc-linked'>" +
163+
"<a href='#" + item.tocId + "' id='" + item.tocId + "' class='icon-link'>" +
164+
"<span class='visuallyhidden'>link</span>" +
165+
"</a> " + item.text + "</h" + item.depth + ">";
166+
156167
return true;
157168
}).forEach(function( item ) {
158169
toc += Array( (item.depth - 1) * 2 + 1 ).join( " " ) + "* " +

0 commit comments

Comments
 (0)