File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed
Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1515</ script >
1616{% endif %}
1717< script type ="text/javascript " async src ="/assets/js/love.js "> </ script >
18+ < script type ="text/javascript " async src ="/assets/js/auto-heading-links.js "> </ script >
1819<!-- Minimal Mistakes layout: {{ page.layout }} -->
Original file line number Diff line number Diff line change @@ -100,3 +100,33 @@ body.landing {
100100 }
101101 }
102102}
103+
104+ section .page__content {
105+ h2 , h3 , h4 , h5 , h6 {
106+ .header-link {
107+ position : relative ;
108+ left : 0.5em ;
109+ opacity : 0 ;
110+ font-size : 0.8em ;
111+ -webkit-transition : opacity 0.2s ease-in-out 0.1s ;
112+ -moz-transition : opacity 0.2s ease-in-out 0.1s ;
113+ -o-transition : opacity 0.2s ease-in-out 0.1s ;
114+ transition : opacity 0.2s ease-in-out 0.1s ;
115+ }
116+
117+ & :hover .header-link {
118+ opacity : 1 ;
119+ }
120+ }
121+ }
122+
123+ .sr-only { // Screen reader only
124+ position : absolute ;
125+ width : 1px ;
126+ height : 1px ;
127+ padding : 0 ;
128+ margin : -1px ;
129+ overflow : hidden ;
130+ clip : rect (0 , 0 , 0 , 0 );
131+ border : 0 ;
132+ }
Original file line number Diff line number Diff line change 1+ var anchorForId = function ( id ) {
2+ var anchor = document . createElement ( "a" ) ;
3+ anchor . className = "header-link" ;
4+ anchor . href = "#" + id ;
5+ anchor . innerHTML = "<span class=\"sr-only\">Permalink</span><i class=\"fa fa-link\"></i>" ;
6+ anchor . title = "Permalink" ;
7+ return anchor ;
8+ } ;
9+
10+ var linkifyAnchors = function ( level , containingElement ) {
11+ var headers = containingElement . getElementsByTagName ( "h" + level ) ;
12+ for ( var h = 0 ; h < headers . length ; h ++ ) {
13+ var header = headers [ h ] ;
14+
15+ if ( typeof header . id !== "undefined" && header . id !== "" ) {
16+ header . appendChild ( anchorForId ( header . id ) ) ;
17+ }
18+ }
19+ } ;
20+
21+ document . onreadystatechange = function ( ) {
22+ if ( this . readyState === "complete" ) {
23+ var contentBlock = document . getElementsByClassName ( "page__content" ) [ 0 ] ;
24+ if ( ! contentBlock ) {
25+ return ;
26+ }
27+ for ( var level = 1 ; level <= 6 ; level ++ ) {
28+ linkifyAnchors ( level , contentBlock ) ;
29+ }
30+ }
31+ } ;
You can’t perform that action at this time.
0 commit comments