mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-30 19:35:26 +01:00 
			
		
		
		
	Never display the ToC when it would be empty (#532)
This commit is contained in:
		| @@ -1,13 +1,13 @@ | ||||
| {{- $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content -}} | ||||
| {{- $has_headers := ge (len $headers) 1 -}} | ||||
| {{- if $has_headers -}} | ||||
| <div class="toc"> | ||||
|     <details {{if (.Param "TocOpen") }} open{{ end }}> | ||||
|         <summary accesskey="c" title="(Alt + C)"> | ||||
|             <div class="details">{{- i18n "toc" | default "Table of Contents" }}</div> | ||||
|         </summary> | ||||
|         <div class="inner"> | ||||
|             {{- $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content -}} | ||||
|             {{- $has_headers := ge (len $headers) 1 -}} | ||||
|             {{- if $has_headers -}} | ||||
|  | ||||
|         <div class="inner"> | ||||
|             {{- $largest := 6 -}} | ||||
|             {{- range $headers -}} | ||||
|             {{- $headerLevel := index (findRE "[1-6]" . 1) 0 -}} | ||||
| @@ -87,7 +87,7 @@ | ||||
|             {{- end -}} | ||||
|             {{- end }} | ||||
|             </ul> | ||||
|             {{- end }} | ||||
|         </div> | ||||
|     </details> | ||||
| </div> | ||||
| {{- end }} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Clément Joly
					Clément Joly