{# ========================================================================== #}
{# :: Content #}
{# ========================================================================== #}
{#
	The content section of the page which contains the main title and the
	different content blocks.
#}

{# ========================================================================== #}
{# :: Imports #}
{# ========================================================================== #}
{% import "components/wysiwyg.njk" as wysiwyg %}
{% import "components/gallery.njk" as gallery %}
{% import "components/fallback.njk" as fallback %}
{% import "components/embed.njk" as embed %}
{% import "components/audio.njk" as audio %}
{% import "components/video.njk" as video %}
{% import "components/restricted.njk" as restricted %}

{# ========================================================================== #}
{# :: Variables #}
{# ========================================================================== #}
{% set TYPE = ROUTEDATA.TYPE %}
{% set TOPIC = ROUTEDATA.TOPIC %}
{% set PAGE = pageParams.id %}
{% set LANGUAGE = ROUTEDATA.LANGUAGE %}
{% set action = "/" + LANGUAGE + "/" + PAGE + "/" + TYPE + ("/" + TOPIC if TOPIC) %}
{% set ISAUNTHENTICATED = ROUTEDATA.ISAUTHENTICATED %}

{# ========================================================================== #}
{# :: Partial #}
{# ========================================================================== #}
{% if ROUTEDATA.DETAIL %}

	<section class="bp-l-section">
		<header class="bp-l-section__header">
			<h1 class="bp-l-section__title u-h1">{{ROUTEDATA.DETAIL.title}}</h1>
		</header>

		{% if ISAUNTHENTICATED %}

			{% for item in ROUTEDATA.DETAIL.body %}
				<div class="bp-l-section__content">
					{% if item.type === "text" %}

						{{wysiwyg.default("", {
							content: item.data.content
						})}}

					{% elseif item.type === "audio" %}

						{% include "partials/api/audio.njk" %}

					{% elseif item.type === "video" %}

						{% include "partials/api/videos.njk" %}

					{% elseif item.type === "colors" %}

						{% include "partials/api/colors.njk" %}

					{% elseif item.type === "embed" %}

						{% include "partials/api/embed.njk" %}

					{% elseif item.type === "images" %}

						{% include "partials/api/images.njk" %}

					{% elseif item.type === "files" %}

						{% include "partials/api/files.njk" %}

					{% endif %}
				</div>
			{% endfor %}

		{% else %}

			<div class="bp-l-section__content">
				{{restricted.default("", {
					title: "resources.restricted.title" | i18n,
					text: "resources.restricted.description" | i18n,
					url: action
				})}}
			</div>

		{% endif %}
	</section>

{% else %}

	{{fallback.default("", {
		text: "resources.fallback.description" | i18n
	})}}

{% endif %}
