Skip to content

Commit

Permalink
Added metadata to the library item web page
Browse files Browse the repository at this point in the history
  • Loading branch information
ResendeTech committed Sep 30, 2024
1 parent 90ad058 commit 481f04c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions library/templates/library/library_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,61 @@ <h1>
{% endif %}
</dl>
{% endblock %}

{{% block extra_js %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "CreativeWork",
"name": "{{ page.title }}",
{% if page.specific.authors.count %}
"author": [
{% for author in page.specific.authors.all %}
{
"@type": "{% if author.author.specific_class_name == 'Person' %}Person{% elif author.author.specific_class_name == 'Organization' or author.author.specific_class_name == 'Meeting' %}Organization{% else %}Thing{% endif %}",
"name": "{{ author.author.title }}"
{% if author.author.specific_class_name == 'Person' %}
,"givenName": "{{ author.author.specific.given_name }}",
"familyName": "{{ author.author.specific.family_name }}"
{% endif %}
}{% if not forloop.last %},{% endif %}
{% endfor %}
],
{% endif %}
{% if page.specific.publication_date %}
"datePublished": "{{ page.specific.publication_date|date:"Y-m-d" }}",
{% endif %}
{% if page.specific.item_audience %}
"audience": {
"@type": "Audience",
"name": "{{ page.specific.item_audience.title }}"
},
{% endif %}
{% if page.specific.item_genre %}
"genre": "{{ page.specific.item_genre.title }}",
{% endif %}
{% if page.specific.item_medium %}
"encodingFormat": "{{ page.specific.item_medium.title }}",
{% endif %}
{% if page.specific.item_time_period %}
"temporalCoverage": "{{ page.specific.item_time_period.title }}",
{% endif %}
{% if page.specific.topics.count %}
"about": [
{% for topic in page.specific.topics.all %}
"{{ topic.topic.title }}"{% if not forloop.last %},{% endif %}
{% endfor %}
],
{% endif %}
{% if page.tags.count %}
"keywords": [
{% for tag in page.tags.all %}
"{{ tag }}"{% if not forloop.last %},{% endif %}
{% endfor %}
],
{% endif %}
"url": "{{ page.full_url }}"
}
</script>

{% endblock extra_js %}}

0 comments on commit 481f04c

Please sign in to comment.