1313bd9779
Having the CSS and JS in the html template produces pages larger than necessary, as each page need to contain all the js/css. Separating them in appropriate files allow the browser to just download them once and use them for all the pages. This is even more effective with an aggressive cache policy for the js and css, something that can be done without fear thanks to the implemented cache-busting. Also, having then in separate files allows us to use Hugo pipelines for minimizing the code.
26 lines
799 B
HTML
26 lines
799 B
HTML
<script src="https://cdn.jsdelivr.net/npm/d3@6"></script>
|
|
<h3>Interactive Graph</h3>
|
|
<div id="graph-container"></div>
|
|
<style>
|
|
:root {
|
|
--g-node: var(--secondary);
|
|
--g-node-active: var(--primary);
|
|
--g-node-inactive: var(--visited);
|
|
--g-link: var(--outlinegray);
|
|
--g-link-active: #5a7282;
|
|
}
|
|
</style>
|
|
{{ $js := resources.Get "js/graph.js" | resources.Fingerprint "md5" }}
|
|
<script src="{{ $js.Permalink }}"></script>
|
|
<script>
|
|
drawGraph(
|
|
{{strings.TrimRight "/" .Page.Permalink}},
|
|
{{strings.TrimRight "/" .Site.BaseURL}},
|
|
{{$.Site.Data.graphConfig.paths}},
|
|
{{$.Site.Data.graphConfig.depth}},
|
|
{{$.Site.Data.graphConfig.enableDrag}},
|
|
{{$.Site.Data.graphConfig.enableLegend}},
|
|
{{$.Site.Data.graphConfig.enableZoom}}
|
|
)
|
|
</script>
|