Skip to content

Commit

Permalink
Add fullName (badge + name) model property, update collections page
Browse files Browse the repository at this point in the history
  • Loading branch information
finestructure committed Dec 5, 2024
1 parent a396167 commit 8dc0940
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions Sources/App/Controllers/CustomCollectionsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum CustomCollectionsController {
let model = CustomCollectionShow.Model(
key: collection.key,
name: collection.name,
badge: collection.badge,
packages: packageInfo,
page: query.page,
hasMoreResults: page.hasMoreResults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,31 @@ extension CustomCollectionShow {
struct Model {
var key: String
var name: String
var badge: String?
var packages: [PackageInfo]
var page: Int
var hasMoreResults: Bool

internal init(key: String,
name: String,
badge: String?,
packages: [PackageInfo],
page: Int,
hasMoreResults: Bool) {
self.key = key
self.name = name
self.badge = badge
self.packages = packages
self.page = page
self.hasMoreResults = hasMoreResults
}

var fullName: String {
if let badge {
"\(badge) \(name)"
} else {
name
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ enum CustomCollectionShow {
override func breadcrumbs() -> [Breadcrumb] {
[
Breadcrumb(title: "Home", url: SiteURL.home.relativeURL()),
Breadcrumb(title: model.name)
Breadcrumb(title: "Collections"),
Breadcrumb(title: model.fullName)
]
}

override func content() -> Node<HTML.BodyContext> {
.group(
.h2(
.class("trimmed"),
.text("\(model.name) package collection")
.text("\(model.fullName) package collection")
),
.p(
.text("The packages in this collection are part of a custom package collection, "),
Expand Down
1 change: 1 addition & 0 deletions Tests/AppTests/Mocks/CustomCollectionShow+mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extension CustomCollectionShow.Model {
) }
return .init(key: "custom-collection",
name: "Custom Collection",
badge: "BADGE",
packages: packages, page: 1,
hasMoreResults: false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ <h1>
</a>
</li>
<li>
<span>Custom Collection</span>
<span>Collections</span>
</li>
<li>
<span>BADGE Custom Collection</span>
</li>
</ul>
</div>
</nav>
<main>
<div class="inner">
<h2 class="trimmed">Custom Collection package collection</h2>
<h2 class="trimmed">BADGE Custom Collection package collection</h2>
<p>The packages in this collection are part of a custom package collection,
<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
<a href="/blog/introducing-custom-package-collections">launch blog post</a>.
Expand Down

0 comments on commit 8dc0940

Please sign in to comment.