Skip to content

Commit

Permalink
Add Twitter card support.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra committed Jan 18, 2024
1 parent 6a23e01 commit 6dee694
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions betty/assets/templates/head.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
{% if app.project.configuration.author %}
<meta name="author" content="{{ app.project.configuration.author }}"/>
{% endif %}
<meta name="og:title" content="{%- if page_title is defined -%}{{ page_title | striptags }}{%- else -%}{{ app.project.configuration.title }}{%- endif -%}"/>
<meta name="og:title" content="{{ page_title | default(app.project.configuration.title) | striptags }}"/>
<meta name="og:site_name" content="{{ app.project.configuration.title }}"/>
<meta name="twitter:title" content="{{ page_title | default(app.project.configuration.title) | striptags }}"/>
<meta name="twitter:card" content="summary_large_image"/>
{% if page_resource is defined %}
{% if page_resource is has_files %}
{% for file in page_resource.files %}
{% if file.media_type.type == 'image' %}
<meta name="og:image" content="{{ file | image(600, 600) | static_url }}"/>
{% set page_image_url = file | image(600, 600) | static_url(absolute=true) %}
<meta name="og:image" content="{{ page_image_url }}"/>
<meta name="og:image:type" content="{{ file.media_type }}"/>
<meta name="twitter:image" content="{{ page_image_url }}"/>
{% if file.description %}
<meta name="og:image:description" content="{{ file.description }}"/>
<meta name="twitter:image:alt" content="{{ file.description }}"/>
{% endif %}
{% endif %}
{% endfor %}
Expand Down

0 comments on commit 6dee694

Please sign in to comment.