Add special case to article renderer for adding additional CSS for feeds.

This commit is contained in:
Brent Simmons committed 2026-12-02 21:13:56 -08:00
1 parent bcd8717bd8
commit 191febbc2a
2 files changed
+23 -1

No files matched your search

@@ -232,7 +232,11 @@ private extension ArticleRenderer {
}
private var articleCSS: String {
return try! MacroProcessor.renderedText(withTemplate: styleString(), substitutions: styleSubstitutions())
let css = try! MacroProcessor.renderedText(withTemplate: styleString(), substitutions: styleSubstitutions())
guard extractedArticle == nil, let feedSpecificCSS = ArticleRenderingSpecialCases.feedSpecificCSS(feedURL: article?.feed?.url) else {
return css
}
return css + "\n" + feedSpecificCSS
}
static var defaultStyleSheet: String = {
@@ -116,6 +116,24 @@ struct ArticleRenderingSpecialCases {
return feedURLsWithTitleInContent.contains(feedURL)
}
// Hide clutter in Reactor’s post header.
private static let reactorAdditionalCSS = """
.post-hero-symbol, .post-hero-publish, .post-hero-caption-vertical, .post-hero-quick-access {
display: none;
}
"""
private static let feedSpecificCSSByFeedURL = [
"https://reactormag.com/feed/": reactorAdditionalCSS
]
static func feedSpecificCSS(feedURL: String?) -> String? {
guard let feedURL else {
return nil
}
return feedSpecificCSSByFeedURL[feedURL]
}
static func filterHTMLIfNeeded(baseURL: String, html: String) -> String {
var filteredHTML = removeLocationHrefRedirectScripts(html)