Add Tab's railroad.js to the blog
- Include railroad.js from http://tabatkins.github.io/railroad-diagrams/ - Include railroad.css from the same, and tweak it to match my style a bit better - Add a railroad-utils.js file that declares a railroadDiagram function. It takes a builder function and an element ID, calls the builder and adds the resulting diagram to the element with the given ID. - Add a railroad_diagram shortcode that wraps that all up so you can write a diagram inline with a post. - Add script includes if the railroad_diagram shortcode is used. The shortcut sets a variable in the page's .Scratch that is looked up in the head partial template to determine whether to include these scripts.
This commit is contained in:
parent
4c51db76aa
commit
9ffa94f8af
5 changed files with 1484 additions and 0 deletions
9
layouts/shortcodes/railroad_diagram.html
Normal file
9
layouts/shortcodes/railroad_diagram.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{ $id := .Get "id" }}
|
||||
{{ .Page.Scratch.Set "includes_railroad_diagram" true }}
|
||||
<figure class="railroad-diagram" {{ if $id }}id="{{ $id }}"{{ end }}></figure>
|
||||
<script defer type="module">
|
||||
import { railroadDiagram } from {{ `/scripts/railroad-utils.js` | relURL }};
|
||||
railroadDiagram(rr => {
|
||||
{{ .Inner | safeJS }}
|
||||
}, "{{ $id }}");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue