🎨 Finish archives page coding.

This commit is contained in:
凡梦星尘
2022-06-07 18:16:40 +08:00
parent 517ddcdf84
commit 168fb20cbb
24 changed files with 184 additions and 26 deletions

View File

@@ -17,7 +17,7 @@
<link rel="icon" type="image/png" sizes="32x32" href="{{ .Site.Params.favicon.medium }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ .Site.Params.favicon.appleTouchIcon }}">
{{- partial "head.html" . }}
<title>{{ .Title | default .Site.Title }}</title>
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
@@ -37,7 +37,7 @@
</header>
<!-- Widgets -->
{{ partial "widgets.html" . }}
<div class="main-inner {{ block "main_class" . }}{{ end }} posts-expand">
<div class="main-inner {{ block "main_inner_class" . }}{{ end }}">
<!-- Submenu,Content,Comment -->
{{- block "main" . }}{{- end }}
{{- if .IsPage }}

View File

@@ -0,0 +1,37 @@
{{- define "title" }}
{{- .Params.Title | default (T .Section) | default .Section | dict "Some" | T "AllSome" }} - {{ .Site.Title -}}
{{- end -}}
{{ define "main_inner_class" }}archive posts-collapse{{ end }}
{{- define "main" }}
<div class="post-block">
<div class="post-content">
<div class="collection-title">
{{- $cheers := "Um" }}
{{- $posts := .Scratch.Get "posts" }}
{{- if gt $posts 210 }}
{{- $cheers = "Excellent" }}
{{- else if gt $posts 130 }}
{{- $cheers = "Great" }}
{{- else if gt $posts 80 }}
{{- $cheers = "Good" }}
{{- else if gt $posts 50 }}
{{- $cheers = "Nice" }}
{{- else if gt $posts 30 }}
{{- $cheers = "Ok" }}
{{- end }}
<span class="collection-header">
{{- T (printf "PostArchiveCheers%s" $cheers) }}
{{- T "SymbolComma"}}
{{- T "ArchiveCounterTitle" $posts }}
{{- T "SymbolComma"}}
{{- T "PostArchiveKeepOn" }}
</span>
</div>
{{ range (.Paginate (.Data.Pages.GroupByDate "2006") 5 ).PageGroups }}
{{- partial "post/list.html" . }}
{{ end }}
</div>
</div>
{{- partial "pagination.html" . }}
{{- end }}

View File

@@ -1,4 +1,5 @@
{{- define "main_class" }}page{{- end }}
{{- define "title" }}{{- .Title }} - {{ .Site.Title -}}{{- end }}
{{- define "main_inner_class" }}post posts-expand{{- end }}
{{- define "main" }}
{{ partial "post_content.html" (dict "ctx" . "IsHome" false) }}
{{ partial "post/index.html" (dict "ctx" . "IsHome" false) }}
{{- end }}

View File

@@ -1,8 +1,8 @@
{{- define "main_class" }}index{{- end }}
{{- define "main_inner_class" }}index posts-expand{{- end }}
{{- define "main" }}
{{ $paginator := .Paginate (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
{{- range $paginator.Pages }}
{{ partial "post_content.html" (dict "ctx" . "IsHome" true) }}
{{ partial "post/index.html" (dict "ctx" . "IsHome" true) }}
{{- end }}
{{- partial "partials/pagination.html" . }}
{{- end }}

View File

@@ -9,12 +9,12 @@
{{- end }}
<div class="post-eof"></div>
{{- else }}
{{ partial "post/post_footer/tags.html" . }}
{{ partial "post/footer_meta/tags.html" . }}
{{ partial "_thirdparty/share/addthis.html" . }}
<hr/>
{{ partial "post/post_footer/reward.html" . }}
{{ partial "post/post_footer/copyright.html" . }}
{{ partial "post/post_footer/followme.html" . }}
{{ partial "post/footer_meta/reward.html" . }}
{{ partial "post/footer_meta/copyright.html" . }}
{{ partial "post/footer_meta/followme.html" . }}
<div class="post-nav">
<div class="post-nav-next post-nav-item">
{{- with .NextInSection }}

View File

@@ -13,7 +13,7 @@
<meta itemprop="description" content="{{ .Description | default .Summary }}">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
{{- if $.IsHome }} <h2 {{ else }} <h1 {{ end -}} class="post-title" itemprop="name headline">
{{- if and .Weight (gt .Weight 0) }}
<span class="post-sticky-flag" title="{{ T "PostStickyTitle" }}">
<i class="fa fa-thumbtack"></i>
@@ -35,18 +35,18 @@
<a href="{{ $editURL }}" rel="noopener external nofollow noreferrer" target="_blank" class="exturl post-edit-link" title="{{ T "PostEditTitle" }}"><i class="fa fa-pen-nib"></i></a>
{{- end }}
{{- end }}
</h2>
{{- if $.IsHome }} </h2> {{ else }} </h1> {{ end -}}
<div class="post-meta-container">
<div class="post-meta-items">
{{ partial "post/post_meta/created_date.html" . }}
{{ partial "post/post_meta/update_date.html" . }}
{{ partial "post/post_meta/categories.html" . }}
{{ partial "post/header_meta/created_date.html" . }}
{{ partial "post/header_meta/update_date.html" . }}
{{ partial "post/header_meta/categories.html" . }}
</div>
{{- if not $.IsHome }}
<div class="post-meta-items">
{{ partial "post/post_meta/words.html" . }}
{{ partial "post/post_meta/readtime.html" . }}
{{ partial "post/post_meta/views.html" . }}
{{ partial "post/header_meta/words.html" . }}
{{ partial "post/header_meta/readtime.html" . }}
{{ partial "post/header_meta/views.html" . }}
</div>
{{ end }}
</div>

View File

@@ -2,11 +2,11 @@
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="{{ .Scratch.Get "lang" }}">
{{ partial "post/post_header.html" (dict "ctx" .ctx "IsHome" .IsHome) }}
{{ partial "post/header.html" (dict "ctx" .ctx "IsHome" .IsHome) }}
<!-- POST BODY -->
{{ partial "post/post_body.html" (dict "ctx" .ctx "IsHome" .IsHome) }}
{{ partial "post/body.html" (dict "ctx" .ctx "IsHome" .IsHome) }}
<footer class="post-footer">
{{ partial "post/post_footer.html" (dict "ctx" .ctx "IsHome" .IsHome) }}
{{ partial "post/footer.html" (dict "ctx" .ctx "IsHome" .IsHome) }}
</footer>
</article>
</div>

View File

@@ -0,0 +1,27 @@
<div class="collection-year">
<span class="collection-header">{{ .Key }}</span>
</div>
{{ range .Pages }}
<article itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<div class="post-meta-container">
{{ $month := .Date.Format .Site.Params.monthFormat }}
<time itemprop="dateCreated" datetime="{{ .Date.Format .Site.Params.timeFormat }}" content="{{ $month }}">
{{ $month }}
</time>
</div>
<div class="post-title">
{{- if isset .Params "extlink" }}
<a href="{{ .Params.extlink }}" rel="noopener external nofollow noreferrer" target="_blank" class="exturl post-title-link post-title-link-external" title="">
<span itemprop="name">{{- .Title -}}</span>
<i class="fa fa-external-link-alt"></i>
</a>
{{- else }}
<a class="post-title-link" href="{{ .Permalink }}" itemprop="url">
<span itemprop="name">{{ .Title }}</span>
</a>
{{- end }}
</div>
</header>
</article>
{{ end }}