{{ define "title" }}{{ .Title }} :: {{ .Site.Title }}{{ end }}

{{ define "main" }}
	{{ $episodes := .Params.episodes }}
	{{ $episodeCount := len $episodes }}
	{{ $episodeIndex := .Params.index }}
	{{ $gameplayPage := .Parent }}
	<nav class="submenu box">
		<h2>Bereiche:</h2>
		<ul>
			{{ range .Parent.Parent.Pages }}
				{{ if .Eq $gameplayPage }}
					<li class="active">
				{{ else }}
					<li>
				{{ end }}
					<a href="{{ .RelPermalink }}">{{ .Title }}</a>
				</li>
			{{ end }}
		</ul>
	</nav>
	<h1>{{ .Params.gameplay }}</h1>
	{{ if .Params.name }}
		<h2>{{ .Params.name }}</h2>
	{{ end }}
	<p>{{ .Description }}</p>
	<p><video src="{{ .Params.video }}" type="video/mp4" playsinline controls style="width:100%; aspect-ratio:16 / 9; display:block;"></video></p>
	{{ if gt $episodeCount 1 }}
		<div class="box videos">
			{{ range $index, $episode := $episodes }}
				{{ $episodeNum := math.Add $index 1 }}
				{{ $isCurrent := eq $index $episodeIndex }}
				{{ if eq $index 0 }}
					{{ if $isCurrent }}
						<div class="active">
					{{ else }}
						<div>
					{{ end }}
						<a href="../">Folge 01 – {{ $episode.title }}</a>
					</div>
				{{ else }}
					{{ if $isCurrent }}
						<div class="active">
					{{ else }}
						<div>
					{{ end }}
						<a href="../{{ $episodeNum }}/">Folge {{ printf "%02d" $episodeNum }} – {{ $episode.title }}</a>
					</div>
				{{ end }}
			{{ end }}
		</div>
	{{ end }}
	{{ .Content }}
{{ end }}