Fix page heading semantics and localized metadata
This commit is contained in:
@@ -50,7 +50,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<main class="te-section">
|
<main class="te-section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
{% if self.body.0.block_type != "saas_hero_banner" %}
|
||||||
<h1 class="te-section__heading">{{ self.title }}</h1>
|
<h1 class="te-section__heading">{{ self.title }}</h1>
|
||||||
|
{% endif %}
|
||||||
{% for block in self.body %}
|
{% for block in self.body %}
|
||||||
{% with scope_class=block.block_type|split:"_"|join:"-" %}
|
{% with scope_class=block.block_type|split:"_"|join:"-" %}
|
||||||
<section class="te-block te-block--{{ scope_class }}" data-block-type="{{ block.block_type }}">
|
<section class="te-block te-block--{{ scope_class }}" data-block-type="{{ block.block_type }}">
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
{% load ocyan_main %}
|
{% load ocyan_main %}
|
||||||
{% load ocyanjson %}
|
{% load ocyanjson %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load localized_navigation %}
|
||||||
{% load wagtailcore_tags wagtailimages_tags wagtailuserbar %}
|
{% load wagtailcore_tags wagtailimages_tags wagtailuserbar %}
|
||||||
|
|
||||||
{% block title %}{% firstof page.seo_title self.seo_title page.title self.title shop_name %}{% endblock %}
|
{% block title %}{% firstof page.seo_title self.seo_title page.title self.title shop_name %}{% endblock %}
|
||||||
@@ -26,12 +27,23 @@
|
|||||||
<link rel="preconnect" href="https://www.google-analytics.com/">
|
<link rel="preconnect" href="https://www.google-analytics.com/">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
{% page_canonical_url as canonical_url %}
|
||||||
|
{% if canonical_url %}
|
||||||
|
<link rel="canonical" href="{{ canonical_url }}">
|
||||||
|
{% endif %}
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'cookie_jar/css/cookie_jar.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'cookie_jar/css/cookie_jar.css' %}">
|
||||||
{% for header_snippet in cookie_jar.activated_snippet_header_templates %}
|
{% for header_snippet in cookie_jar.activated_snippet_header_templates %}
|
||||||
{% include header_snippet %}
|
{% include header_snippet %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block hreflang %}
|
||||||
|
{% page_hreflang_links as hreflang_links %}
|
||||||
|
{% for link in hreflang_links %}
|
||||||
|
<link rel="alternate" hreflang="{{ link.code }}" href="{{ link.url }}">
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block layout %}
|
{% block layout %}
|
||||||
{% if show_basket_popup_setting %}
|
{% if show_basket_popup_setting %}
|
||||||
{% esi_fragment "partials/added_success.html" with sessionid=True oscar_open_basket=True request=request csrf_token=csrf_token only %}
|
{% esi_fragment "partials/added_success.html" with sessionid=True oscar_open_basket=True request=request csrf_token=csrf_token only %}
|
||||||
|
|||||||
60
mandelstudio/tests/test_localized_navigation_tags.py
Normal file
60
mandelstudio/tests/test_localized_navigation_tags.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
from types import SimpleNamespace
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
|
from django.test import RequestFactory, SimpleTestCase, override_settings
|
||||||
|
|
||||||
|
from mandelstudio.templatetags import localized_navigation
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(
|
||||||
|
CANONICAL_BASE_URL="https://www.mandelblog.com",
|
||||||
|
LANGUAGE_CODE="nl",
|
||||||
|
LANGUAGES=(
|
||||||
|
("nl", "Dutch"),
|
||||||
|
("en", "English"),
|
||||||
|
("de", "German"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
class LocalizedNavigationTagTests(SimpleTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
|
||||||
|
def test_page_canonical_url_uses_canonical_host_and_page_url(self):
|
||||||
|
request = self.factory.get("/en/contact/")
|
||||||
|
page = SimpleNamespace(url="/en/contact/")
|
||||||
|
|
||||||
|
canonical = localized_navigation.page_canonical_url(
|
||||||
|
{"request": request, "page": page}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(canonical, "https://www.mandelblog.com/en/contact/")
|
||||||
|
|
||||||
|
@mock.patch(
|
||||||
|
"mandelstudio.templatetags.localized_navigation._translated_pages"
|
||||||
|
)
|
||||||
|
def test_page_hreflang_links_only_include_live_public_translations(
|
||||||
|
self, translated_pages_mock
|
||||||
|
):
|
||||||
|
request = self.factory.get("/en/contact/")
|
||||||
|
current_page = SimpleNamespace(
|
||||||
|
translation_key="key",
|
||||||
|
locale=SimpleNamespace(language_code="en"),
|
||||||
|
url="/en/contact/",
|
||||||
|
)
|
||||||
|
translated_pages_mock.return_value = {
|
||||||
|
"nl": SimpleNamespace(url="/contact/", locale=SimpleNamespace(language_code="nl")),
|
||||||
|
"en": SimpleNamespace(url="/en/contact/", locale=SimpleNamespace(language_code="en")),
|
||||||
|
}
|
||||||
|
|
||||||
|
links = localized_navigation.page_hreflang_links(
|
||||||
|
{"request": request, "page": current_page}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
links,
|
||||||
|
[
|
||||||
|
{"code": "nl", "url": "https://www.mandelblog.com/contact/"},
|
||||||
|
{"code": "en", "url": "https://www.mandelblog.com/en/contact/"},
|
||||||
|
{"code": "x-default", "url": "https://www.mandelblog.com/contact/"},
|
||||||
|
],
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user