Skip to content

Commit

Permalink
feat(container): add the bg parameter, supports site resources, page …
Browse files Browse the repository at this point in the history
…resources, internal images and external images (#123)
  • Loading branch information
razonyang committed Mar 5, 2024
1 parent 89910cf commit ff5581c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion layouts/partials/bootstrap/container.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- $breakpoint := "" }}
{{- $class := "" }}
{{- $bg := "" }}
{{- if .IsNamedParams }}
{{- $breakpoint = .Get "breakpoint" }}
{{- $class = .Get "class" }}
{{- $bg = .Get "bg" }}
{{- else }}
{{- $breakpoint = .Get 0 }}
{{- $class = .Get 1 }}
Expand All @@ -14,6 +16,23 @@
{{- $classes = $classes | append "container" }}
{{- end }}
{{- with $class }}{{ $classes = $classes | append . }}{{ end }}
<div class="{{ delimit $classes ` ` }}">
{{- $style := slice }}
{{- if ne $bg "" }}
{{- $classes = $classes | append "" }}
{{- with .Page.Resources.Get $bg }}
{{- $bg = .RelPermalink }}
{{- else }}
{{- with resources.Get $bg }}
{{- $bg = .RelPermalink }}
{{- end }}
{{- end }}
{{- $style = $style | append
(printf "background-image: url(%s)" $bg)
(printf "background-size: cover" $bg)
}}
{{- end }}
<div
class="{{ delimit $classes ` ` }}"
{{ with $style }}{{ delimit . `;` | printf `style="%s"` | safeHTMLAttr }}{{ end }}>
{{ .Inner }}
</div>

0 comments on commit ff5581c

Please sign in to comment.