Skip to content

Commit 10a60d9

Browse files
committed
Chore: Merge branch 'content-re-grid' into 'add-card-example'
2 parents 5a52a5f + 54712a3 commit 10a60d9

File tree

8 files changed

+188
-150
lines changed

8 files changed

+188
-150
lines changed

assets/css/v2/style.css

Lines changed: 144 additions & 120 deletions
Large diffs are not rendered by default.

exampleSite/content/_index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Example Site for NGINX Hugo Theme
3+
description:
4+
---
5+
6+
## NGINX Hugo Theme Documentation
7+
Documentation for hugo theme
8+
{{<card-layout>}}
9+
{{<card-section showAsCards="true">}}
10+
{{<card title="Test Product" titleUrl="/test-product/" icon="test-tubes" isLanding="true">}}
11+
See explanations and usages of shortcodes
12+
{{</card >}}
13+
{{<card title="NGINX Plus" titleUrl="/nginx/" brandIcon="NGINX-Plus-product-icon-RGB" isLanding="true">}}
14+
See a live example of theme components
15+
{{</card >}}
16+
{{</card-section>}}
17+
{{</card-layout>}}
18+

exampleSite/layouts/index.html

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
11
{{ define "main" }}
2-
3-
<h1>Homepage Example</h1>
4-
<p>
5-
<ul>
6-
<li>
7-
<a href="{{ relref . "nginx" }}">NGINX and NGINX Plus</a>
8-
</li>
9-
<li>
10-
<a href="{{ relref . "test-product" }}">Test Product</a>
11-
</li>
12-
</ul>
13-
</p>
14-
15-
2+
{{ partial "homepage.html" . }}
163
{{end}}

layouts/_default/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<main class="content " role="main">
44
<div data-cms-edit="content" class="text-content list-page">
5-
<div class="breadcrumb-layout wide">
5+
<div class="breadcrumb-layout">
66
{{ if not .IsHome }}
77
{{ if not (in .Params.display_breadcrumb "false" ) }}
88
{{ partial "breadcrumb" .}}

layouts/_default/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- Replace icons -->
44
{{ $content := partial "icon-replacement.html" (dict "content" .Content) }}
55

6-
<div class="breadcrumb-layout wide">
6+
<div class="breadcrumb-layout">
77
{{ if not .IsHome }}
88
{{ if not (in .Params.display_breadcrumb "false" ) }}
99
{{ partial "breadcrumb" .}}

layouts/partials/homepage.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="homepage">
2+
<div class="homepage-section">
3+
{{ .Content }}
4+
</div>
5+
</div>

layouts/shortcodes/card-section.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div class="card-section {{if eq $isFeaturedSection "true"}}featured-section{{ end }}" data-testid="{{if eq $isFeaturedSection "true"}}card-section__featured-section{{else}}card-section{{ end }}">
2626
{{- if $title -}}
2727
<strong class="card-section-title">{{- $title -}}</strong>
28-
<div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }}{{ end }}" data-testid="{{ if eq $showAsCards "true" }}card-section-content__card-grid{{else}}card-section-content{{ end }}">{{- .Inner -}}</div>
28+
<div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }}{{ end }}" data-testid="{{ if eq $showAsCards "true" }}card-section-content__card-grid{{else}}card-section-content{{ end }}">{{ .Inner }}</div>
2929
{{ else }}
3030
<div class="card-section-content{{ if eq $showAsCards "true" }} {{ $class }}{{ end }}" data-testid="{{ if eq $showAsCards "true" }}card-section-content__card-grid{{else}}card-section-content{{ end }}">{{ .Inner }}</div>
3131
{{ end }}

layouts/shortcodes/card.html

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{{- $title := .Get "title" -}}
2-
{{- $titleUrl := .Get "titleUrl" | default "/" -}}
2+
{{- $titleUrl := .Get "titleUrl" | default "." -}}
33
{{- $icon := .Get "icon" | default "book-open" -}}
44
{{- $brandIcon := .Get "brandIcon" -}}
5-
{{- $isFeaturedParam := .Get "isFeaturedCard" | default "false" }}
5+
{{- $isFeaturedParam := .Get "isFeatured" | default "false" }}
66
{{- $isFullSizeParam := .Get "isFullSize" | default "false" -}}
7+
{{- $isLandingParam := .Get "isLanding" | default "false" }}
78

89
{{- /* Validate the parameter strictly */ -}}
910
{{- if not (in (slice "true" "false") $isFeaturedParam) -}}
@@ -16,37 +17,40 @@
1617
{{- end -}}
1718
{{- $isFullSize := cond (eq $isFullSizeParam "true") "true" "false" -}}
1819

20+
{{- if not (in (slice "true" "false") $isLandingParam) -}}
21+
{{- warnf "The '<card>' Shortcode parameter 'isLanding' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $isLandingParam -}}
22+
{{- end -}}
23+
{{- $isLanding := cond (eq $isLandingParam "true") "true" "false" -}}
24+
1925
{{- /* Set up the positioning */ -}}
2026
{{ $dataGrid := "" }}
2127
{{ if or (eq $isFullSize "true") (eq $isFeatured "true") }}
2228
{{ $dataGrid = "wide"}}
29+
{{ else if (eq $isLanding "true") }}
30+
{{ $dataGrid = "third"}}
2331
{{ else }}
2432
{{ $dataGrid = "half"}}
2533
{{ end }}
2634

2735
{{- /* Validate that the parent is card-section and under 3 cards */ -}}
2836
{{- if (eq .Parent.Name "card-section") -}}
29-
<div class="card{{ if eq $isFeatured "true" }} featured-card{{ end }}" data-grid="{{ $dataGrid }}" data-testid="{{ if eq $isFeatured "true" }}card__featured-card{{else}}card{{ end }}">
37+
<a href="{{- $titleUrl -}}" alt="{{- $title -}}" class="card{{ if eq $isFeatured "true" }} featured-card{{ end }}" data-grid="{{ $dataGrid }}" data-testid="{{ if eq $isFeatured "true" }}card__featured-card{{else}}card{{ end }}">
38+
<div class="card-container">
3039
{{- if $title -}}
3140
<div class="card-header">
3241
{{- if $brandIcon -}}
3342
<img class="card-brand-icon" src="/images/icons/{{ $brandIcon }}.svg">
34-
{{- else -}}
35-
{{- if $icon -}}
36-
{{ partial "lucide" (dict "context" . "icon" $icon) }}
37-
{{- end -}}
38-
{{- end -}}
39-
{{- if $titleUrl -}}
40-
<h2 class="card-title"><a href="{{- $titleUrl -}}">{{- $title -}}</a></h2>
41-
{{- else -}}
42-
<h2 class="card-title">{{- $title -}}</h2>
43+
{{- else if $icon -}}
44+
{{ partial "lucide" (dict "context" . "icon" $icon) }}
4345
{{- end -}}
46+
<h2 class="card-title">{{- $title -}}</h2>
4447
</div>
4548
{{- else -}}
4649
{{ errorf "Mainframe: Missing param 'title'" }}
4750
{{- end -}}
48-
{{ .Inner }}
51+
<div class="card-content">{{ .Inner }}</div>
4952
</div>
53+
</a>
5054
{{- else -}}
5155
{{ errorf "The '<card>' must be nested directly inside the shortcode '<card-section>'. Please see the exampleSite for an example of usage." }}
5256
{{- end -}}

0 commit comments

Comments
 (0)