Skip to content

Commit d1cfba3

Browse files
committed
Added latest badge on latest documentation page
1 parent 4f05cdd commit d1cfba3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

FrontEnd/docc.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,13 @@ footer.spi {
248248
text-align: center;
249249
}
250250
}
251+
252+
.badge {
253+
margin-left: 4px;
254+
padding: 2px 4px;
255+
font-size: 10px;
256+
text-align: center;
257+
color: var(--grey);
258+
background-color: var(--dark-grey);
259+
border-radius: 4px;
260+
}

Sources/App/Views/DocumentationPageProcessor.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ struct DocumentationPageProcessor {
172172
.span(
173173
.class(referenceKind.cssClass),
174174
.text(docVersion.reference)
175-
)
175+
),
176+
latestBadge()
176177
), choices: documentationVersionChoices.count > 0 ? documentationVersionChoices : nil)
177178
]
178179

@@ -244,6 +245,15 @@ struct DocumentationPageProcessor {
244245
).render()
245246
}
246247

248+
func latestBadge() -> Plot.Node<HTML.BodyContext> {
249+
let isLatest = availableVersions.first(where: { $0.reference == docVersion.reference })?.isLatestStable ?? false
250+
print("isLatest: \(isLatest)")
251+
return isLatest ? .span(
252+
.class("badge"),
253+
.text("LATEST")
254+
) : .empty
255+
}
256+
247257
var footer: String {
248258
@Dependency(\.environment) var environment
249259
return Plot.Node.footer(

0 commit comments

Comments
 (0)