Skip to content

Commit bc0cc30

Browse files
authored
Merge pull request #3 from gethinode/develop
fix: change inline partials into seperate assets
2 parents 6ddda7d + 0e701d0 commit bc0cc30

File tree

2 files changed

+3
-140
lines changed

2 files changed

+3
-140
lines changed

component-library/components/faq/faq.hugo.html

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,6 @@
1212
{{/* Initialize global arguments */}}
1313
{{- $padding := partial "utilities/GetPadding.html" -}}
1414

15-
{{ define "_partials/inline/accordion-faq.html" }}
16-
{{ $id := .id }}
17-
{{ $contrast := .contrast }}
18-
{{ $class := .class }}
19-
{{ $color := .color }}
20-
{{ $items := .items }}
21-
22-
<div id="{{ $id }}" class="accordion accordion-faq {{ if $contrast }}accordion-faq-contrast text-white {{ end -}}
23-
accordion-flush{{ with $class }} {{ . }}{{ end }} col-12 col-md-6 mx-auto">
24-
{{ range $index, $item := $items }}
25-
<div class="accordion-item">
26-
{{- with $item.title -}}
27-
<div class="accordion-header m-0" id="{{ $id }}-heading-{{ $id }}">
28-
<button class="accordion-button collapsed"
29-
type="button"
30-
data-bs-toggle="collapse"
31-
data-bs-target="#{{ $id }}-item-{{ $index }}"
32-
aria-expanded="false"
33-
aria-controls="{{ $id }}-item-{{ $index }}"
34-
>
35-
{{ if $color }}<div class="text-{{ $color }}">{{ . }}</div>{{ else }}{{ . }}{{ end }}
36-
</button>
37-
</div>
38-
{{- end -}}
39-
<div id="{{ $id }}-item-{{ $index }}"
40-
class="accordion-collapse collapse"
41-
aria-labelledby="{{ $id }}-heading-{{ $index }}"
42-
data-bs-parent="#{{ $id }}"
43-
>
44-
<div class="accordion-body">{{ $item.description | page.RenderString | safeHTML }}</div>
45-
</div>
46-
</div>
47-
{{ end }}
48-
</div>
49-
{{ end }}
50-
5115
{{/* Main code */}}
5216
{{ $color := "" }}
5317
{{ if .contrast }}{{ $color = "white" }}{{ end }}
@@ -60,7 +24,7 @@
6024
{{ $class := "" }}
6125
{{ $id := printf "faq-%s" (md5 (delimit (slice . now) "-")) }}
6226

63-
{{ $raw = printf "%s%s" $raw (partial "inline/accordion-faq.html" (dict
27+
{{ $raw = printf "%s%s" $raw (partial "assets/faq.html" (dict
6428
"id" $id
6529
"contrast" .contrast
6630
"class" .class

component-library/components/testimonials/testimonials.hugo.html

Lines changed: 2 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -9,113 +9,12 @@
99
https://github.com/CloudCannon/bookshop/blob/main/guides/hugo.adoc#passing-data-to-bookshop-components
1010
*/}}
1111

12-
{{ define "_partials/inline/testimonial-carousel.html" }}
13-
{{ $carousel := .carousel }}
14-
{{ $testimonials := .testimonials }}
15-
{{ $card := .card }}
16-
{{ $padding := .padding }}
17-
{{ $colGrid := .colGrid }}
18-
{{ $iconStyle := index . "icon-style" }}
19-
20-
{{ if and $carousel (gt (len $testimonials) 1) }}
21-
{{ $id := printf "testimonial-carousel-%s" (md5 (delimit (slice . now) "-")) }}
22-
<div id="{{ $id }}" class="carousel slide">
23-
<div class="carousel-indicators">
24-
{{ range $index, $item := $testimonials }}
25-
<button type="button"
26-
data-bs-target="#{{ $id }}"
27-
data-bs-slide-to="{{ $index }}"
28-
{{ if eq $index 0 }}class="active" aria-current="true"{{ end }}
29-
aria-label="Slide 1">
30-
</button>
31-
{{ end }}
32-
</div>
33-
<div class="carousel-inner">
34-
{{ range $index, $item := $testimonials }}
35-
<div class="carousel-item{{ if eq $index 0 }} active{{ end }}">
36-
{{ $cardStyle := partial "utilities/GetBackgroundStyle" (dict "background" $card) }}
37-
{{ $cardStyle = print $cardStyle " testimonial-carousel-item" }}
38-
39-
{{ partial "assets/testimonial.html" (dict
40-
"page" page
41-
"content" $item.content
42-
"logo" $item.logo
43-
"icon" $item.icon
44-
"icon-style" $iconStyle
45-
"scale" $item.scale
46-
"contact" (cond ($item.client | not | not) $item.client.contact "")
47-
"role" (cond ($item.client | not | not) $item.client.role "")
48-
"image" (cond ($item.client | not | not) $item.client.image "")
49-
"url" (cond ($item.client | not | not) $item.client.url "")
50-
"link" $item.link
51-
"show-controls" true
52-
"padding" $padding.x
53-
"class" $cardStyle
54-
)}}
55-
</div>
56-
{{ end}}
57-
</div>
58-
<button class="carousel-control-prev" type="button" data-bs-target="#{{ $id }}" data-bs-slide="prev">
59-
{{ partial "assets/icon.html" (dict "icon" "fas chevron-left fa-2xl") }}
60-
<span class="visually-hidden">{{ T "testimonialPrevious" }}</span>
61-
</button>
62-
<button class="carousel-control-next" type="button" data-bs-target="#{{ $id }}" data-bs-slide="next">
63-
{{ partial "assets/icon.html" (dict "icon" "fas chevron-right fa-2xl") }}
64-
<span class="visually-hidden">{{ T "testimonialNext" }}</span>
65-
</button>
66-
</div>
67-
{{ else }}
68-
<div class="testimonial-grid container p-0">
69-
<div class="row {{ $colGrid }} g-3">
70-
{{ range $testimonials }}
71-
<div class="col">
72-
{{ partial "assets/testimonial.html" (dict
73-
"page" page
74-
"content" .content
75-
"logo" .logo
76-
"icon" .icon
77-
"icon-style" $iconStyle
78-
"scale" .scale
79-
"contact" (cond (.client | not | not) .client.contact "")
80-
"role" (cond (.client | not | not) .client.role "")
81-
"image" (cond (.client | not | not) .client.image "")
82-
"url" (cond (.client | not | not) .client.url "")
83-
"link" .link
84-
"padding" $padding.x
85-
"class" (partial "utilities/GetBackgroundStyle" (dict "background" $card))
86-
)}}
87-
</div>
88-
{{ end}}
89-
</div>
90-
</div>
91-
{{ end }}
92-
{{ end }}
93-
94-
{{/* Initialize global arguments */}}
95-
{{- $style := partial "utilities/GetBackgroundStyle" (dict "background" .background) -}}
96-
{{- $breakpoint := partial "utilities/GetBreakpoint.html" -}}
97-
{{- $padding := partial "utilities/GetPadding.html" -}}
98-
9912
{{/* Main code */}}
100-
{{ $colGrid := printf "row-cols-%d" (.cols | default 1) }}
101-
{{- if eq .cols 1 }}
102-
{{ $colGrid = "row-cols-1" -}}
103-
{{- else if eq .cols 2 }}
104-
{{ $colGrid = printf "row-cols-1 row-cols-%s-2" $breakpoint.next }}
105-
{{- else if eq .cols 3 }}
106-
{{ $colGrid = printf "row-cols-1 row-cols-%s-3" $breakpoint.next }}
107-
{{- else if eq .cols 4 }}
108-
{{ $colGrid = printf "row-cols-1 row-cols-%s-2 row-cols-%s-4" $breakpoint.current $breakpoint.next }}
109-
{{- else if eq .cols 5 }}
110-
{{ $colGrid = printf "row-cols-1 row-cols-%s-3 row-cols-%s-5" $breakpoint.current $breakpoint.next }}
111-
{{ end -}}
112-
113-
{{ $raw := partial "inline/testimonial-carousel.html" (dict
13+
{{ $raw := partial "assets/testimonial-carousel.html" (dict
11414
"carousel" .carousel
11515
"testimonials" .testimonials
11616
"card" .card
117-
"padding" .padding
118-
"colGrid" $colGrid
17+
"cols" .cols
11918
"icon-style" (or .icon_style (index . "icon-style"))
12019
) }}
12120

0 commit comments

Comments
 (0)