Derive body class for pages

This commit is contained in:
Jake Howard 2022-06-10 15:54:31 +01:00
parent 3986b30a64
commit 82f3163ff5
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 11 additions and 7 deletions

View file

@ -5,9 +5,7 @@
<head>
<meta charset="utf-8" />
<title>
{% block title %}
{% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %}
{% endblock %}
{% block title %}{% endblock %}
{% block title_suffix %}
{% wagtail_site as current_site %}
{% if current_site and current_site.site_name %}:: {{ current_site.site_name }}{% endif %}

View file

@ -0,0 +1,5 @@
{% extends "base.html" %}
{% block body_class %}{{ page.body_class }}{% endblock %}
{% block title %}{% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %}{% endblock %}

View file

@ -6,3 +6,7 @@ from wagtail.models import Page
class BasePage(Page):
class Meta:
abstract = True
@property
def body_class(self):
return "page-" + self._meta.db_table.replace("_", "-")

View file

@ -1,7 +1,4 @@
{% extends "base.html" %}
{% load static %}
{% block body_class %}template-homepage{% endblock %}
{% extends "wagtail_base.html" %}
{% block content %}