Skip to content

Commit 7c5a4ab

Browse files
committed
đź“ť (layouts): update category and tag list templates for improved readability and structure
The changes enhance the readability and structure of the category and tag list templates. The section headers for "Categories" and "Tags" are now more prominent with updated heading levels, improving the visual hierarchy. The layout adjustments ensure a more consistent and user-friendly presentation of categories and tags, making it easier for users to navigate and understand the content. Additionally, the code refactoring improves maintainability and aligns with best practices for template organization.
1 parent 0793862 commit 7c5a4ab

File tree

2 files changed

+86
-62
lines changed

2 files changed

+86
-62
lines changed

‎site/layouts/categories/list.html

+84-60
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,101 @@
11
{{- define "main" }}
2-
<section class="container my-5">
3-
<div class="row">
4-
{{- $taxonomyName := .Title }}
5-
{{- $taxonomyShortName := .Title }}
6-
{{- $pages := where .Pages.ByWeight "Draft" "!=" true }}
2+
{{- $taxonomyName := .Title }}
3+
{{- $taxonomyShortName := .Title }}
4+
{{- $pages := where .Pages.ByWeight "Draft" "!=" true }}
75

8-
{{- $pagesWithData := slice }}
9-
{{- range $page := $pages }}
10-
{{- with .Resources.GetMatch "data.index.classifications.json" }}
11-
{{- $data := . | transform.Unmarshal }}
12-
{{- $dataItem := index $data $taxonomyName }}
13-
{{- if $dataItem }}
14-
<!-- Ensure the taxonomy exists in the data -->
15-
{{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" ($dataItem.final_score | default 0)) }}
16-
{{- else }}
17-
{{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" 0) }}
18-
{{- end }}
19-
{{- else }}
20-
{{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" .Weight) }}
21-
<!-- Default when no data file -->
22-
{{- end }}
6+
{{- $pagesWithData := slice }}
7+
{{- range $page := $pages }}
8+
{{- with .Resources.GetMatch "data.index.classifications.json" }}
9+
{{- $data := . | transform.Unmarshal }}
10+
{{- $dataItem := index $data $taxonomyName }}
11+
{{- if $dataItem }}
12+
<!-- Ensure the taxonomy exists in the data -->
13+
{{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" ($dataItem.final_score | default 0)) }}
14+
{{- else }}
15+
{{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" 0) }}
2316
{{- end }}
24-
{{- $sortedPagesWithData := sort $pagesWithData "score" "desc" }}
25-
26-
{{- range $pageWithData := $sortedPagesWithData }}
27-
{{- if eq $pageWithData.page.Type "course" }}
28-
<div class="col-xl-4 d-flex p-2">
29-
{{- partial "cards-course.html" (dict "context" .) }}
30-
</div>
31-
{{- else if or (eq $pageWithData.page.Type "tags") (eq $pageWithData.page.Type "categories") }}
32-
<div class="col-xl-4 d-flex p-2">
33-
{{- partial "page-sections/sections-taxonomies-card.html" (dict "site" .Site "context" $pageWithData.page "subTypes" "resources") }}
34-
</div>
35-
{{- else }}
36-
<div class="col-xl-4 d-flex p-2">
37-
{{- $title := $pageWithData.page.Title }}
38-
{{- $description := $pageWithData.page.Description }}
39-
{{- $buttonContent := "Find out More" }}
40-
{{- if $pageWithData.page.Params.card }}
41-
{{- $title = $pageWithData.page.Params.card.title }}
42-
{{- $description = $pageWithData.page.Params.card.content }}
43-
{{- $buttonContent = $pageWithData.page.Params.card.button.content }}
44-
{{- end }}
45-
<!-- layouts/partials/card.html -->
46-
<div class="sectioncards p-2 flex-fill flex-grow-1 h-100">
47-
<div class="card sectioncards flex-fill flex-grow-1 m-3 shadow text-start small border-0 h-100 position-relative">
48-
<div class="card-body p-4 px-20">
49-
<span class="badge text-bg-secondary">{{- title $pageWithData.page.Params.ResourceType }}</span>
50-
<h3 class="ttl-nkdagility h5 text-start" title="{{ $title }}">{{- $title }}</h3>
51-
<div class="card-text text-muted">
52-
{{- $description | markdownify }}
17+
{{- else }}
18+
{{- $pagesWithData = $pagesWithData | append (dict "page" $page "score" .Weight) }}
19+
<!-- Default when no data file -->
20+
{{- end }}
21+
{{- end }}
22+
{{- $sortedPagesWithData := sort $pagesWithData "score" "desc" }}
23+
<section class="container my-2">
24+
<div class="container">
25+
<div class="row">
26+
{{- range $sortedPagesWithData }}
27+
<div class="col-xl-4 p-2">
28+
{{- if or (eq .page.Type "tags") (eq .page.Type "categories") }}
29+
{{- partial "page-sections/sections-taxonomies-card.html" (dict "site" .Site "context" .page "subTypes" "resources") }}
30+
{{- else }}
31+
{{- $title := .page.Title }}
32+
{{- $description := .page.Description }}
33+
{{- $buttonContent := "Find out More" }}
34+
{{- if .page.Params.card }}
35+
{{- $title = .page.Params.card.title }}
36+
{{- $description = .page.Params.card.content }}
37+
{{- $buttonContent = .page.Params.card.button.content }}
38+
{{- end }}
39+
<!-- layouts/partials/card.html -->
40+
<div class="sectioncards p-2 flex-fill flex-grow-1 h-100">
41+
<div class="card sectioncards flex-fill flex-grow-1 m-3 shadow text-start small border-0 h-100 position-relative">
42+
<div class="card-body p-4 px-20">
43+
<span class="badge text-bg-secondary">{{- title .page.Params.ResourceType }}</span>
44+
<h3 class="ttl-nkdagility h5 text-start" title="{{ $title }}">{{- $title }}</h3>
45+
<div class="card-text text-muted">
46+
{{- $description | markdownify }}
47+
</div>
48+
</div>
49+
<div class="card-footer border-transparent bg-white p-3 border-0 d-flex justify-content-between align-items-center">
50+
<small class="text-body-secondary" title="Affinity to {{ $taxonomyName }} is {{ .score }}%"> <strong class="d-inline-block text-truncate" style="max-width: 150px; vertical-align: middle;"> {{ $taxonomyName }} </strong>: {{ .score }}% </small>
51+
<a href="{{ .page.Permalink }}" class="btn btn-nkdagility p-2" title="More information on {{ .title }}"> {{- $buttonContent }} <i class="fa-solid fa-arrow-right"></i> </a>
5352
</div>
54-
</div>
55-
<div class="card-footer border-transparent bg-white p-3 border-0 d-flex justify-content-between align-items-center">
56-
<small class="text-body-secondary" title="Affinity to {{ $taxonomyName }} is {{ $pageWithData.score }}%"> <strong class="d-inline-block text-truncate" style="max-width: 150px; vertical-align: middle;"> {{ $taxonomyName }} </strong>: {{ $pageWithData.score }}% </small>
57-
<a href="{{ $pageWithData.page.Permalink }}" class="btn btn-nkdagility p-2" title="More information on {{ .title }}"> {{- $buttonContent }} <i class="fa-solid fa-arrow-right"></i> </a>
5853
</div>
5954
</div>
60-
</div>
55+
{{- end }}
6156
</div>
6257
{{- end }}
63-
{{- end }}
58+
<div class="col-xl-12 p-2 my-4">
59+
<h2>Overview of {{ .Title }}</h2>
60+
{{- .Content }}
61+
</div>
62+
</div>
6463
</div>
6564
</section>
6665
{{- end }}
6766

6867
{{- define "siteSectionCallback" }}
6968
<section class="container my-5">
70-
{{/* <h2 title="R - What we do?">Our Services</h2>
71-
<p>Explore our comprehensive range of services and capabilities designed to empower organizations and teams. With our expert solutions, you can efficiently address and resolve immediate challenges, driving success across your operations.</p>
72-
{{- partial "cards-section.html" (dict "context" . "SectionName" "capabilities")
73-
}}
74-
*/}}
69+
<div class="m-1 small">
70+
<h2>Categories</h2>
71+
<div class="row">
72+
{{ range $category, $pages := .Site.Taxonomies.categories }}
73+
<div class="col-md-3 d-flex align-items-center">
74+
<span class="text-truncate d-inline-block" style="max-width: 100%;" title="{{ .Page.Title }}">
75+
<a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a>
76+
</span>
77+
{{- $count := len (where $pages "Draft" "!=" true) }}
78+
<span class="ms-1">({{ $count }})</span>
79+
</div>
80+
{{ end }}
81+
</div>
82+
<hr />
83+
</div>
84+
<div class="m-1 small">
85+
<h2>Tags</h2>
86+
<div class="row">
87+
{{ range $category, $pages := .Site.Taxonomies.tags }}
88+
<div class="col-md-3 d-flex align-items-center">
89+
<span class="text-truncate d-inline-block" style="max-width: 100%;" title="{{ .Page.Title }}">
90+
<a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a>
91+
</span>
92+
{{- $count := len (where $pages "Draft" "!=" true) }}
93+
<span class="ms-1">({{ $count }})</span>
94+
</div>
95+
{{ end }}
96+
</div>
97+
<hr />
98+
</div>
7599
</section>
76100
{{- end }}
77101

‎site/layouts/tags/list.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ <h2>Overview of {{ .Title }}</h2>
6767
{{- define "siteSectionCallback" }}
6868
<section class="container my-5">
6969
<div class="m-1 small">
70-
<h5>Categories</h5>
70+
<h2>Categories</h2>
7171
<div class="row">
7272
{{ range $category, $pages := .Site.Taxonomies.categories }}
7373
<div class="col-md-3 d-flex align-items-center">
@@ -82,7 +82,7 @@ <h5>Categories</h5>
8282
<hr />
8383
</div>
8484
<div class="m-1 small">
85-
<h6>Tags</h6>
85+
<h2>Tags</h2>
8686
<div class="row">
8787
{{ range $category, $pages := .Site.Taxonomies.tags }}
8888
<div class="col-md-3 d-flex align-items-center">

0 commit comments

Comments
 (0)