content: Update transformation examples

This commit is contained in:
Joe Mooring
2025-04-25 20:58:17 -07:00
committed by GitHub
parent 3327065ab1
commit 1a5191d78d
3 changed files with 15 additions and 15 deletions
+5 -5
View File
@@ -66,20 +66,20 @@ vars
```go-html-template {copy=true}
{{ with resources.Get "sass/main.scss" }}
{{ $opts := dict
"enableSourceMap" (not hugo.IsProduction)
"outputStyle" (cond hugo.IsProduction "compressed" "expanded")
"enableSourceMap" hugo.IsDevelopment
"outputStyle" (cond hugo.IsDevelopment "expanded" "compressed")
"targetPath" "css/main.css"
"transpiler" "dartsass"
"vars" site.Params.styles
"includePaths" (slice "node_modules/bootstrap/scss")
}}
{{ with . | toCSS $opts }}
{{ if hugo.IsProduction }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ else }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ end }}
{{ end }}
{{ end }}
+4 -4
View File
@@ -76,16 +76,16 @@ Create a partial template to process the CSS with the Tailwind CSS CLI:
{{ with (templates.Defer (dict "key" "global")) }}
{{ with resources.Get "css/main.css" }}
{{ $opts := dict
"minify" hugo.IsProduction
"minify" (not hugo.IsDevelopment)
"inlineImports" true
}}
{{ with . | css.TailwindCSS $opts }}
{{ if hugo.IsProduction }}
{{ if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ else }}
{{ with . | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
{{ else }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{ end }}
{{ end }}
{{ end }}
+6 -6
View File
@@ -20,18 +20,18 @@ The `js.Build` function uses the [evanw/esbuild] package to:
```go-html-template
{{ with resources.Get "js/main.js" }}
{{ $opts := dict
"minify" hugo.IsProduction
"sourceMap" (cond hugo.IsProduction "" "external")
{{$opts := dict
"minify" (not hugo.IsDevelopment)
"sourceMap" (cond hugo.IsDevelopment "external" "")
"targetPath" "js/main.js"
}}
{{ with . | js.Build $opts }}
{{ if hugo.IsProduction }}
{{ if hugo.IsDevelopment }}
<script src="{{ .RelPermalink }}"></script>
{{ else }}
{{ with . | fingerprint }}
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{ end }}
{{ else }}
<script src="{{ .RelPermalink }}"></script>
{{ end }}
{{ end }}
{{ end }}