Skip to content

Commit 2288fba

Browse files
committed
👌 [#1750] PR feedback
* Add extra meta tags for sharing (description, image, page and type)
1 parent e12880c commit 2288fba

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/open_inwoner/pdc/views.py

+3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def crumbs(self):
201201
def get_context_data(self, **kwargs):
202202
product = self.get_object()
203203
context = super().get_context_data(**kwargs)
204+
request = context["view"].request
204205

205206
subheadings = extract_subheadings(product.content, tag="h2")
206207

@@ -217,6 +218,8 @@ def get_context_data(self, **kwargs):
217218
anchors.append(("#contact", _("Contact")))
218219

219220
context["meta_description"] = product.summary
221+
context["meta_image_url"] = request.build_absolute_uri(product.icon.url)
222+
context["meta_page_url"] = request.build_absolute_uri(request.path)
220223
context["anchors"] = anchors
221224
context["related_products_start"] = 6 if product.links.exists() else 1
222225
context["product_links"] = product.links.order_by("pk")

src/open_inwoner/templates/master.html

+10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@
1010
{% if meta_description %}
1111
<meta property="og:description" content="{{ meta_description }}">
1212
<meta name="twitter:description" content="{{ meta_description }}">
13+
<meta name="description" content="{{ meta_description }}"/>
1314
{% endif %}
15+
{% if meta_image_url %}
16+
<meta property="og:image" content="{{ meta_image_url }}">
17+
<meta name="twitter:image" content="{{ meta_image_url }}">
18+
{% endif %}
19+
{% if meta_page_url %}
20+
<meta property="og:url" content="{{ meta_page_url }}">
21+
{% endif %}
22+
<meta property="og:type" content="article">
23+
1424

1525
{% if favicon %}<link rel="icon" href="{{ favicon }}" />
1626
<link rel="apple-touch-icon" href="{{ favicon }}">{% endif %}

0 commit comments

Comments
 (0)