diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-09-14 13:56:58 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-09-14 13:56:58 +0300 |
commit | 02e7340b7b2e503fbffb9fffc9c67f8269c7dbc0 (patch) | |
tree | a5004976c22c77345a4f43ba11c53522402eb28f | |
parent | 4da8870bdd6a16c819f7c1a41a82e6c50d9ddfb4 (diff) |
Add turboturbo
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | turbo/README.md | 24 | ||||
-rw-r--r-- | turbo/config.toml | 12 | ||||
-rw-r--r-- | turbo/go.mod | 4 | ||||
-rw-r--r-- | turbo/go.sum | 2 | ||||
-rw-r--r-- | turbo/layouts/partials/jslibs/turbo/script-src.html | 7 |
6 files changed, 51 insertions, 1 deletions
@@ -1 +1,2 @@ -**/resources
\ No newline at end of file +**/resources +public/
\ No newline at end of file diff --git a/turbo/README.md b/turbo/README.md new file mode 100644 index 0000000..7d75e07 --- /dev/null +++ b/turbo/README.md @@ -0,0 +1,24 @@ +## Description + +This module wraps [Turbo](https://github.com/hotwired/turbo). + +## Installation + +First, add the module import to your site or theme component's configuration's module section: + +```toml +[module] +[[imports]] +path = "github.com/gohugoio/hugo-mod-jslibs/turbo" +``` + +Then add the script source in the head section of your template (typically in the `baseof.html`): + + +```html +<head> +{{ partialCached "jslibs/turbo/script-src.html" "-" }} +</head> +``` + +Note that the target `src` folder gets mounted to `assets/jslibs/turbo`.
\ No newline at end of file diff --git a/turbo/config.toml b/turbo/config.toml new file mode 100644 index 0000000..0a905e3 --- /dev/null +++ b/turbo/config.toml @@ -0,0 +1,12 @@ +[module] +[[module.mounts]] +source = "layouts" +target = "layouts" +[[module.mounts]] +source = "assets" +target = "assets" +[[module.imports]] +path = "https://github.com/hotwired/turbo" +[[module.imports.mounts]] +source = "src" +target = "assets/jslibs/turbo" diff --git a/turbo/go.mod b/turbo/go.mod new file mode 100644 index 0000000..1f09782 --- /dev/null +++ b/turbo/go.mod @@ -0,0 +1,4 @@ +module github.com/gohugoio/hugo-mod-jslibs/turbo + +go 1.17 + diff --git a/turbo/go.sum b/turbo/go.sum new file mode 100644 index 0000000..db76be6 --- /dev/null +++ b/turbo/go.sum @@ -0,0 +1,2 @@ +github.com/turbolinks/turbolinks-source-gem v5.2.0+incompatible h1:UNx8t3fYB51UyUv3gOXpTPT7Q6u9LCdcXQd2iW1EClA= +github.com/turbolinks/turbolinks-source-gem v5.2.0+incompatible/go.mod h1:Cl0Br9tUXkQvxumVNGTvyaa7dqpFC2kPMrsS0Ttc94U= diff --git a/turbo/layouts/partials/jslibs/turbo/script-src.html b/turbo/layouts/partials/jslibs/turbo/script-src.html new file mode 100644 index 0000000..614353e --- /dev/null +++ b/turbo/layouts/partials/jslibs/turbo/script-src.html @@ -0,0 +1,7 @@ +{{ $sourceMap := cond hugo.IsProduction "" "inline" }} +{{ $opts := dict "sourceMap" $sourceMap "minify" hugo.IsProduction "target" "es2016" "params" $params }} +{{- $js := resources.Get "jslibs/turbo/index.ts" | js.Build $opts -}} +{{- if hugo.IsProduction }} + {{ $js = $js | fingerprint }} +{{ end -}} +<script src="{{ $js.RelPermalink }}" {{ if $isProd }} integrity="{{ $js.Data.Integrity }}" {{ end }} defer></script>
\ No newline at end of file |