Skip to content

Commit

Permalink
👌 [#1750] PR feedback
Browse files Browse the repository at this point in the history
* Add extra meta tags for sharing (description, image, page and type)
  • Loading branch information
stevenbal committed Oct 2, 2023
1 parent e12880c commit c901ddb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/open_inwoner/pdc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def crumbs(self):
def get_context_data(self, **kwargs):
product = self.get_object()
context = super().get_context_data(**kwargs)
request = context["view"].request

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

Expand All @@ -217,6 +218,9 @@ def get_context_data(self, **kwargs):
anchors.append(("#contact", _("Contact")))

context["meta_description"] = product.summary
if product.icon:
context["meta_image_url"] = request.build_absolute_uri(product.icon.url)
context["meta_page_url"] = request.build_absolute_uri(request.path)
context["anchors"] = anchors
context["related_products_start"] = 6 if product.links.exists() else 1
context["product_links"] = product.links.order_by("pk")
Expand Down
10 changes: 10 additions & 0 deletions src/open_inwoner/templates/master.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
{% if meta_description %}
<meta property="og:description" content="{{ meta_description }}">
<meta name="twitter:description" content="{{ meta_description }}">
<meta name="description" content="{{ meta_description }}"/>
{% endif %}
{% if meta_image_url %}
<meta property="og:image" content="{{ meta_image_url }}">
<meta name="twitter:image" content="{{ meta_image_url }}">
{% endif %}
{% if meta_page_url %}
<meta property="og:url" content="{{ meta_page_url }}">
{% endif %}
<meta property="og:type" content="article">


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

0 comments on commit c901ddb

Please sign in to comment.