Skip to content

Commit

Permalink
[BSv5] blocks/cover row/col fix (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Mar 8, 2023
1 parent 706dbf9 commit c05c214
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions assets/scss/blocks/_cover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
}

& > .byline {
@extend .small;
position: absolute;
bottom: 2px;
right: 4px;
Expand Down
74 changes: 37 additions & 37 deletions layouts/shortcodes/blocks/cover.html
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{{ $_hugo_config := `{ "version": 1 }` }}
{{ $blockID := printf "td-cover-block-%d" .Ordinal }}
{{ $promo_image := (.Page.Resources.ByType "image").GetMatch "**background*" }}
{{ $logo_image := (.Page.Resources.ByType "image").GetMatch "**logo*" }}
{{ $col_id := .Get "color" | default "dark" }}
{{ $image_anchor := .Get "image_anchor" | default "smart" }}
{{ $logo_anchor := .Get "logo_anchor" | default "smart" }}
{{/* Height can be one of: auto, min, med, max, full. */}}
{{ $height := .Get "height" | default "max" }}
{{ $byline := .Get "byline" | default "" }}
{{ with $promo_image }}
{{ $promo_image_big := (.Fill (printf "1920x1080 %s" $image_anchor)) }}
{{ $promo_image_small := (.Fill (printf "960x540 %s" $image_anchor)) }}
{{ $_hugo_config := `{ "version": 1 }` -}}
{{ $blockID := printf "td-cover-block-%d" .Ordinal -}}
{{ $promo_image := (.Page.Resources.ByType "image").GetMatch "**background*" -}}
{{ $logo_image := (.Page.Resources.ByType "image").GetMatch "**logo*" -}}
{{ $col_id := .Get "color" | default "dark" -}}
{{ $image_anchor := .Get "image_anchor" | default "smart" -}}
{{ $logo_anchor := .Get "logo_anchor" | default "smart" -}}
{{/* Height can be one of: auto, min, med, max, full. */ -}}
{{ $height := .Get "height" | default "max" -}}

{{ with $promo_image -}}
{{ $promo_image_big := (.Fill (printf "1920x1080 %s" $image_anchor)) -}}
{{ $promo_image_small := (.Fill (printf "960x540 %s" $image_anchor)) -}}
<link rel="preload" as="image" href="{{ $promo_image_small.RelPermalink }}" media="(max-width: 1200px)">
<link rel="preload" as="image" href="{{ $promo_image_big.RelPermalink }}" media="(min-width: 1200px)">
<style>
#{{ $blockID }} {
background-image: url({{ $promo_image_small.RelPermalink }});
background-image: url({{ $promo_image_small.RelPermalink }});
}
@media only screen and (min-width: 1200px) {
#{{ $blockID }} {
background-image: url({{ $promo_image_big.RelPermalink }});
}
#{{ $blockID }} {
background-image: url({{ $promo_image_big.RelPermalink }});
}
}
</style>
{{ end }}
<section id="{{ $blockID }}" class="row td-cover-block td-cover-block--height-{{ $height }}{{ if not .Site.Params.ui.navbar_translucent_over_cover_disable }} js-td-cover{{ end }} td-overlay td-overlay--dark -bg-{{ $col_id }}">
<div class="container td-overlay__inner">
<div class="row">
<div class="col-12">
<div class="text-center">
{{ with .Get "title" }}<h1 class="display-1 mt-0 mt-md-5 pb-4">{{ $title := . }}{{ with $logo_image }}{{ $logo_image_resized := (.Fit (printf "70x70 %s" $logo_anchor)) }}<img class="td-cover-logo" src="{{ $logo_image_resized.RelPermalink }}" alt="{{ $title | html }} Logo">{{ end }}{{ $title | html }}</h1>{{ end }}
{{ with .Get "subtitle" }}<p class="display-2 text-uppercase mb-0">{{ . | html }}</p>{{ end }}
<div class="pt-3 lead">
{{ if eq .Page.File.Ext "md" }}
{{ .Inner | markdownify }}
{{ else }}
{{ .Inner | htmlUnescape | safeHTML }}
{{ end }}
</div>
{{ end -}}

<section id="{{ $blockID }}" class="row td-cover-block td-cover-block--height-{{ $height -}}
{{ if not .Site.Params.ui.navbar_translucent_over_cover_disable }} js-td-cover
{{- end }} td-overlay td-overlay--dark -bg-{{ $col_id }}">
<div class="col-12 p-0">
<div class="container td-overlay__inner">
<div class="text-center">
{{ with .Get "title" }}<h1 class="display-1 mt-0 mt-md-5 pb-4">{{ $title := . }}{{ with $logo_image }}{{ $logo_image_resized := (.Fit (printf "70x70 %s" $logo_anchor)) }}<img class="td-cover-logo" src="{{ $logo_image_resized.RelPermalink }}" alt="{{ $title | html }} Logo">{{ end }}{{ $title | html }}</h1>{{ end }}
{{ with .Get "subtitle" }}<p class="display-2 text-uppercase mb-0">{{ . | html }}</p>{{ end }}
<div class="pt-3 lead">
{{ if eq .Page.File.Ext "md" }}
{{ .Inner | markdownify }}
{{ else }}
{{ .Inner | htmlUnescape | safeHTML }}
{{ end }}
</div>
</div>
</div>
</div>
{{ if $byline }}
<div class="byline">
<small>{{ $byline }}</small>
</div>
{{ end }}
{{ with .Get "byline" | default "" -}}
<div class="byline">{{ . }}</div>
{{- end }}
</section>
{{/**/ -}}
2 changes: 1 addition & 1 deletion userguide/content/en/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Docsy
---

{{< blocks/cover title="Welcome to Docsy!" image_anchor="top" height="full" color="orange" >}}
{{< blocks/cover title="Welcome to Docsy!" image_anchor="top" height="full" >}}
<div class="mx-auto">
<a class="btn btn-lg btn-primary me-3 mb-4" href="{{< relref "/about" >}}">
Learn More <i class="fa-solid fa-circle-right ms-2"></i>
Expand Down
2 changes: 1 addition & 1 deletion userguide/content/en/docs/adding-content/iconsimages.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Docsy's [`blocks/cover` shortcode](/docs/adding-content/shortcodes/#blockscover)
You specify the preferred display height of a cover block container (and hence its image) using the block's `height` parameter. For a full viewport height, use `full`:

```html
{{</* blocks/cover title="Welcome to the Docsy Example Project!" image_anchor="top" height="full" color="orange" */>}}
{{</* blocks/cover title="Welcome to the Docsy Example Project!" image_anchor="top" height="full" */>}}
...
{{</* /blocks/cover */>}}
```
Expand Down

0 comments on commit c05c214

Please sign in to comment.