Add opengraph #30

Merged
thisfro merged 1 commit from dev into main 2023-11-06 17:44:09 +01:00
2 changed files with 7 additions and 1 deletions

View file

@ -6,6 +6,11 @@
<meta name="description"
content="{{ offer.user.username }} offers {{ offer.title }}!">
<meta name="author" content="{{ offer.user.username }}">
<meta property="og:title" content="{{ offer.title }}">
<meta property="og:description"
content="{{ offer.user.username }} offers {{ offer.title }}!">
<meta property="og:url" content="{{ host }}/offer/{{ offer.id }}">
<meta property="og:image" content="{{ host }}{{ offer.image.url }}">
{% endblock %}
{% block content %}
{% if offer.user == request.user %}

View file

@ -53,6 +53,7 @@ def create_offer(request):
def offer_detail(request, offer_id):
offer = get_object_or_404(Offer, id=offer_id)
wishes = Wish.objects.filter(user=offer.user)
host = f"{request.scheme}://{request.META.get('HTTP_HOST')}"
if request.user.is_authenticated:
if offer.zipcode and request.user.zipcode:
@ -68,7 +69,7 @@ def offer_detail(request, offer_id):
else:
dist = None
return render(request, "offer/detail.html", {"offer": offer, "wishes": wishes, "dist": dist})
return render(request, "offer/detail.html", {"host": host, "offer": offer, "wishes": wishes, "dist": dist})
@login_required