Commit c2c1a468 authored by Kaushal Modi's avatar Kaushal Modi

Link to the series landing page if it has non-empty content

.. Like an _index.md with some content in there.
parent e92e4868
......@@ -14,19 +14,29 @@
{{ $this_page_permalink := .Permalink }}
{{ range .Params.series }}
{{ $series_name := . }}
{{ $series_name_urlized := (. | urlize) }}
{{ $series_page := ($.Site.GetPage (printf "/series/%s" $series_name_urlized)) }}
{{ $series_page_empty_content := (eq "" ($series_page.Content | replaceRE "[[:^alpha:]]" "")) }}
<!--
$.Site.Taxonomies.series then is a map with key = "urlized value
of the series name", and value = WeightedPages object. The
WeightedPages object holds a list of WeightedPage objects.
-->
{{ with $.Site.Taxonomies.series }}
{{ $weighted_pages := index . ($series_name | urlize) }}
{{ $weighted_pages := index . $series_name_urlized }}
<!-- It does not make sense to show the "series block" if that series has just one post. -->
{{ if (or (ge $weighted_pages.Count 2) $.Site.Data.series.todo) }}
<div class="series">
<p>
<a href="#" id="series"></a>
This is a post in the “<b class="p-category">{{ $series_name }}</b>” series.
This is a post in the
{{ if $series_page_empty_content }}
<b class="p-category">{{ $series_name }}</b>
{{ else }}
<!-- Link to the series landing page only if it has non-empty .Content. -->
<a href="{{ $series_page.Permalink }}"><b class="p-category">{{ $series_name }}</b></a>
{{ end }}
series.
</p>
<table>
<!-- Calling .Pages function on the WeightedPages object will return all the nested pages. -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment