Skip to content

Commit 08dc4e8

Browse files
Update image and grid shortcodes (#520)
1 parent 497ee4b commit 08dc4e8

5 files changed

Lines changed: 37 additions & 25 deletions

File tree

assets/theme-css/styles.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ body {
88
box-sizing: border-box;
99
}
1010

11+
.text-center {
12+
text-align: center !important;
13+
}
14+
15+
img {
16+
max-width: 100%;
17+
}
18+
1119
img.align-left,
1220
figure.align-left,
1321
.figure.align-left,
@@ -41,7 +49,6 @@ figure.align-default,
4149
display: block;
4250
margin-left: auto;
4351
margin-right: auto;
44-
max-width: 100%;
4552
text-align: center;
4653
}
4754

doc/content/about/theme-team.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[[item]]
22
type = 'card'
3+
classcard = 'text-center'
34
header = 'Adam Porter'
45
body = '''{{< image >}}
56
src = 'https://avatars.githubusercontent.com/u/601365?v=4"'
@@ -9,6 +10,7 @@ link = 'https://github.com/alphapapa'
910

1011
[[item]]
1112
type = 'card'
13+
classcard = 'text-center'
1214
header = 'Brian Hawthorne'
1315
body = '''{{< image >}}
1416
src = 'https://avatars.githubusercontent.com/u/352264?u=1fd523aa28b0451454989400579d97a8c1bc1b9a&v=4"'
@@ -18,6 +20,7 @@ link = 'https://github.com/brianhawthorne'
1820

1921
[[item]]
2022
type = 'card'
23+
classcard = 'text-center'
2124
header = 'Jarrod Millman'
2225
body = '''{{< image >}}
2326
src = 'https://avatars.githubusercontent.com/u/123428?v=4"'
@@ -27,6 +30,7 @@ link = 'https://github.com/jarrodmillman'
2730

2831
[[item]]
2932
type = 'card'
33+
classcard = 'text-center'
3034
header = 'Stefan van der Walt'
3135
body = '''{{< image >}}
3236
src = 'https://avatars.githubusercontent.com/u/45071?u=c779b5e06448fbc638bc987cdfe305c7f9a7175e&v=4"'
@@ -36,6 +40,7 @@ link = 'https://github.com/stefanv'
3640

3741
[[item]]
3842
type = 'card'
43+
classcard = 'text-center'
3944
header = 'Pamphile Roy'
4045
body = '''{{< image >}}
4146
src = 'https://avatars.githubusercontent.com/u/23188539?u=64445b52dbf3f75de8006ed4264fdd2afaed97a3&v=4"'

layouts/shortcodes/grid1.html

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,27 @@
7070
body = '''{{< image >}}
7171
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
7272
alt = 'Cute puppies'
73-
align = 'center'
7473
{{< /image >}}'''
7574

7675
[[item]]
7776
type = 'card'
78-
header = 'A clickable figure card'
77+
classcard = 'text-center'
7978
link = 'https://example.com'
80-
body = '''{{< figure
81-
src="https://source.unsplash.com/200x200/daily?cute+puppy"
82-
alt="Cute puppies"
83-
>}}'''
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'''
8485

8586
[[item]]
8687
type = 'card'
8788
link = 'https://example.com'
88-
body = '''{{< figure
89-
src="https://source.unsplash.com/200x200/daily?cute+puppy"
90-
alt="Cute puppies"
91-
caption="Cute puppies"
92-
>}}'''
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'
9394

9495
{{< /grid1 >}}
9596

@@ -123,10 +124,12 @@
123124
{{- range $key, $d := $items -}}
124125
{{ if eq $d.type "card" }}
125126
<div class="sd-col sd-d-flex-row">
127+
{{ $class := "" }}
128+
{{- with $d.classcard }}{{ $class = . }}{{- end }}
126129
{{- with $d.link }}
127-
<div class="sd-card sd-w-100 sd-shadow-sm sd-card-hover">
130+
<div class="sd-card sd-w-100 sd-shadow-sm sd-card-hover {{ $class }}">
128131
{{- else }}
129-
<div class="sd-card sd-w-100 sd-shadow-sm">
132+
<div class="sd-card sd-w-100 sd-shadow-sm {{ $class }}">
130133
{{- end }}
131134
{{- with $d.header }}
132135
<div class="sd-card-header">

layouts/shortcodes/image.html

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
{{< image >}}
66
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
7-
alt = 'Cute puppies laying in the door of a tiny plastic house'
7+
alt = 'Cute puppies'
88
{{< /image >}}
99

1010
A clickable image:
1111

1212
{{< image >}}
1313
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
14-
alt = 'Cute puppies laying in the door of a tiny plastic house'
14+
alt = 'Cute puppies'
1515
target = 'https://unsplash.com/'
1616
height = 200
1717
width = 200
@@ -21,7 +21,7 @@
2121

2222
{{< image >}}
2323
src = 'https://source.unsplash.com/200x200/daily?cute+puppy'
24-
alt = 'Cute puppies laying in the door of a tiny plastic house'
24+
alt = 'Cute puppies'
2525
align = 'right'
2626
height = 200
2727
width = 200
@@ -31,17 +31,13 @@
3131

3232
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
3333

34-
{{< admonition note >}}
35-
For more options, see Hugo embedded [figure shortcode](https://gohugo.io/content-management/shortcodes/#figure).
36-
{{< /admonition >}}
37-
3834
*/}}
3935

4036
{{- $data := .Inner | transform.Unmarshal -}}
4137
{{- if $data.target -}}<a href="{{ $data.target }}">{{- end -}}
4238
<img src="{{ $data.src }}" alt="{{ $data.alt }}"
43-
{{- with $data.align }} class="align-{{ . }}"{{ end -}}
44-
{{- with $data.width }} width="{{ . }}"{{ end -}}
45-
{{- with $data.height }} height="{{ . }}"{{ end -}}
46-
><!-- Closing img tag -->
39+
{{- with $data.align }} class="align-{{ . }}"{{ end -}}
40+
{{- with $data.width }} width="{{ . }}"{{ end -}}
41+
{{- with $data.height }} height="{{ . }}"{{ end -}}
42+
>
4743
{{- if $data.target }}</a>{{ end -}}

tools/team_query.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def api(query):
6565
"""\
6666
[[item]]
6767
type = 'card'
68+
classcard = 'text-center'
6869
header = '${name}'
6970
body = '''{{< image >}}
7071
src = '${avatarUrl}"'

0 commit comments

Comments
 (0)