File tree 3 files changed +10
-16
lines changed
3 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,6 @@ pub fn render_feeds(
36
36
) -> Result < Option < Vec < String > > > {
37
37
let mut pages = all_pages. into_iter ( ) . filter ( |p| p. meta . date . is_some ( ) ) . collect :: < Vec < _ > > ( ) ;
38
38
39
- // Don't generate a feed if none of the pages has a date
40
- if pages. is_empty ( ) {
41
- return Ok ( None ) ;
42
- }
43
-
44
39
pages. par_sort_unstable_by ( |a, b| {
45
40
let ord = b. meta . datetime . unwrap ( ) . cmp ( & a. meta . datetime . unwrap ( ) ) ;
46
41
if ord == Ordering :: Equal {
@@ -51,15 +46,14 @@ pub fn render_feeds(
51
46
} ) ;
52
47
53
48
let mut context = Context :: new ( ) ;
54
- context. insert (
55
- "last_updated" ,
56
- pages
57
- . iter ( )
58
- . filter_map ( |page| page. meta . updated . as_ref ( ) )
59
- . chain ( pages[ 0 ] . meta . date . as_ref ( ) )
60
- . max ( ) // I love lexicographically sorted date strings
61
- . unwrap ( ) , // Guaranteed because of pages[0].meta.date
62
- ) ;
49
+ if let Some ( last_updated) = pages
50
+ . iter ( )
51
+ . filter_map ( |page| page. meta . updated . as_ref ( ) )
52
+ . chain ( pages. first ( ) . and_then ( |p| p. meta . date . as_ref ( ) ) )
53
+ . max ( )
54
+ {
55
+ context. insert ( "last_updated" , & last_updated) ;
56
+ }
63
57
let library = site. library . read ( ) . unwrap ( ) ;
64
58
// limit to the last n elements if the limit is set; otherwise use all.
65
59
let num_entries = site. config . feed_limit . unwrap_or ( pages. len ( ) ) ;
Original file line number Diff line number Diff line change 17
17
{%- endif -%}
18
18
" />
19
19
<generator uri =" https://www.getzola.org/" >Zola</generator >
20
- <updated >{{ last_updated | date(format="%+") }}</updated >
20
+ {% if last_updated is defined %} <updated >{{ last_updated | date(format="%+") }}</updated >{% endif %}
21
21
<id >{{ feed_url | safe }}</id >
22
22
{%- for page in pages %}
23
23
<entry xml : lang =" {{ page.lang }}" >
Original file line number Diff line number Diff line change 17
17
<generator >Zola</generator >
18
18
<language >{{ lang }}</language >
19
19
<atom : link href =" {{ feed_url | safe }}" rel =" self" type =" application/rss+xml" />
20
- <lastBuildDate >{{ last_updated | date(format="%a, %d %b %Y %H:%M:%S %z") }}</lastBuildDate >
20
+ {% if last_updated is defined %} <lastBuildDate >{{ last_updated | date(format="%a, %d %b %Y %H:%M:%S %z") }}</lastBuildDate >{% endif %}
21
21
{%- for page in pages %}
22
22
<item >
23
23
<title >{{ page.title }}</title >
You can’t perform that action at this time.
0 commit comments