Skip to content

Commit 8dc0940

Browse files
committed
Add fullName (badge + name) model property, update collections page
1 parent a396167 commit 8dc0940

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

Sources/App/Controllers/CustomCollectionsController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ enum CustomCollectionsController {
7373
let model = CustomCollectionShow.Model(
7474
key: collection.key,
7575
name: collection.name,
76+
badge: collection.badge,
7677
packages: packageInfo,
7778
page: query.page,
7879
hasMoreResults: page.hasMoreResults

Sources/App/Views/CustomCollection/CustomCollectionShow+Model.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,31 @@ extension CustomCollectionShow {
1616
struct Model {
1717
var key: String
1818
var name: String
19+
var badge: String?
1920
var packages: [PackageInfo]
2021
var page: Int
2122
var hasMoreResults: Bool
2223

2324
internal init(key: String,
2425
name: String,
26+
badge: String?,
2527
packages: [PackageInfo],
2628
page: Int,
2729
hasMoreResults: Bool) {
2830
self.key = key
2931
self.name = name
32+
self.badge = badge
3033
self.packages = packages
3134
self.page = page
3235
self.hasMoreResults = hasMoreResults
3336
}
37+
38+
var fullName: String {
39+
if let badge {
40+
"\(badge) \(name)"
41+
} else {
42+
name
43+
}
44+
}
3445
}
3546
}

Sources/App/Views/CustomCollection/CustomCollectionShow+View.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ enum CustomCollectionShow {
3838
override func breadcrumbs() -> [Breadcrumb] {
3939
[
4040
Breadcrumb(title: "Home", url: SiteURL.home.relativeURL()),
41-
Breadcrumb(title: model.name)
41+
Breadcrumb(title: "Collections"),
42+
Breadcrumb(title: model.fullName)
4243
]
4344
}
4445

4546
override func content() -> Node<HTML.BodyContext> {
4647
.group(
4748
.h2(
4849
.class("trimmed"),
49-
.text("\(model.name) package collection")
50+
.text("\(model.fullName) package collection")
5051
),
5152
.p(
5253
.text("The packages in this collection are part of a custom package collection, "),

Tests/AppTests/Mocks/CustomCollectionShow+mock.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extension CustomCollectionShow.Model {
3030
) }
3131
return .init(key: "custom-collection",
3232
name: "Custom Collection",
33+
badge: "BADGE",
3334
packages: packages, page: 1,
3435
hasMoreResults: false)
3536
}

Tests/AppTests/__Snapshots__/WebpageSnapshotTests/test_CustomCollectionShow.1.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,17 @@ <h1>
7575
</a>
7676
</li>
7777
<li>
78-
<span>Custom Collection</span>
78+
<span>Collections</span>
79+
</li>
80+
<li>
81+
<span>BADGE Custom Collection</span>
7982
</li>
8083
</ul>
8184
</div>
8285
</nav>
8386
<main>
8487
<div class="inner">
85-
<h2 class="trimmed">Custom Collection package collection</h2>
88+
<h2 class="trimmed">BADGE Custom Collection package collection</h2>
8689
<p>The packages in this collection are part of a custom package collection,
8790
<a href="/package-collections">usable in Xcode or SwiftPM</a>. You can find out more about custom package collections and how to request one in the
8891
<a href="/blog/introducing-custom-package-collections">launch blog post</a>.

0 commit comments

Comments
 (0)