diff options
author | Bing-Sheng Chen <gundamew@gmail.com> | 2019-08-01 09:47:14 +0300 |
---|---|---|
committer | Bing-Sheng Chen <gundamew@gmail.com> | 2019-08-01 09:47:14 +0300 |
commit | 9341e736fc758699a3f232806817f0dd74a6b2aa (patch) | |
tree | 63451016bd96aa71b40e641e5e7ca13f5102739a | |
parent | 94449ca9fa5e1c659c5d1009bf2e2316cb5df284 (diff) |
refactor(partial): Create a partial of JavaScript
Create JavaScript partial and make it cacheable.
See also: https://github.com/google/docsy/blob/master/layouts/_default/baseof.html
-rw-r--r-- | layouts/_default/baseof.html | 1 | ||||
-rw-r--r-- | layouts/partials/footer.html | 3 | ||||
-rw-r--r-- | layouts/partials/scripts.html | 3 |
3 files changed, 4 insertions, 3 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 696b038..175311c 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -7,6 +7,7 @@ {{- block "main" . }}{{- end }} </div> {{- partial "footer.html" . -}} + {{- partialCached "scripts.html" . -}} {{- template "_internal/google_analytics.html" . -}} </body> </html> diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index f6635c5..dfb7fc0 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -2,6 +2,3 @@ {{ partial "lang-selector.html" . }} <span class="footer-text">Powered by <a href="https://gohugo.io/" target="_blank">Hugo</a></span> </footer> -{{ $highlight := resources.Get "js/highlight.pack.js" | fingerprint }} -<script src="{{ $highlight.Permalink }}" integrity="{{ $highlight.Data.Integrity }}"></script> -<script>hljs.initHighlightingOnLoad();</script> diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html new file mode 100644 index 0000000..f7384a0 --- /dev/null +++ b/layouts/partials/scripts.html @@ -0,0 +1,3 @@ +{{ $highlight := resources.Get "js/highlight.pack.js" | fingerprint }} +<script src="{{ $highlight.Permalink }}" integrity="{{ $highlight.Data.Integrity }}"></script> +<script>hljs.initHighlightingOnLoad();</script> |