Remove section wrapper from page if no sidebars

This commit is contained in:
benjamin melançon 2018-10-17 17:49:11 -04:00
parent ac3fe87aa1
commit 41ae557063

View file

@ -74,3 +74,80 @@
{% endblock tabs %}
</section>
{% endblock header %}
{% block main %}
{# Main section #}
{# Only group the main content into one wrapping element if it needs to be
separated from a sidebar or two. #}
{% if page.sidebar_first or page.sidebar_second %}
<section class="section">
<main role="main" class="container">
{% endif %}
<a id="main-content" tabindex="-1"></a>{# link is in html.html.twig #}
{{ page.highlighted }}
{{ page.help }}
{% block main_content %}
{# Set attributes for content. #}
{% if not page.content_attributes %}
{%
set page = page|merge({
'content_attributes': create_attribute().addClass([
'main-content',
'column',
]),
})
%}
{% endif %}
{# Main content #}
<div{{page.content_attributes}}>
{{ page.content }}
</div>
{% endblock main_content %}
{% block sidebar_first %}
{# Sidebar first #}
{% if page.sidebar_first %}
{# Set attributes for content. #}
{% if not page.sidebar_first_attributes %}
{%
set page = page|merge({
'sidebar_first_attributes': create_attribute().addClass([
'sidebar-first',
'column',
'is-2',
]),
})
%}
{% endif %}
<aside{{page.sidebar_first_attributes|without('role')}} role="complimentary">
{{ page.sidebar_first }}
</aside>
{% endif %}
{% endblock sidebar_first %}
{% block sidebar_second %}
{# Sidebar second #}
{% if page.sidebar_second %}
{% if not page.sidebar_second_attributes %}
{%
set page = page|merge({
'sidebar_second_attributes': create_attribute().addClass([
'sidebar-second',
'column',
'is-2',
]),
})
%}
{% endif %}
<aside{{page.sidebar_second_attributes|without('role')}} role="complimentary">
{{ page.sidebar_second }}
</aside>
{% endif %}
{% endblock sidebar_second %}
{% if page.sidebar_first or page.sidebar_second %}
</main>
</section>
{% endif %}
{% endblock main %}