From a5372e1238b26e3254e57a7d0d373327ffd6d319 Mon Sep 17 00:00:00 2001 From: Konstantin Kostov Date: Thu, 11 Apr 2024 11:19:51 +0200 Subject: [PATCH] improve structured SEO data, v39 --- Makefile | 2 +- blog/models.py | 15 +++++++++++++++ home/models.py | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1eae5ad..4cef8a5 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: help build publish -VERSION = 1.0.38 +VERSION = 1.0.39 help: @perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/blog/models.py b/blog/models.py index 34dedbc..c0279c0 100644 --- a/blog/models.py +++ b/blog/models.py @@ -1,3 +1,5 @@ +from typing import Optional + from django import forms from django.db import models from modelcluster.fields import ParentalKey, ParentalManyToManyField @@ -95,6 +97,19 @@ class BlogPage(SeoMixin, Page): promote_panels = SeoMixin.seo_panels seo_content_type = SeoType.ARTICLE + @property + def seo_author(self) -> str: + return ', '.join([author.name for author in self.authors.all()]) + + @property + def seo_canonical_url(self) -> str: + # replace http:// with https:// + return super().seo_canonical_url.replace('http://', 'https://') + + @property + def seo_struct_publisher_dict(self) -> Optional[dict]: + return None + class BlogPageGalleryImage(Orderable): page = ParentalKey(BlogPage, on_delete=models.CASCADE, related_name='gallery_images') diff --git a/home/models.py b/home/models.py index cab0e1d..34d4bb1 100644 --- a/home/models.py +++ b/home/models.py @@ -3,7 +3,7 @@ from django.db import models from wagtail.models import Page from wagtail.fields import RichTextField, StreamField from wagtail.admin.panels import FieldPanel, MultiFieldPanel -from wagtailseo.models import SeoMixin +from wagtailseo.models import SeoMixin, SeoType from .blocks import HomeContentBlock @@ -56,3 +56,4 @@ class HomePage(SeoMixin, Page): ] promote_panels = SeoMixin.seo_panels + seo_content_type = SeoType.WEBSITE