Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added metadata to the library item web page #1123

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{% block extra_js %}
{% 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 %}",
brylie marked this conversation as resolved.
Show resolved Hide resolved
"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 %}}
Loading