|
| 1 | +{{- define "main" }} |
| 2 | + |
| 3 | +{{- $headerImage := resources.Get "dahai.png" }} |
| 4 | +{{- if $headerImage }} |
| 5 | +<div class="home-header"> |
| 6 | + <img src="{{ $headerImage.RelPermalink }}" alt="Header image"> |
| 7 | +</div> |
| 8 | +{{- end }} |
| 9 | + |
| 10 | +{{- if site.Params.profileMode.enabled }} |
| 11 | +{{- partial "index_profile.html" . }} |
| 12 | +{{- else }} |
| 13 | + |
| 14 | +{{- if .Content }} |
| 15 | +<div class="post-content"> |
| 16 | + {{- if not (.Param "disableAnchoredHeadings") }} |
| 17 | + {{- partial "anchored_headings.html" .Content -}} |
| 18 | + {{- else }}{{ .Content }}{{ end }} |
| 19 | +</div> |
| 20 | +{{- end }} |
| 21 | + |
| 22 | +{{- $pages := where site.RegularPages "Type" "in" site.Params.mainSections }} |
| 23 | +{{- $pages = where $pages "Params.hiddenInHomeList" "!=" "true" }} |
| 24 | + |
| 25 | +{{- $paginator := .Paginate $pages }} |
| 26 | + |
| 27 | +{{- if and site.Params.homeInfoParams (eq $paginator.PageNumber 1) }} |
| 28 | +{{- partial "home_info.html" . }} |
| 29 | +{{- end }} |
| 30 | + |
| 31 | +{{- $term := .Data.Term }} |
| 32 | +{{- range $index, $page := $paginator.Pages }} |
| 33 | + |
| 34 | +{{- $class := "post-entry" }} |
| 35 | + |
| 36 | +{{- $user_preferred := or site.Params.disableSpecial1stPost site.Params.homeInfoParams }} |
| 37 | +{{- if (and (eq $paginator.PageNumber 1) (eq $index 0) (not $user_preferred)) }} |
| 38 | +{{- $class = "first-entry" }} |
| 39 | +{{- else if $term }} |
| 40 | +{{- $class = "post-entry tag-entry" }} |
| 41 | +{{- end }} |
| 42 | + |
| 43 | +<article class="{{ $class }}"> |
| 44 | + {{- $isHidden := (.Param "cover.hiddenInList") | default (.Param "cover.hidden") | default false }} |
| 45 | + {{- partial "cover.html" (dict "cxt" . "IsSingle" false "isHidden" $isHidden) }} |
| 46 | + <header class="entry-header"> |
| 47 | + <h2 class="entry-hint-parent"> |
| 48 | + {{- .Title }} |
| 49 | + {{- if .Draft }} |
| 50 | + <span class="entry-hint" title="Draft"> |
| 51 | + <svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" fill="currentColor"> |
| 52 | + <path d="M160-410v-60h300v60H160Zm0-165v-60h470v60H160Zm0-165v-60h470v60H160Zm360 580v-123l221-220q9-9 20-13t22-4q12 0 23 4.5t20 13.5l37 37q9 9 13 20t4 22q0 11-4.5 22.5T862.09-380L643-160H520Zm300-263-37-37 37 37ZM580-220h38l121-122-18-19-19-18-122 121v38Zm141-141-19-18 37 37-18-19Z" /> |
| 53 | + </svg> |
| 54 | + </span> |
| 55 | + {{- end }} |
| 56 | + </h2> |
| 57 | + </header> |
| 58 | + {{- if (ne (.Param "hideSummary") true) }} |
| 59 | + <div class="entry-content"> |
| 60 | + <p>{{ .Summary | plainify | htmlUnescape }}{{ if .Truncated }}...{{ end }}</p> |
| 61 | + </div> |
| 62 | + {{- end }} |
| 63 | + {{- if not (.Param "hideMeta") }} |
| 64 | + <footer class="entry-footer"> |
| 65 | + {{- partial "post_meta.html" . -}} |
| 66 | + </footer> |
| 67 | + {{- end }} |
| 68 | + <a class="entry-link" aria-label="post link to {{ .Title | plainify }}" href="{{ .Permalink }}"></a> |
| 69 | +</article> |
| 70 | +{{- end }} |
| 71 | + |
| 72 | +{{- if gt $paginator.TotalPages 1 }} |
| 73 | +<footer class="page-footer"> |
| 74 | + <nav class="pagination"> |
| 75 | + {{- if $paginator.HasPrev }} |
| 76 | + <a class="prev" href="{{ $paginator.Prev.URL | absURL }}"> |
| 77 | + « {{ i18n "prev_page" }} |
| 78 | + {{- if (.Param "ShowPageNums") }} |
| 79 | + {{- sub $paginator.PageNumber 1 }}/{{ $paginator.TotalPages }} |
| 80 | + {{- end }} |
| 81 | + </a> |
| 82 | + {{- end }} |
| 83 | + {{- if $paginator.HasNext }} |
| 84 | + <a class="next" href="{{ $paginator.Next.URL | absURL }}"> |
| 85 | + {{- i18n "next_page" }} |
| 86 | + {{- if (.Param "ShowPageNums") }} |
| 87 | + {{- add 1 $paginator.PageNumber }}/{{ $paginator.TotalPages }} |
| 88 | + {{- end }} » |
| 89 | + </a> |
| 90 | + {{- end }} |
| 91 | + </nav> |
| 92 | +</footer> |
| 93 | +{{- end }} |
| 94 | + |
| 95 | +{{- end }}{{/* end profileMode */}} |
| 96 | + |
| 97 | +{{- end }}{{- /* end main */ -}} |
0 commit comments