Skip to content

Commit df39e17

Browse files
authored
fix: order for list pages + navbar improv (#37)
1 parent dd04617 commit df39e17

File tree

2 files changed

+45
-58
lines changed

2 files changed

+45
-58
lines changed

assets/js/sidebar.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,31 @@ $(document).ready(function () {
44
if (item.dataset.menuId == $(".main").data("menuId")) {
55
$(item).css("color", "#429345");
66
$(item).css("font-weight", "500");
7+
8+
// Remove "collapsed" class and set aria-expanded to "true" for the current item
9+
$(item).removeClass("collapsed");
10+
$(item).attr("aria-expanded", "true");
11+
12+
// Capture data-target value
13+
var targetId = $(item).data("target");
14+
if (!targetId) {
15+
var hrefValue = $(item).attr("href");
16+
// Add "show" class to the corresponding divs with matching id
17+
var targetDivs = $("div[id='" + hrefValue.replace("#", "") + "']");
18+
targetDivs.addClass("show");
19+
} else {
20+
$(targetId).addClass("show");
21+
}
22+
23+
// Expand parents
724
$(item).parents(".collapse").each(function(i,el) {
825
var col = new bootstrap.Collapse(el, {
926
toggle: false
1027
});
1128
col.show();
1229
});
13-
}
14-
});
30+
31+
$(item).next(".accordion-body").find(".collapse").addClass("show");
32+
}
33+
});
1534
});

layouts/partials/list-main.html

+24-56
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,43 @@ <h1 class="bd-title">
55
{{ .Title }}
66
</h1>
77
{{ if .Description }}
8-
<p class="bd-lead">
8+
<p>
99
{{ .Description | markdownify }}
1010
</p>
1111
{{ end}}
1212
{{ if .Content }}
13-
<p class="bd-lead">
13+
<p>
1414
{{ .Content | markdownify }}
1515
</p>
1616
{{ end }}
1717
</div>
1818
</div>
1919

20-
<section class="col-md-12 col-xl-12 py-md-3 pl-md-5" id="section-content-list">
21-
20+
<section>
2221
<div class="row">
2322
<div class="card-deck">
24-
{{ if .Sections }}
25-
{{ range .Sections }}
26-
<div class="col-md-5 card">
27-
<div class="card-body">
28-
<h3 class="card-title">
29-
<i class="fas fa-{{if .Page.Params.icon}}{{ .Page.Params.icon }}{{else}}book{{end}} fa-2x card-img-top"></i>
30-
<a href="{{ .Permalink }}">{{ .Title }}</a>
31-
</h3>
32-
{{/*}}<p class="card-text">
33-
{{ if .Description }}{{ .Description | markdownify }}{{ end }}
34-
</p>{{*/}}
35-
{{ if and (eq .Site.Params.useSectionPageLists "true") (.Pages) }}
36-
<ul class="card-list">
37-
{{ range first 5 .Pages.ByWeight }}
38-
<li>
39-
<a href="{{ .Permalink }}">{{ .Title }}</a>
40-
</li>
41-
{{ end }}
42-
{{ if gt .Pages "5" }}
43-
<li>
44-
<a href="{{ .Permalink }}">More...</a>
45-
</li>
46-
{{ end }}
47-
</ul>
48-
{{ end }}
49-
</div>
50-
</div>
51-
{{ end }}
52-
{{ end }}
23+
{{ range .Pages.GroupBy "Section" }}
5324

54-
{{ range (.Paginate ( where .Pages.ByWeight ".Kind" "!=" "section" )).Pages }}
55-
<div class="col-md-5 card">
56-
<div class="card-body">
57-
<h3 class="card-title">
58-
<i class="far fa-{{if .Page.Params.icon}}{{ .Page.Params.icon }}{{else}}file-alt{{end}} fa-2x card-img-top"></i>
59-
<a href="{{ .Permalink }}">{{ .Title }}</a>
60-
</h3>
61-
{{/*}}
62-
<p class="card-text">
63-
{{ if .Description }} {{ .Description | markdownify }}{{ end }}
64-
</p>{{*/}}
65-
</div>
66-
</div>
67-
{{ end }}
68-
</div>
69-
</div>
70-
</section>
25+
{{ range .Pages.ByWeight }}
26+
<div class="col-md-5 card">
27+
<div class="card-body">
28+
<h3 class="card-title">
29+
<i class="fas fa-{{if eq .Kind "page"}}file-alt{{else}}book{{end}} fa-2x card-img-top"></i>
30+
<a href="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}}">{{ .Title }}</a>
31+
</h3>
32+
{{/*}}<p class="card-text">
33+
{{ if .Description }}{{ .Description | markdownify }}{{ end }}
34+
</p>{{*/}}
35+
36+
</div>
37+
</div>
7138

72-
{{ if not .IsHome }}
73-
<div class="row justify-content-center">
74-
{{ partial "pagination.html" . }}
75-
</div>
76-
{{ end }}
39+
{{ end }}
40+
</div>
41+
</div>
42+
{{ end }}
7743

44+
45+
</section>
7846

79-
</div>
47+
</div>

0 commit comments

Comments
 (0)