Fix dates and add subjects in RSS3
This commit is contained in:
parent
6e86eee5fc
commit
7a359e53c2
|
@ -3,6 +3,7 @@
|
|||
|
||||
def ensure_array: (. // []) | if type == "array" then . else [.] end;
|
||||
def ensure_string: if type == "array" then .[0] else . end | if type == "object" then .["#text"] else . end;
|
||||
def parse_date: if .pubDate then .pubDate | strptime("%a, %d %b %Y %T %Z") | todateiso8601 else null end;
|
||||
|
||||
.rss.channel
|
||||
| [{
|
||||
|
@ -10,7 +11,7 @@ def ensure_string: if type == "array" then .[0] else . end | if type == "object"
|
|||
"link": .link,
|
||||
"description": .description,
|
||||
"generator": .generator,
|
||||
"last-modified": .pubDate,
|
||||
"last-modified": parse_date,
|
||||
"language": .language,
|
||||
"rights": .copyright,
|
||||
"creator": (.managingEditor // .webMaster),
|
||||
|
@ -20,14 +21,15 @@ def ensure_string: if type == "array" then .[0] else . end | if type == "object"
|
|||
"link": .link,
|
||||
"description": .description,
|
||||
"creator": .author,
|
||||
"last-modified": .pubDate,
|
||||
"last-modified": parse_date,
|
||||
"guid": .guid,
|
||||
"uri": (if (.guid|type) == "string" or .guid?["@isPermaLink"] != "false" then .guid else null end)
|
||||
"uri": (if (.guid|type) == "string" or .guid?["@isPermaLink"] != "false" then .guid else null end),
|
||||
"subject": (.category | ensure_array | map(ensure_string) | join(", "))
|
||||
}]
|
||||
| map([
|
||||
map_values(ensure_string)
|
||||
| to_entries[]
|
||||
| select(.value | . != null and length)
|
||||
| select(.value | . != null and length > 0)
|
||||
| "\(.key): \(.value)"
|
||||
# Ensure there are spaces after all newlines
|
||||
| gsub("\n"; "\n ")
|
||||
|
|
Loading…
Reference in New Issue