mirror of
				https://github.com/ItsDrike/itsdrike.com.git
				synced 2025-11-04 04:06:36 +00:00 
			
		
		
		
	Only show headers when there are 4 or more of them
This commit is contained in:
		
							parent
							
								
									381bb3e60d
								
							
						
					
					
						commit
						60849fcdc6
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -12,9 +12,13 @@
 | 
			
		|||
 | 
			
		||||
  <div class="content mt-3">
 | 
			
		||||
    {{ if .TableOfContents }}
 | 
			
		||||
      <div class="float-lg-end ml-lg-3 mb-3 p-3">
 | 
			
		||||
        {{ .TableOfContents }}
 | 
			
		||||
      </div>
 | 
			
		||||
      <!-- Get the amount of headers using regex -->
 | 
			
		||||
      {{ $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content }}
 | 
			
		||||
      {{ if ge (len $headers) 4 }}
 | 
			
		||||
        <div class="float-lg-end ml-lg-3 mb-3 p-3">
 | 
			
		||||
          {{ .TableOfContents }}
 | 
			
		||||
        </div>
 | 
			
		||||
      {{ end }}
 | 
			
		||||
    {{ end }}
 | 
			
		||||
    {{ .Content }}
 | 
			
		||||
  </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue