Don't render empty html about books

This commit is contained in:
Mouse Reeve 2021-10-01 10:08:56 -07:00
parent 0928fd03a6
commit 428d87a351
2 changed files with 47 additions and 45 deletions

View file

@ -1,6 +1,7 @@
{% spaceless %}
{% load i18n %}
{% if book.isbn13 or book.oclc_number or book.asin %}
<dl>
{% if book.isbn_13 %}
<div class="is-flex">
@ -23,4 +24,5 @@
</div>
{% endif %}
</dl>
{% endif %}
{% endspaceless %}

View file

@ -3,15 +3,12 @@
{% load i18n %}
{% load humanize %}
<p>
{% firstof book.physical_format_detail book.physical_format as format %}
{% firstof book.physical_format book.physical_format_detail as format_property %}
{% with pages=book.pages %}
{% if format %}
{% comment %}
@todo The bookFormat property is limited to a list of values whereas the book edition is free text.
@see https://schema.org/bookFormat
{% endcomment %}
{% if format or pages %}
<p>
{% if format_property %}
<meta itemprop="bookFormat" content="{{ format_property }}">
{% endif %}
@ -26,8 +23,9 @@
{% elif pages %}
{% blocktrans %}{{ pages }} pages{% endblocktrans %}
{% endif %}
{% endwith %}
</p>
{% endif %}
{% endwith %}
{% if book.languages %}
{% for language in book.languages %}
@ -41,8 +39,9 @@
</p>
{% endif %}
<p>
{% with date=book.published_date|naturalday publisher=book.publishers|join:', ' %}
{% if date or book.first_published_date or book.publishers %}
<p>
{% if date or book.first_published_date %}
<meta
itemprop="datePublished"
@ -67,6 +66,7 @@
{% elif publisher %}
{% blocktrans %}Published by {{ publisher }}.{% endblocktrans %}
{% endif %}
{% endwith %}
</p>
{% endif %}
{% endwith %}
{% endspaceless %}