Skip to content

Commit d43ac66

Browse files
authored
feat: add hextra hero-container shortcode (#389)
* Implement hextra hero-container * Fix width * Fix width * Fix width * Set number of columns * Fix display for mobile devices * Trim image prefix * Implement image card * Fix width * Fix css
1 parent 4eca719 commit d43ac66

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- $class := .Get "class" -}}
2+
{{- $cols := .Get "cols" | default 2 -}}
3+
{{- $image := .Get "image" -}}
4+
{{- $imageCard := .Get "imageCard" | default false -}}
5+
{{- $imageClass := .Get "imageClass" -}}
6+
{{- $imageLink := .Get "imageLink" -}}
7+
{{- $imageLinkExternal := hasPrefix $imageLink "http" -}}
8+
{{- $imageStyle := .Get "imageStyle" -}}
9+
{{- $imageTitle := .Get "imageTitle" -}}
10+
{{- $imageWidth := .Get "imageWidth" | default 350 -}}
11+
{{- $imageHeight := .Get "imageHeight" | default 350 -}}
12+
{{- $style := .Get "style" -}}
13+
14+
{{- $css := printf "--hextra-feature-grid-cols: %v; %s" $cols $style -}}
15+
{{- $href := cond (hasPrefix $imageLink "/") ($imageLink | relURL) $imageLink -}}
16+
{{- if hasPrefix $image "/" -}}
17+
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
18+
{{- end -}}
19+
20+
<div
21+
class="{{ $class }} hextra-feature-grid hx-grid sm:max-lg:hx-grid-cols-2 max-sm:hx-grid-cols-1 hx-gap-4 hx-w-full not-prose"
22+
{{ with $css }}style="{{ . | safeCSS }}"{{ end }}
23+
>
24+
<div class="hx-w-full">
25+
{{ .Inner }}
26+
</div>
27+
{{- with $image }}
28+
<div class="hx-mx-auto">
29+
<a
30+
{{ with $imageLink }}href="{{ $href }}" {{ with $imageLinkExternal }} target="_blank" rel="noreferrer"{{ end }}{{ end }}
31+
{{ with $imageStyle }}style="{{ . | safeCSS }}"{{ end }}
32+
class="{{ $imageClass }} {{ if $imageCard }}hextra-feature-card not-prose hx-block hx-relative hx-p-6 hx-overflow-hidden hx-rounded-3xl hx-border hx-border-gray-200 hover:hx-border-gray-300 dark:hx-border-neutral-800 dark:hover:hx-border-neutral-700 before:hx-pointer-events-none before:hx-absolute before:hx-inset-0 before:hx-bg-glass-gradient{{ end }}"
33+
>
34+
<img src="{{ $image }}" width="{{ $imageWidth }}" height="{{ $imageHeight }}" {{ with $imageTitle }}alt="{{ $imageTitle }}"{{ end }}/>
35+
</a>
36+
</div>
37+
{{ end -}}
38+
</div>

0 commit comments

Comments
 (0)