--- layout: base ---
{% comment %} Extract the path of this series. {% endcomment %} {% assign thisSeriesPath = page.path | remove: '/index.md' | append: '/' %} {% comment %} Only select videos that are in this series. {% endcomment %} {% assign videos = site[page.collection] %} {% include 1-tools/sort-videos.html videos=videos seriesPage=page future=true %} {% assign sortedVideos = out_sortedVideos %} {% comment %} Remove series path from video path. {% endcomment %} {% assign videoPathWithoutSeries = sortedVideos[0].path | remove: thisSeriesPath %} {% comment %} If the video path contains at least one '/' {% endcomment %} {% if videoPathWithoutSeries contains '/' %} {% assign hasMultipleSeries = true %} {% endif %} {% comment %} Show the page's subtitle. {% endcomment %}
{% comment %} Show current series with its number if the page only displays a list of videos. {% endcomment %} {% unless hasMultipleSeries %} {% include 1-tools/series-for-video.html video=page %} {% if page.series_number %} {{ out_series.title }} {{ page.video_type }} #{{ page.series_number }}{% if page.subtitle %}:{% endif %} {% endif %} {% endunless %} {{ page.subtitle | xml_escape }}
{% comment %} Show the series description. {% endcomment %}
{{ content }}
{% comment %} This page displays a list of other series. {% endcomment %} {% if hasMultipleSeries %} {% comment %} Get the ID of all series in this collection. {% endcomment %} {% assign seriesIndexPages = videos | where: 'layout', 'series-index' | where_exp: 'seriesIndex', 'seriesIndex.path != page.path' | sort: 'series_number' %} {% comment %} Show the first three videos for every series ... {% endcomment %} {% for seriesIndexPage in seriesIndexPages %} {% comment %} Only if the series is a direct children to this series. {% endcomment %} {% comment %} ...by comparing the path of the index.md and the path of the series{% endcomment %} {% assign seriesIndexPagePath = seriesIndexPage.path | remove: '/index.md' | split: '/' | pop | join: '/' | append: '/'%} {% if thisSeriesPath == seriesIndexPagePath %} {% comment %} Display title, description and videos. {% endcomment %}

{% if seriesIndexPage.series_number %}{{ seriesIndexPage.video_type }} #{{ seriesIndexPage.series_number }}: {% endif %}{{ seriesIndexPage.title }}

{{ seriesIndexPage.subtitle }}
{{ seriesIndexPage.excerpt }}
{% include 3-modules/video-list.html videos=sortedVideos seriesPage=seriesIndexPage limit=3 reverse=seriesIndexPage.reverse future=true %}
{% endif %} {% endfor %} {% comment %} This page displays a list of videos. {% endcomment %} {% else %} {% comment %} Display all videos. {% endcomment %} {% include 3-modules/video-list.html sortedVideos=sortedVideos reverse=page.reverse future=true %} {% endif %}