Don't show word count if there isn't one

This mostly covers spotify pages, which use a custom reading time but
don't have words.
This commit is contained in:
Jake Howard 2022-09-06 09:17:42 +01:00
parent 71f74251bb
commit c7e56ab038
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 7 additions and 1 deletions

View file

@ -15,7 +15,9 @@
<div class="control"> <div class="control">
<div class="tags has-addons"> <div class="tags has-addons">
<span class="tag is-dark"><i class="far fa-clock"></i></span> <span class="tag is-dark"><i class="far fa-clock"></i></span>
<span class="tag is-light" title="{{ page.word_count }} words">{{ page.reading_time|naturaldelta }}</span> <span class="tag is-light" {% if page.word_count %}title="{{ page.word_count }} words"{% endif %}>
{{ page.reading_time|naturaldelta }}
</span>
</div> </div>
</div> </div>
{% endif %} {% endif %}

View file

@ -48,6 +48,10 @@ class SpotifyPlaylistPage(BaseContentPage):
) )
) )
@cached_property
def word_count(self) -> int:
return 0
@cached_property @cached_property
def subtitle(self) -> str: def subtitle(self) -> str:
return self.playlist_data["description"] return self.playlist_data["description"]