add time to datePublished

This commit is contained in:
Tobias Brunner 2025-07-11 11:19:02 +02:00
parent c123e74c1f
commit 4bc6e7d354
No known key found for this signature in database

View file

@ -1,7 +1,9 @@
# hub/services/templatetags/json_ld_tags.py from datetime import datetime, time
from django import template from django import template
from django.urls import resolve, Resolver404 from django.urls import resolve, Resolver404
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils import timezone as django_timezone
import json import json
register = template.Library() register = template.Library()
@ -332,8 +334,10 @@ def json_ld_structured_data(context):
} }
# Add publication date using article_date field # Add publication date using article_date field
if article.article_date: article_datetime = django_timezone.make_aware(
data["datePublished"] = article.article_date.isoformat() datetime.combine(article.article_date, time.min)
)
data["datePublished"] = article_datetime.isoformat()
# Add modification date # Add modification date
if article.updated_at: if article.updated_at: