diff options
author | Vincent Ambo <mail@tazj.in> | 2020-08-10T23·15+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-08-10T23·24+0000 |
commit | 1d699fdc5c606924c8d45762afadcb6ac9da4542 (patch) | |
tree | 2a7337194d7a1b2ce456633e827c731f7df07595 | |
parent | 718a561441856b056d4c5994e19ca279344587c5 (diff) |
refactor(tazjin/atom-feed): Make content optional r/1638
This allows for adding feed entries which only have an alternate representation (i.e. URL that points somewhere else). These entries will still have a summary, in my use-case. Change-Id: I149838c5f59c66e8169b97f35b378aefe9763a84 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1714 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
-rw-r--r-- | users/tazjin/atom-feed/default.nix | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/users/tazjin/atom-feed/default.nix b/users/tazjin/atom-feed/default.nix index 369295da280d..cd189b86754d 100644 --- a/users/tazjin/atom-feed/default.nix +++ b/users/tazjin/atom-feed/default.nix @@ -29,10 +29,8 @@ let # not be blank. title = string; - # Content of the entry. This element is technically optional, but - # only if an alternate link is provided. In practice it should - # always be present in the feeds generated by this code. - content = string; + # Content of the entry. + content = option string; # Indicates the last time the entry was modified in a significant # way (in seconds since epoch). @@ -113,7 +111,11 @@ let ${elem "title" e.title} ${elem "id" e.id} ${elem "updated" (renderEpoch e.updated)} - <content type="html">${escape e.content}</content> + ${if e ? content + then ''<content type="html">${escape e.content}</content>'' + else "" + } + ${if e ? summary then elem "summary" e.summary else ""} ${concatStrings (map renderAuthor (e.authors or []))} ${if e ? subtitle then elem "subtitle" e.subtitle else ""} ${if e ? rights then elem "rights" e.rights else ""} |