Skip to content
Snippets Groups Projects
Commit b3b0f5a4 authored by alexisben's avatar alexisben
Browse files

fix page toc

parent 399c8b2d
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@
.posts-navigation
border-top: 1px solid $color-border
margin-top: $spacing3
margin-bottom: $spacing4
padding-bottom: $spacing4
ul
@include list-reset
display: flex
......
......@@ -5,13 +5,35 @@
{{/* TOC PART */}}
{{- $category := site.GetPage (printf "/categories%s" .Params.category) -}}
{{- if .Params.blocks }}
{{ $need_aside := false }}
{{ range .Params.blocks }}
{{ if .title }}
{{ $need_aside = true }}
{{ end }}
{{ end }}
{{- $show_aside := false -}}
{{- $has_blocks := false -}}
{{- range .Params.blocks -}}
{{- $has_blocks = true -}}
{{- if .title -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{- if .Pages -}}
{{- if eq $has_blocks false -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{- if .Content -}}
{{- if eq $has_blocks false -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{- if $category -}}
{{- if eq $has_blocks false -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{- if $show_aside }}
{{ partial "toc/container.html"
(dict
"category" $category
......
{{- $show_aside := false -}}
<nav class="toc toc-pages" id="nav-toc" aria-labelledby="toc-title">
<ol>
{{- $has_blocks := false -}}
{{- range .context.Params.blocks -}}
{{- $has_blocks = true -}}
{{- if .title -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{- if .context.Params.blocks -}}
{{- if .context.Pages -}}
{{- if eq $has_blocks false -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{- partial "blocks/toc.html" .context.Params.blocks -}}
{{- if .context.Content -}}
{{- if eq $has_blocks false -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- if .category -}}
{{- if eq $has_blocks false -}}
{{- $show_aside = true -}}
{{- end -}}
{{- end -}}
{{/* TODO: Delete it */}}
{{ $h2s := partial "H2Extract" .context.Content }}
{{- if and (not $h2s) (partial "GetTextFromHTML" .context.Content) }}
<li>
<a href="#page-informations">{{ i18n "pages.informations" }}</a>
</li>
{{ end -}}
{{- if $show_aside }}
<nav class="toc toc-pages" id="nav-toc" aria-labelledby="toc-title">
<ol>
{{- range $index, $h2 := $h2s }}
<li>
<a href="#page-h2-{{$index}}">{{ plainify $h2 }}</a>
</li>
{{ end -}}
{{- if .context.Params.blocks -}}
{{- if .context.Pages }}
<li>
<a href="#page-children">{{ i18n "pages.details" }}</a>
</li>
{{ end -}}
{{- partial "blocks/toc.html" .context.Params.blocks -}}
{{- if .category.Pages }}
<li>
<a href="#page-posts">{{ i18n "pages.posts" }}</a>
</li>
{{ end -}}
{{- else -}}
{{/* TODO: Delete it */}}
{{ $h2s := partial "H2Extract" .context.Content }}
{{- if and (not $h2s) (partial "GetTextFromHTML" .context.Content) }}
<li>
<a href="#page-informations">{{ i18n "pages.informations" }}</a>
</li>
{{ end -}}
{{- range $index, $h2 := $h2s }}
<li>
<a href="#page-h2-{{$index}}">{{ plainify $h2 }}</a>
</li>
{{ end -}}
{{- if .context.Pages }}
<li>
<a href="#page-children">{{ i18n "pages.details" }}</a>
</li>
{{ end -}}
{{- if .category.Pages }}
<li>
<a href="#page-posts">{{ i18n "pages.posts" }}</a>
</li>
{{ end -}}
{{- end -}}
</ol>
</nav>
{{ end -}}
{{- end -}}
</ol>
</nav>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment