commit 5a365c2607655acb416397319c5c362e1bbb4f15 from: Anton Kasimov date: Fri Aug 21 14:00:50 2026 UTC Упрощение shortcode после реализации pick commit - 1560af799348ecbf7e9e8d27838254dd3df43fbc commit + 5a365c2607655acb416397319c5c362e1bbb4f15 blob - 3ba203f999fae7f8dffd8690bd5c2cbbabe9a00f blob + 0c2c104a94a01d3ca17d2ad2e9742783997e256b --- layouts/_shortcodes/source.html +++ layouts/_shortcodes/source.html @@ -11,29 +11,20 @@ {{- end -}} {{- end -}} -{{- $codecs := .Get "codecs" -}} -{{- if and $type $codecs -}} - {{- $type = printf "%s; codecs=%s" $type $codecs -}} -{{- end -}} - -{{- $allowed := slice - "srcset" - "sizes" - "media" - "width" - "height" --}} - -{{- $attributes := dict "src" $src -}} - -{{- range $name, $value := .Params -}} - {{- if in $allowed $name -}} - {{- $attributes = merge $attributes (dict $name $value) -}} +{{- with .Get "codecs" -}} + {{- if $type -}} + {{- $type = printf "%s; codecs=%s" $type . -}} {{- end -}} {{- end -}} -{{- with $type -}} - {{- $attributes = merge $attributes (dict "type" .) -}} -{{- end -}} +{{- $attributes := partial "pick.html" (dict + "dict" .Params + "allowed" (slice "srcset" "sizes" "media" "width" "height") +) -}} +{{- $attributes = merge $attributes (dict + "src" $src + "type" $type +) -}} + blob - 88fa63e3feb9a9939d2cd375aa2361ce9fe57e08 blob + 6a15da496d704cb08b9e79ddb78e1f1d7e8ab7a6 --- layouts/_shortcodes/video.html +++ layouts/_shortcodes/video.html @@ -15,7 +15,7 @@ "controls" -}} -{{- $attributes := dict +{{- $defaults := dict "autoplay" true "loop" true "muted" true @@ -25,12 +25,13 @@ "controls" false -}} -{{- range $name, $value := .Params -}} - {{- if in $allowed $name -}} - {{- $attributes = merge $attributes (dict $name $value) -}} - {{- end -}} -{{- end -}} +{{- $attributes := partial "pick.html" (dict + "dict" .Params + "allowed" $allowed +) -}} +{{- $attributes = merge $defaults $attributes -}} + {{ .Inner }}