Skip to content

Commit eecf1d2

Browse files
Replace grid with grid1 shortcode (#543)
1 parent 53d5ceb commit eecf1d2

File tree

2 files changed

+107
-110
lines changed

2 files changed

+107
-110
lines changed

layouts/shortcodes/grid.html

Lines changed: 107 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,109 @@
1-
<div class="sd-container-fluid sd-mb-4">
2-
{{- with .Get "columns" -}}
3-
{{ $columns := split . " " }}
4-
{{ $xs := index $columns 0 }}
5-
{{ $sm := index $columns 1 }}
6-
{{ $md := index $columns 2 }}
7-
{{ $lg := index $columns 3 }}
8-
<div class="sd-row sd-row-cols-1 sd-row-cols-xs-{{ $xs }} sd-row-cols-sm-{{ $sm }} sd-row-cols-md-{{ $md }} sd-row-cols-lg-{{ $lg }} sd-g-2 sd-g-xs-{{ $xs }} sd-g-sm-{{ $sm }} sd-g-md-{{ $md }} sd-g-lg-{{ $lg }}">
1+
{{/*
2+
3+
doc: Grids.
4+
5+
{{< grid1 columns="1 2 3 4" outline="true" >}}
6+
7+
[[item]]
8+
type = ''
9+
body = 'A'
10+
11+
[[item]]
12+
type = ''
13+
body = 'B'
14+
15+
[[item]]
16+
type = ''
17+
body = 'C'
18+
19+
[[item]]
20+
type = ''
21+
body = 'D'
22+
23+
{{< /grid1 >}}
24+
25+
{{< grid1 columns="1 2 2 4" >}}
26+
27+
[[item]]
28+
type = 'card'
29+
title = 'Only title'
30+
31+
[[item]]
32+
type = 'card'
33+
body = '''
34+
Only body.
35+
36+
But with multiple text paragraphs.
37+
'''
38+
39+
[[item]]
40+
type = 'card'
41+
title = 'Heading and body'
42+
body = '''
43+
Content of the third card.
44+
45+
{{< badge primary >}}Sample badge{{< /badge >}}
46+
'''
47+
48+
[[item]]
49+
type = 'card'
50+
title = 'A card with a dropdown menu'
51+
body = '''
52+
{{< dropdown >}}
53+
title = 'Click to expand dropdown'
54+
icon = 'fa-solid fa-eye'
55+
body = 'Hidden content'
56+
{{< /dropdown >}}
57+
'''
58+
59+
[[item]]
60+
type = 'card'
61+
header = 'Header'
62+
title = 'Card Title'
63+
body = 'Card content'
64+
footer = 'Footer'
65+
66+
[[item]]
67+
type = 'card'
68+
header = 'A clickable image card'
69+
link = 'https://example.com'
70+
body = '''{{< image >}}
71+
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
72+
alt = 'Cute puppies'
73+
{{< /image >}}'''
74+
75+
[[item]]
76+
type = 'card'
77+
classcard = 'text-center'
78+
link = 'https://example.com'
79+
body = '''{{< image >}}
80+
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
81+
alt = 'Cute puppies'
82+
{{< /image >}}
83+
84+
A clickable figure card'''
85+
86+
[[item]]
87+
type = 'card'
88+
link = 'https://example.com'
89+
body = '''{{< image >}}
90+
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
91+
alt = 'Cute puppies'
92+
{{< /image >}}'''
93+
footer = 'A clickable figure card'
94+
95+
{{< /grid1 >}}
96+
97+
*/}}
98+
99+
{{- $items := "" -}}
100+
{{- with .Get "file" -}}
101+
{{- with $.Page.Resources.Get . | transform.Unmarshal }}
102+
{{- $items = (index . "item") }}
103+
{{- else }}
104+
{{- errorf "Unable to get page resource %q" . }}
105+
{{- end }}
9106
{{- else }}
10-
<div class="sd-row">
107+
{{- $items = (index (.Inner | transform.Unmarshal) "item") }}
11108
{{- end }}
12-
{{ .Inner }}
13-
</div>
14-
</div>
109+
{{- partial "_elements/grid.html" (merge .Params (dict "items" $items)) -}}

layouts/shortcodes/grid1.html

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,3 @@
1-
{{/*
2-
3-
doc: Grids.
4-
5-
{{< grid1 columns="1 2 3 4" outline="true" >}}
6-
7-
[[item]]
8-
type = ''
9-
body = 'A'
10-
11-
[[item]]
12-
type = ''
13-
body = 'B'
14-
15-
[[item]]
16-
type = ''
17-
body = 'C'
18-
19-
[[item]]
20-
type = ''
21-
body = 'D'
22-
23-
{{< /grid1 >}}
24-
25-
{{< grid1 columns="1 2 2 4" >}}
26-
27-
[[item]]
28-
type = 'card'
29-
title = 'Only title'
30-
31-
[[item]]
32-
type = 'card'
33-
body = '''
34-
Only body.
35-
36-
But with multiple text paragraphs.
37-
'''
38-
39-
[[item]]
40-
type = 'card'
41-
title = 'Heading and body'
42-
body = '''
43-
Content of the third card.
44-
45-
{{< badge primary >}}Sample badge{{< /badge >}}
46-
'''
47-
48-
[[item]]
49-
type = 'card'
50-
title = 'A card with a dropdown menu'
51-
body = '''
52-
{{< dropdown >}}
53-
title = 'Click to expand dropdown'
54-
icon = 'fa-solid fa-eye'
55-
body = 'Hidden content'
56-
{{< /dropdown >}}
57-
'''
58-
59-
[[item]]
60-
type = 'card'
61-
header = 'Header'
62-
title = 'Card Title'
63-
body = 'Card content'
64-
footer = 'Footer'
65-
66-
[[item]]
67-
type = 'card'
68-
header = 'A clickable image card'
69-
link = 'https://example.com'
70-
body = '''{{< image >}}
71-
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
72-
alt = 'Cute puppies'
73-
{{< /image >}}'''
74-
75-
[[item]]
76-
type = 'card'
77-
classcard = 'text-center'
78-
link = 'https://example.com'
79-
body = '''{{< image >}}
80-
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
81-
alt = 'Cute puppies'
82-
{{< /image >}}
83-
84-
A clickable figure card'''
85-
86-
[[item]]
87-
type = 'card'
88-
link = 'https://example.com'
89-
body = '''{{< image >}}
90-
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
91-
alt = 'Cute puppies'
92-
{{< /image >}}'''
93-
footer = 'A clickable figure card'
94-
95-
{{< /grid1 >}}
96-
97-
*/}}
98-
991
{{- $items := "" -}}
1002
{{- with .Get "file" -}}
1013
{{- with $.Page.Resources.Get . | transform.Unmarshal }}

0 commit comments

Comments
 (0)