Welcome to mirror list, hosted at ThFree Co, Russian Federation.

d3.html « shortcodes « layouts - github.com/zzossig/hugo-theme-zzo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e18d69078d148d57f99845b499538685e95c364e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{{ $scriptPath := (.Get "script") }}
{{ $stylePath := (.Get "style") }}

<div class="d3-container">{{ .Inner }}</div>
<link rel="stylesheet" href="{{ $stylePath }}">

<script>
  document.addEventListener('DOMContentLoaded', function () {
    var scriptPath = JSON.parse({{ $scriptPath | jsonify }});
    var stylePath = JSON.parse({{ $stylePath | jsonify }});

    var myScript = document.createElement('script');
    myScript.setAttribute('src', scriptPath);
    myScript.setAttribute('defer', '');
    myScript.setAttribute('crossorigin', 'anonymous');
    myScript.onload = function () {
    }

    document.querySelector('.d3-container').appendChild(myScript);
  });
</script>