Break section template into first and descendent sections
First section templates render the most recent $n yearly subsections as a list of articles. Descendent sections render just the content of those subsections.
This commit is contained in:
		
							parent
							
								
									50dc3c45c1
								
							
						
					
					
						commit
						59ff58e159
					
				
					 6 changed files with 81 additions and 26 deletions
				
			
		|  | @ -6,3 +6,9 @@ draftNo: "NO" | |||
| 
 | ||||
| home: Home | ||||
| tableOfContents: Table of Contents | ||||
| 
 | ||||
| # Title of section of a list page where years older than | ||||
| # .Site.Params.blog.yearLimit are collapsed into a bulleted list. | ||||
| olderPagesSectionTitle: Older | ||||
| 
 | ||||
| yearsTagTitle: Years | ||||
|  |  | |||
|  | @ -1,13 +1,7 @@ | |||
| {{ define "main" }} | ||||
|   <main class="main--list"> | ||||
|     <header class="page-header"> | ||||
|       {{ partial "page_header.html" (dict "page" .) }} | ||||
|     </header> | ||||
| 
 | ||||
|     {{- .Content -}} | ||||
| 
 | ||||
|     {{- range .Pages.ByTitle -}} | ||||
|       {{ .Render "page_summary" }} | ||||
|     {{- end -}} | ||||
|   </main> | ||||
|   {{ if eq . .FirstSection }} | ||||
|     {{ partial "page/first_section.list.html" . }} | ||||
|   {{ else }} | ||||
|     {{ partial "page/descendent_section.list.html" . }} | ||||
|   {{ end }} | ||||
| {{ end }} | ||||
|  |  | |||
|  | @ -1,17 +1,7 @@ | |||
| {{ define "main" }} | ||||
|   <main class="main--list"> | ||||
|     <header class="page-header"> | ||||
|       {{ partial "page_header.html" (dict "page" .) }} | ||||
|     </header> | ||||
| 
 | ||||
|     {{- with .Content }} | ||||
|     <div class="main__content">{{ . }}</div> | ||||
|     {{ end -}} | ||||
| 
 | ||||
|     {{ range .Pages.ByDate.Reverse -}} | ||||
|       {{ if or (not .Draft) hugo.IsDevelopment }} | ||||
|         {{ .Render "page_summary" }} | ||||
|       {{ end }} | ||||
|     {{- end }} | ||||
|   </main> | ||||
|   {{ if eq . .FirstSection }} | ||||
|     {{ partial "page/first_section.list.html" . }} | ||||
|   {{ else }} | ||||
|     {{ partial "page/descendent_section.list.html" . }} | ||||
|   {{ end }} | ||||
| {{ end }} | ||||
|  |  | |||
							
								
								
									
										13
									
								
								layouts/partials/page/descendent_section.list.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								layouts/partials/page/descendent_section.list.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| <main class="main--list"> | ||||
|   <header class="page-header"> | ||||
|     {{ partial "page_header.html" (dict "page" .) }} | ||||
|   </header> | ||||
| 
 | ||||
|   {{- .Content -}} | ||||
| 
 | ||||
|   {{ range .RegularPages.ByPublishDate -}} | ||||
|     {{ if or (not .Draft) hugo.IsDevelopment -}} | ||||
|       {{ .Render "page_summary" }} | ||||
|     {{ end }} | ||||
|   {{ end }} | ||||
| </main> | ||||
							
								
								
									
										39
									
								
								layouts/partials/page/first_section.list.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								layouts/partials/page/first_section.list.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| <main class="main--list"> | ||||
|   <header class="page-header"> | ||||
|     {{ partial "page_header.html" (dict "page" .) }} | ||||
|   </header> | ||||
| 
 | ||||
|   {{/* Each page is a year section. */}} | ||||
|   {{- $yearPages := .Pages.ByPublishDate.Reverse -}} | ||||
|   {{- $yearLimit := math.Max ($.Site.Params.blog.yearLimit | default 5) 3 -}} | ||||
|   {{- $expandedYears := first $yearLimit $yearPages -}} | ||||
|   {{- $collapsedYears := after $yearLimit $yearPages -}} | ||||
| 
 | ||||
|   {{- | ||||
|     partial "page/section_year_nav.html" | ||||
|       (dict | ||||
|         "years" $expandedYears | ||||
|         "includeCollapsedYearItem" (gt (len $collapsedYears) 0) | ||||
|       ) | ||||
|   -}} | ||||
| 
 | ||||
|   {{- .Content -}} | ||||
| 
 | ||||
|   {{ range $expandedYears -}} | ||||
|     <h2 id="{{ .Date | time.Format "2006" }}">{{ .Title }}</h2> | ||||
|     {{ range .RegularPagesRecursive.ByPublishDate.Reverse -}} | ||||
|       {{ if or (not .Draft) hugo.IsDevelopment -}} | ||||
|         {{ .Render "page_summary" }} | ||||
|       {{ end }} | ||||
|     {{ end }} | ||||
|   {{- end }} | ||||
| 
 | ||||
|   {{ with $collapsedYears -}} | ||||
|     <h2 id="older">{{ i18n "olderPagesSectionTitle" }}</h2> | ||||
|     <ul> | ||||
|       {{ range . -}} | ||||
|         <li><a href="{{ .Permalink }}">{{ .LinkTitle | markdownify }}</a></li> | ||||
|       {{ end }} | ||||
|     </ul> | ||||
|   {{ end }} | ||||
| </main> | ||||
							
								
								
									
										13
									
								
								layouts/partials/page/section_year_nav.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								layouts/partials/page/section_year_nav.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| {{- $years := .years -}} | ||||
| {{- $includeCollapsedYearItem := .includeCollapsedYearItem -}} | ||||
| <nav class="year-nav  tag"> | ||||
|   <span class="tag__name">{{ i18n "yearsTagTitle" }}</span> | ||||
|   <ul class="tag__value--list"> | ||||
|     {{ range $years -}} | ||||
|       <li class="tag__value__list-item"><a href="#{{ .Date | time.Format "2006" }}">{{ .LinkTitle }}</a></li> | ||||
|     {{ end }} | ||||
|     {{ if $includeCollapsedYearItem -}} | ||||
|       <li class="tag__value__list-item"><a href="#older">{{ i18n "olderPagesSectionTitle" }}</a></li> | ||||
|     {{ end }} | ||||
|   </ul> | ||||
| </nav> | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue