mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
76f809794f
- Simplify `resources.Get` calls to string paths in script pipeline callers (plugin/script.html handles resources.Get internally) - Refactor js-build.html to use $defaultOptions merge pattern matching style.html's ToCSS handling for better readability - Refactor style.html ToCSS with $defaultOptions merge pattern and automatic targetPath generation from resource name - Remove redundant custom $options dicts for targetPath that match the new default behavior - Update partial docs for script.html and style.html
29 lines
996 B
HTML
29 lines
996 B
HTML
{{- /*
|
|
Build and minify a JS resource with unified behavior.
|
|
@param {resource.Resource} .Resource Hugo resource to process
|
|
@param {Object|Boolean} [.Build] true for defaults, dict for custom options, false/omit to skip js.Build
|
|
@param {Boolean} [.Minify] extra minify flag; final minify is Minify OR Build.minify
|
|
@return {resource.Resource}
|
|
*/ -}}
|
|
|
|
{{- $resource := .Resource -}}
|
|
{{- $minify := .Minify -}}
|
|
{{- with .Build -}}
|
|
{{- $defaultOptions := dict
|
|
"targetPath" (replaceRE `\.(template\.)?ts$` ".js" $resource.Name)
|
|
"sourceMap" (cond hugo.IsDevelopment "linked" "none")
|
|
"minify" hugo.IsProduction
|
|
-}}
|
|
{{- $options := . -}}
|
|
{{- if eq . true -}}
|
|
{{- $options = dict -}}
|
|
{{- end -}}
|
|
{{- $options = $options | merge $defaultOptions -}}
|
|
{{- $resource = $resource | js.Build $options -}}
|
|
{{- $minify = $minify | or (index $options "minify") -}}
|
|
{{- end -}}
|
|
{{- if $minify -}}
|
|
{{- $resource = $resource | minify -}}
|
|
{{- end -}}
|
|
{{- return $resource -}}
|