mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
Updates for JSON Feed 1.1
- Add `authors` now that `author` is deprecated - Add `language` with the value en-CA - Change MIME type to application/feed+json
This commit is contained in:
parent
be47fc2974
commit
905ccfa674
3 changed files with 21 additions and 9 deletions
|
|
@ -6,6 +6,10 @@ AddType text/html net
|
|||
SetOutputFilter DEFLATE
|
||||
AddDefaultCharset utf-8
|
||||
|
||||
<Files feed.json>
|
||||
AddType application/feed+json json
|
||||
</Files>
|
||||
|
||||
# Turn on Expires and set default expires to 3 days
|
||||
ExpiresActive On
|
||||
ExpiresDefault A259200
|
||||
|
|
@ -18,7 +22,7 @@ ExpiresDefault A259200
|
|||
</FilesMatch>
|
||||
|
||||
# Set up 2 week caching on commonly updated files
|
||||
<FilesMatch "\.(xml|txt|html|js|css|rss)$">
|
||||
<FilesMatch "\.(xml|txt|html|js|css|rss|json)$">
|
||||
ExpiresDefault A1209600
|
||||
Header append Cache-Control "private, must-revalidate"
|
||||
</FilesMatch>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import Foundation
|
|||
struct Permissions: OptionSet {
|
||||
let rawValue: Int16
|
||||
|
||||
static let none = Permissions(rawValue: 0)
|
||||
static let none: Permissions = []
|
||||
|
||||
// These raw values match those used by Unix file systems and must not be changed.
|
||||
|
||||
|
|
|
|||
|
|
@ -37,15 +37,17 @@ final class JSONFeedWriter {
|
|||
|
||||
private extension JSONFeedWriter {
|
||||
func buildFeed(site: Site, posts: [Post], renderer: JSONFeedRendering) throws -> Feed {
|
||||
Feed(
|
||||
let author = FeedAuthor(
|
||||
name: site.author,
|
||||
avatar: jsonFeed.avatarPath.map(site.url.appendingPathComponent)?.absoluteString,
|
||||
url: site.url.absoluteString
|
||||
)
|
||||
return Feed(
|
||||
title: site.title,
|
||||
home_page_url: site.url.absoluteString,
|
||||
feed_url: site.url.appendingPathComponent(jsonFeed.path).absoluteString,
|
||||
author: FeedAuthor(
|
||||
name: site.author,
|
||||
avatar: jsonFeed.avatarPath.map(site.url.appendingPathComponent)?.absoluteString,
|
||||
url: site.url.absoluteString
|
||||
),
|
||||
author: author,
|
||||
authors: [author],
|
||||
icon: jsonFeed.iconPath.map(site.url.appendingPathComponent)?.absoluteString,
|
||||
favicon: jsonFeed.faviconPath.map(site.url.appendingPathComponent)?.absoluteString,
|
||||
items: try posts.map { post in
|
||||
|
|
@ -66,11 +68,17 @@ private extension JSONFeedWriter {
|
|||
}
|
||||
|
||||
private struct Feed: Codable {
|
||||
let version = "https://jsonfeed.org/version/1"
|
||||
var version = "https://jsonfeed.org/version/1.1"
|
||||
var language = "en-CA"
|
||||
let title: String
|
||||
let home_page_url: String
|
||||
let feed_url: String
|
||||
|
||||
// `author` has been deprecated in favour of `authors`, but `author` remains for backwards
|
||||
// compatibility.
|
||||
let author: FeedAuthor
|
||||
let authors: [FeedAuthor]
|
||||
|
||||
let icon: String?
|
||||
let favicon: String?
|
||||
let items: [FeedItem]
|
||||
|
|
|
|||
Loading…
Reference in a new issue