Merge pull request #3003 from dato/book_info_first_pub_date

Fallback to showing first published date
This commit is contained in:
Jascha Ezra Urbach 2023-10-17 20:16:06 +02:00 committed by GitHub
commit 06923c64c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,16 +40,13 @@
</p> </p>
{% endif %} {% endif %}
{% with date=book.published_date|naturalday publisher=book.publishers|join:', ' %} {% if book.published_date or book.first_published_date %}
{% if date or book.first_published_date or book.publishers %}
{% if date or book.first_published_date %}
<meta <meta
itemprop="datePublished" itemprop="datePublished"
content="{{ book.first_published_date|default:book.published_date|date:'Y-m-d' }}" content="{{ book.first_published_date|default:book.published_date|date:'Y-m-d' }}"
> >
{% endif %} {% endif %}
<p> <p>
{% comment %} {% comment %}
@todo The publisher property needs to be an Organization or a Person. Well be using Thing which is the more generic ancestor. @todo The publisher property needs to be an Organization or a Person. Well be using Thing which is the more generic ancestor.
@see https://schema.org/Publisher @see https://schema.org/Publisher
@ -60,14 +57,14 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if date and publisher %} {% with date=book.published_date|default:book.first_published_date|naturalday publisher=book.publishers|join:', ' %}
{% if book.published_date and publisher %}
{% blocktrans %}Published {{ date }} by {{ publisher }}.{% endblocktrans %} {% blocktrans %}Published {{ date }} by {{ publisher }}.{% endblocktrans %}
{% elif date %}
{% blocktrans %}Published {{ date }}{% endblocktrans %}
{% elif publisher %} {% elif publisher %}
{% blocktrans %}Published by {{ publisher }}.{% endblocktrans %} {% blocktrans %}Published by {{ publisher }}.{% endblocktrans %}
{% elif date %}
{% blocktrans %}Published {{ date }}{% endblocktrans %}
{% endif %} {% endif %}
{% endwith %}
</p> </p>
{% endif %}
{% endwith %}
{% endspaceless %} {% endspaceless %}