Add a table of contents
Create a new table_of_contents partial that includes an auto-generated table of contents if the word count is over 400 and the "toc" page variable has been set true.
This commit is contained in:
		
							parent
							
								
									6eeeb11ab4
								
							
						
					
					
						commit
						f21ac49b08
					
				
					 3 changed files with 11 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -7,6 +7,8 @@
 | 
			
		|||
  <h1>{{ .Title }}</h1>
 | 
			
		||||
</header>
 | 
			
		||||
 | 
			
		||||
{{ partial "table_of_contents.html" . }}
 | 
			
		||||
 | 
			
		||||
{{- $hasContent := false -}}
 | 
			
		||||
{{ with .Content }}
 | 
			
		||||
  {{- $hasContent = true -}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,7 @@
 | 
			
		|||
          {{- $focalLength := .Tags.FocalLengthIn35mmFilm | default .Tags.FocalLength -}}
 | 
			
		||||
          {{- with $focalLength -}}{{ . }} mm{{- end -}}
 | 
			
		||||
        </td>
 | 
			
		||||
        <td class="f-number">{{ with .Tags.FNumber }}ƒ{{ . }}{{ end }}</td>
 | 
			
		||||
        <td class="f-number">{{ with .Tags.FNumber }}{{ printf "ƒ%0.1f" . }}{{ end }}</td>
 | 
			
		||||
        <td class="exposure-time">
 | 
			
		||||
          {{- with $exposureTime := .Tags.ExposureTime -}}
 | 
			
		||||
            {{- if in $exposureTime "/" -}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								layouts/partials/table_of_contents.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								layouts/partials/table_of_contents.html
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
{{ if and (gt .WordCount 400) .Params.toc }}
 | 
			
		||||
<aside>
 | 
			
		||||
  <details open>
 | 
			
		||||
    <summary>Table of Contents</summary>
 | 
			
		||||
    {{ .TableOfContents }}
 | 
			
		||||
  </details>
 | 
			
		||||
</aside>
 | 
			
		||||
{{ end }}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue