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

github.com/gohugoio/hugo-mod-jslibs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-10-06 18:10:18 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-10-06 18:42:15 +0300
commit97cb50aae023f7112daff0b025b9ef3b29e7dfc5 (patch)
tree77ce6abed4688ede727e470332c7fdfdc768da12
parent4da8870bdd6a16c819f7c1a41a82e6c50d9ddfb4 (diff)
Add Turbo
-rw-r--r--turbo/README.md24
-rw-r--r--turbo/config.toml12
-rw-r--r--turbo/go.mod5
-rw-r--r--turbo/go.sum4
-rw-r--r--turbo/layouts/partials/jslibs/turbo/script-src.html7
5 files changed, 52 insertions, 0 deletions
diff --git a/turbo/README.md b/turbo/README.md
new file mode 100644
index 0000000..c7c6ded
--- /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/v7"
+```
+
+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/v7`. \ No newline at end of file
diff --git a/turbo/config.toml b/turbo/config.toml
new file mode 100644
index 0000000..b4afb90
--- /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 = "github.com/hotwired/turbo"
+[[module.imports.mounts]]
+source = "src"
+target = "assets/jslibs/turbo/v7"
diff --git a/turbo/go.mod b/turbo/go.mod
new file mode 100644
index 0000000..89cb2fa
--- /dev/null
+++ b/turbo/go.mod
@@ -0,0 +1,5 @@
+module github.com/gohugoio/hugo-mod-jslibs/turbo/v7
+
+go 1.17
+
+require github.com/hotwired/turbo v7.0.1+incompatible // indirect
diff --git a/turbo/go.sum b/turbo/go.sum
new file mode 100644
index 0000000..8e31738
--- /dev/null
+++ b/turbo/go.sum
@@ -0,0 +1,4 @@
+github.com/hotwired/turbo v7.0.1+incompatible h1:DvY56vNgcvH0vkw4VqlAc/hfsTeMdcoOKTGgnoGH6ok=
+github.com/hotwired/turbo v7.0.1+incompatible/go.mod h1:6XcpYEC+j8xb7URpSYwhlq4iq98M5F5T/jaLWNHVbZs=
+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..a4d0639
--- /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" }}
+{{- $js := resources.Get "jslibs/turbo/v7/index.ts" | js.Build $opts -}}
+{{- if hugo.IsProduction }}
+ {{ $js = $js | fingerprint }}
+{{ end -}}
+<script src="{{ $js.RelPermalink }}" {{ if hugo.IsProduction }} integrity="{{ $js.Data.Integrity }}" {{ end }} defer></script> \ No newline at end of file