mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
Make site email optional
This commit is contained in:
parent
1426b4e75b
commit
fa3ec10345
3 changed files with 11 additions and 3 deletions
|
|
@ -53,11 +53,19 @@ final class RSSFeedWriter {
|
|||
)
|
||||
let renderedPosts: [FeedPost] = try posts.map { post in
|
||||
let title = post.isLink ? "→ \(post.title)" : post.title
|
||||
let author: String = {
|
||||
if let email = site.email {
|
||||
return "\(email) (\(post.author))"
|
||||
}
|
||||
else {
|
||||
return post.author
|
||||
}
|
||||
}()
|
||||
let url = site.url.appendingPathComponent(post.path)
|
||||
return FeedPost(
|
||||
title: title.htmlEscape(useNamedReferences: true),
|
||||
date: post.date.rfc822.htmlEscape(useNamedReferences: true),
|
||||
author: "\(site.email) (\(post.author))".htmlEscape(useNamedReferences: true),
|
||||
author: author.htmlEscape(useNamedReferences: true),
|
||||
link: (post.link ?? url).absoluteString.htmlEscape(useNamedReferences: true),
|
||||
guid: url.absoluteString.htmlEscape(useNamedReferences: true),
|
||||
body: try templateRenderer.renderTemplate(name: "feed-post.html", context: [
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import Foundation
|
|||
/// This is used to make the JSON simpler to write with optionals.
|
||||
struct HumanSite: Codable {
|
||||
let author: String
|
||||
let email: String
|
||||
let email: String?
|
||||
let title: String
|
||||
let description: String?
|
||||
let url: URL
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import Foundation
|
|||
|
||||
public struct Site {
|
||||
public let author: String
|
||||
public let email: String
|
||||
public let email: String?
|
||||
public let title: String
|
||||
public let description: String?
|
||||
public let url: URL
|
||||
|
|
|
|||
Loading…
Reference in a new issue