1
Fork 0

Extract mermaid logic into its own JS file, and correct conditional loading

This commit is contained in:
Jake Howard 2019-10-29 18:49:42 +00:00
parent 48cae84b96
commit 60c66b5ab0
Signed by: jake
GPG key ID: 57AFB45680EDD477
6 changed files with 20 additions and 18 deletions

View file

@ -55,4 +55,3 @@ After giving your credentials twice (once for the intermediary, then again for t
SSH has many configuration options available to ease this process, such as using keys for authentication over passwords, and transparently connecting to the intermediary server when trying to connect to the server. SSH has many configuration options available to ease this process, such as using keys for authentication over passwords, and transparently connecting to the intermediary server when trying to connect to the server.
My personal tool of choice for managing config like this is [`assh`](https://github.com/moul/advanced-ssh-config). My personal tool of choice for managing config like this is [`assh`](https://github.com/moul/advanced-ssh-config).

View file

@ -28,10 +28,10 @@
{{ partial "footer.html" . }} {{ partial "footer.html" . }}
{{ $raw_content := "" }} {{ $content := "" }}
{{ if .Content }} {{ if .Content }}
{{ $raw_content = .RawContent }} {{ $content = .Content | htmlEscape }}
{{ end }} {{ end }}
{{ partial "script.html" "js/jquery.js" }} {{ partial "script.html" "js/jquery.js" }}
@ -44,7 +44,7 @@
{{ partial "script_async.html" "js/bootstrap.js" }} {{ partial "script_async.html" "js/bootstrap.js" }}
{{ if in $raw_content "{{<mermaid" }} {{ if in $content "mermaid-shortcode" }}
{{ partial "script_async.html" "js/mermaid.js" }} {{ partial "script_async.html" "js/mermaid.js" }}
{{ end }} {{ end }}

View file

@ -1,5 +1,5 @@
<figure> <figure>
<div class="mermaid" align="center"> <div class="mermaid mermaid-shortcode" align="center">
{{ safeHTML .Inner }} {{ safeHTML .Inner }}
</div> </div>
<figcaption class="text-center"> <figcaption class="text-center">

View file

@ -18,10 +18,10 @@ cp -r $BASEDIR/node_modules/@fortawesome/fontawesome-free/webfonts $STATIC_BUILD
cp $BASEDIR/node_modules/jquery/dist/jquery.min.js $STATIC_BUILD/js/jquery.js cp $BASEDIR/node_modules/jquery/dist/jquery.min.js $STATIC_BUILD/js/jquery.js
cp $BASEDIR/node_modules/lightgallery/dist/js/lightgallery-all.min.js $STATIC_BUILD/js/lightgallery.js cp $BASEDIR/node_modules/lightgallery/dist/js/lightgallery-all.min.js $STATIC_BUILD/js/lightgallery.js
cp $BASEDIR/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js $STATIC_BUILD/js/bootstrap.js cp $BASEDIR/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js $STATIC_BUILD/js/bootstrap.js
cp $BASEDIR/node_modules/mermaid/dist/mermaid.min.js $STATIC_BUILD/js/mermaid.js
browserify $STATIC_SRC/js/index.js -o $STATIC_BUILD/js/app.js browserify $STATIC_SRC/js/index.js -o $STATIC_BUILD/js/app.js
browserify $STATIC_SRC/js/sentry.js -t envify -o $STATIC_BUILD/js/sentry.js browserify $STATIC_SRC/js/sentry.js -t envify -o $STATIC_BUILD/js/sentry.js
browserify $STATIC_SRC/js/mermaid.js -o $STATIC_BUILD/js/mermaid.js
cp -r $STATIC_SRC/scss $STATIC_BUILD/scss cp -r $STATIC_SRC/scss $STATIC_BUILD/scss
hugo gen chromastyles --style=monokai > $STATIC_BUILD/css/highlight.css hugo gen chromastyles --style=monokai > $STATIC_BUILD/css/highlight.css

View file

@ -47,12 +47,6 @@ $(document).ready(function() {
); );
} }
}); });
waitFor(window, 'mermaid', function() {
mermaid.initialize({
startOnLoad: true,
});
});
}); });
$('.navbar-brand').on('click', function(event) { $('.navbar-brand').on('click', function(event) {

9
static/src/js/mermaid.js Normal file
View file

@ -0,0 +1,9 @@
'use strict';
var mermaid = require('mermaid');
$(document).ready(function() {
mermaid.initialize({
startOnLoad: true,
});
});