Skip to content

Commit

Permalink
Render heading anchors with new render hook
Browse files Browse the repository at this point in the history
This removes the old javascript code that adds heading anchor links and
replaces it with the new render-heading template. This means the markup
is generated statically and doesn't depend on javascript.
  • Loading branch information
apexskier authored and bep committed May 18, 2020
1 parent 2bfd5f8 commit 62cbad0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.header-link:after {
position: relative;
left: 0.5em;
Expand Down
4 changes: 2 additions & 2 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import '_tachyons';

/* purgecss start ignore */
@import '_anchorforid';
@import '_header-link';
@import '_animation';
@import '_documentation-styles';

Expand Down Expand Up @@ -36,4 +36,4 @@
.mw-90 {
max-width:90%;
}
/* purgecss end ignore */
/* purgecss end ignore */
4 changes: 0 additions & 4 deletions assets/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require("typeface-muli")
import styles from './css/main.css';
import './js/anchorforid.js'
import './js/clipboardjs.js'
import './js/codeblocks.js'
import './js/docsearch.js'
Expand All @@ -11,6 +10,3 @@ import './js/scrolldir.js'
import './js/smoothscroll.js'
import './js/tabs.js'
import './js/nojs.js'



34 changes: 0 additions & 34 deletions assets/js/anchorforid.js

This file was deleted.

5 changes: 1 addition & 4 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styles from './../css/main.css';
import './anchorforid.js'
import './clipboardjs.js'
import './codeblocks.js'
import './docsearch.js'
Expand All @@ -10,9 +9,7 @@ import './smoothscroll.js'
import './tabs.js'
import './nojs.js'



// TO use Jquery, just call the modules you want
// TO use jQuery, just call the modules you want
// var $ = require('jquery/src/core');
// require('jquery/src/core/init');
// require('jquery/src/manipulation');
Expand Down
1 change: 1 addition & 0 deletions assets/output/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -5280,3 +5280,4 @@ code, .code, pre code, .highlight pre {
max-width:90%;
}
/* purgecss end ignore */

9 changes: 4 additions & 5 deletions assets/output/js/app.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}
{{- if and (ge .Level 2) (le .Level 4) }}{{" " -}}
<a class="header-link" href="#{{ .Anchor | safeURL }}"><svg class="fill-current o-60 hover-accent-color-light" height="22px" viewBox="0 0 24 24" width="22px" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg></a>
{{- end -}}
</h{{ .Level }}>

0 comments on commit 62cbad0

Please sign in to comment.