Add SEO title, desc, author to library pages

This commit is contained in:
Lacey Williams Henschel
2023-09-11 15:26:37 -07:00
parent 2d9fb17e4b
commit fcc6afb4bd
6 changed files with 27 additions and 4 deletions

View File

@@ -159,6 +159,7 @@ class LibraryDetail(FormMixin, DetailView):
context["documentation_url"] = self.get_documentation_url(context["version"])
context["github_url"] = self.get_github_url(context["version"])
context["maintainers"] = self.get_maintainers(context["version"])
context["author_tag"] = self.get_author_tag()
# Populate the commit graphs
context["commit_data_annual"] = self.get_commit_data_annual()
@@ -190,6 +191,17 @@ class LibraryDetail(FormMixin, DetailView):
raise Http404("No library found matching the query")
return obj
def get_author_tag(self):
"""Format the authors for the author meta tag in the template."""
authors = self.object.authors.all()
author_names = [author.get_full_name() for author in authors]
if len(author_names) > 1:
final_output = ", ".join(author_names[:-1]) + " and " + author_names[-1]
else:
final_output = author_names[0] if author_names else ""
return final_output
def _prepare_commit_data(self, commit_data, data_type):
commit_data_list = []
for data in commit_data:

View File

@@ -28,7 +28,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="{% block description %}{% endblock %}" />
<meta name="keywords" content="{% block keywords %}{% endblock %}" />
<meta name="author" content="{% block author %}{% endblock %}" />
<meta name="author" content="{% block author %}Boost C++ Libraries{% endblock %}" />
<link rel="shortcut icon" href="{% static 'img/Boost_Symbol_Transparent.svg' %}" type="image/x-icon" />
<link href="{% static 'css/styles.css' %}" rel="stylesheet" />

View File

@@ -2,7 +2,9 @@
{% load i18n %}
{% load static %}
{% block title %}{% trans "Libraries by Category" %}{% endblock %}
{% block title %}{% trans "Boost Libraries by Category" %}{% endblock %}
{% block description %}{% trans "Browse Boost C++ Libraries by category and discover tools for multithreading, image processing, testing, and more." %}{% endblock %}
{% block content %}
<main class="content">

View File

@@ -1,5 +1,11 @@
{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% block title %}Boost.{{ object.name }} ({{ version.display_name }}){% endblock %}
{% block description %}{% trans object.description %}{% endblock %}
{% block author %}{{ author_tag }}{% endblock %}
{% block content %}
<main class="content">
<header class="py-0 px-0 mb-0 w-full md:mb-2 flex flex-row flex-nowrap items-center"

View File

@@ -2,7 +2,9 @@
{% load i18n %}
{% load static %}
{% block title %}{% trans "Libraries by Name" %}{% endblock %}
{% block title %}{% trans "Boost Libraries by Name" %}{% endblock %}
{% block description %}{% trans "Explore the Boost C++ Libraries and discover tools for multithreading, image processing, testing, and more." %}{% endblock %}
{% block content %}
<main class="content">

View File

@@ -2,7 +2,8 @@
{% load i18n %}
{% load static %}
{% block title %}{% trans "Libraries" %}{% endblock %}
{% block title %}{% trans "Boost Libraries" %}{% endblock %}
{% block description %}{% trans "Explore our comprehensive list of Boost C++ Libraries and discover tools for multithreading, image processing, testing, and more." %}{% endblock %}
{% block content %}
<main class="content">