Move all opengraph (/twitter) metadata into one template

This makes it easier to modify & allows us to set title & description for specific types of pages.

Sets us up for #2575
This commit is contained in:
Andy Maloney 2023-01-11 16:17:41 -05:00
parent 5c8145b79d
commit b4aa39f0ed
6 changed files with 25 additions and 29 deletions

View file

@ -7,8 +7,8 @@
{% block title %}{{ book|book_title }}{% endblock %}
{% block opengraph_images %}
{% include 'snippets/opengraph_images.html' with image=book.preview_image %}
{% block opengraph %}
{% include 'snippets/opengraph.html' with image=book.preview_image %}
{% endblock %}
{% block content %}

View file

@ -2,15 +2,13 @@
{% load feed_page_tags %}
{% load i18n %}
{% block opengraph_images %}
{% firstof status.book status.mention_books.first as book %}
{% if book %}
{% include 'snippets/opengraph_images.html' with image=preview %}
{% else %}
{% include 'snippets/opengraph_images.html' %}
{% endif %}
{% block opengraph %}
{% firstof status.book status.mention_books.first as book %}
{% if book %}
{% include 'snippets/opengraph.html' with image=preview %}
{% else %}
{% include 'snippets/opengraph.html' %}
{% endif %}
{% endblock %}
@ -44,4 +42,3 @@
</div>
{% endblock %}

View file

@ -15,20 +15,9 @@
<link rel="shortcut icon" type="image/x-icon" href="{% if site.favicon %}{% get_media_prefix %}{{ site.favicon }}{% else %}{% static "images/favicon.ico" %}{% endif %}">
<link rel="apple-touch-icon" href="{% if site.logo %}{{ media_full_url }}{{ site.logo }}{% else %}{% static "images/logo.png" %}{% endif %}">
{% if preview_images_enabled is True %}
<meta name="twitter:card" content="summary_large_image">
{% else %}
<meta name="twitter:card" content="summary">
{% endif %}
<meta name="twitter:title" content="{% if title %}{{ title }} - {% endif %}{{ site.name }}">
<meta name="og:title" content="{% if title %}{{ title }} - {% endif %}{{ site.name }}">
<meta name="twitter:description" content="{{ site.instance_tagline }}">
<meta name="og:description" content="{{ site.instance_tagline }}">
{% block opengraph_images %}
{% include 'snippets/opengraph_images.html' %}
{% block opengraph %}
{% include 'snippets/opengraph.html' %}
{% endblock %}
<meta name="twitter:image:alt" content="BookWyrm Logo">
{% block head_links %}{% endblock %}
</head>

View file

@ -8,8 +8,8 @@
{% include 'user/books_header.html' with shelf=shelf %}
{% endblock %}
{% block opengraph_images %}
{% include 'snippets/opengraph_images.html' with image=user.preview_image %}
{% block opengraph %}
{% include 'snippets/opengraph.html' with image=user.preview_image %}
{% endblock %}
{% block content %}

View file

@ -1,6 +1,7 @@
{% load static %}
{% if preview_images_enabled is True %}
<meta name="twitter:card" content="summary_large_image">
{% if image %}
<meta name="twitter:image" content="{{ media_full_url }}{{ image }}">
<meta name="og:image" content="{{ media_full_url }}{{ image }}">
@ -9,6 +10,15 @@
<meta name="og:image" content="{{ media_full_url }}{{ site.preview_image }}">
{% endif %}
{% else %}
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="{% if site.logo %}{{ media_full_url }}{{ site.logo }}{% else %}{% static "images/logo.png" %}{% endif %}">
<meta name="og:image" content="{% if site.logo %}{{ media_full_url }}{{ site.logo }}{% else %}{% static "images/logo.png" %}{% endif %}">
{% endif %}
<meta name="twitter:image:alt" content="BookWyrm Logo">
<meta name="twitter:title" content="{% if title %}{{ title }} - {% endif %}{{ site.name }}">
<meta name="og:title" content="{% if title %}{{ title }} - {% endif %}{{ site.name }}">
<meta name="twitter:description" content="{% if description %}{{ description }}{% else %}{{ site.instance_tagline }}{% endif %}">
<meta name="og:description" content="{% if description %}{{ description }}{% else %}{{ site.instance_tagline }}{% endif %}">

View file

@ -8,8 +8,8 @@
{% block title %}{{ user.display_name }}{% endblock %}
{% block opengraph_images %}
{% include 'snippets/opengraph_images.html' with image=user.preview_image %}
{% block opengraph %}
{% include 'snippets/opengraph.html' with image=user.preview_image %}
{% endblock %}
{% block content %}