🏗️ Finish post content template split and the single page coding.

This commit is contained in:
凡梦星尘
2022-06-02 12:13:16 +08:00
parent 288ded9ddd
commit 5d1b38416e
17 changed files with 227 additions and 79 deletions

View File

@@ -0,0 +1,11 @@
<div class="post-body" itemprop="articleBody">
{{- if not .IsHome }}
{{- if .Params.Expand }}
{{ .Content }}
{{- else }}
{{ .Summary }}
{{- end }}
{{- else }}
{{ .Content }}
{{- end }}
</div>

View File

@@ -0,0 +1,28 @@
{{- if .Scratch.Get "IsHome" }}
{{- if and .Site.Params.readMoreBtn (not .Params.Expand) }}
<div class="post-button">
<a class="btn" href="{{ .Permalink }}#more" rel="contents">
{{ T "PostReadMore" }} &raquo;
</a>
</div>
{{- end }}
<div class="post-eof"></div>
{{- else }}
<div class="post-nav">
<div class="post-nav-next post-nav-item">
{{- with .NextInSection }}
<a href="{{ .Permalink}}" rel="next" title="{{.Title}}">
<i class="fa fa-chevron-left"></i> {{.Title}}
</a>
{{- end }}
</div>
<div class="post-nav-prev post-nav-item">
{{- with .PrevInSection }}
<a href="{{ .Permalink}}" rel="prev" title="{{.Title}}">
{{.Title}}
<i class="fa fa-chevron-right"></i>
</a>
{{- end }}
</div>
</div>
{{- end }}

View File

@@ -0,0 +1,42 @@
<link itemprop="mainEntityOfPage" href="{{ .Permalink }}">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="{{ .Site.Params.avatar.url }}">
<meta itemprop="name" content="{{ .Params.author | default .Site.Params.author }}">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="{{ .Site.Params.author }}">
<meta itemprop="description" content="{{ .Site.Params.description }}">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="{{ .Title }}">
<meta itemprop="description" content="{{ .Description | default .Summary }}">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
{{- if and (isset .Params "sticky") (gt .Params.Sticky 0) }}
<span class="post-sticky-flag" title="{{ T "PostStickyTitle" }}">
<i class="fa fa-thumbtack"></i>
</span>
{{- end }}
{{- if and (isset .Params "link") (ne .Params.Link "") }}
<a href="{{ .Params.Link }}" rel="noopener external nofollow noreferrer" target="_blank" class="exturl post-title-link post-title-link-external">
{{ .Title }}
<i class="fa fa-external-link-alt"></i>
</a>
{{- else }}
<a href="{{ .Permalink }}" itemprop="url" class="post-title-link">{{ .Title }}</a>
{{- end }}
</h2>
{{/* TODO IsHome */}}
{{ print "Get IsHome value in pages loop: " ($.Scratch.Get "IsHome") }}
<div class="post-meta-container">
{{ partial "post/post_meta/created_date.html" . }}
{{ partial "post/post_meta/update_date.html" . }}
{{ partial "post/post_meta/categories.html" . }}
{{- if not (.Scratch.Get "IsHome") }}
{{ partial "post/post_meta/words.html" . }}
{{ partial "post/post_meta/readtime.html" . }}
{{ partial "post/post_meta/views.html" . }}
{{ end }}
</div>
</header>

View File

@@ -0,0 +1,17 @@
{{- if .Site.Params.postMeta.categories }}
{{- if and .Params.categories (gt (len .Params.categories) 0) }}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder-open"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostCatgs") (T "SymbolColon") }}</span>
{{- range (first 3 .Params.categories) }}
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="{{ . | urlize }}" itemprop="url" rel="index">
<span itemprop="name">{{ . }}</span>
</a>
</span>
{{- end }}
</span>
{{- end }}
{{- end }}

View File

@@ -0,0 +1,13 @@
{{- if .Site.Params.postMeta.created }}
{{ $timeF := .Site.Params.timeFormat }}
{{ $createdTime := (.Date.Format $timeF) | default (.PublishDate.Format $timeF) }}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostPublishDate") (T "SymbolColon") }}</span>
<time title="{{ print (T "PostPublishDate") (T "SymbolColon") }}{{ .PublishDate }}" itemprop="dateCreated datePublished" datetime="{{ .PublishDate }}">
{{- .PublishDate.Format .Site.Params.dateFormat -}}
</time>
</span>
{{- end }}

View File

@@ -0,0 +1,9 @@
{{- if .Site.Params.postMeta.readTime }}
<span class="post-meta-item" title="{{ T "PostReading" }}">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostReading") (T "SymbolColon") }} &asymp;</span>
<span>{{- T "PostReadTime" . -}}</span>
</span>
{{- end }}

View File

@@ -0,0 +1,12 @@
{{- if and .Site.Params.postMeta.updated.enable .Site.Params.postMeta.updated.anotherDay }}
{{- if and .Lastmod (gt .Lastmod .PublishDate) }}
{{ $modTime := .Lastmod.Format .Site.Params.timeFormat }}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostLastModDate") (T "SymbolColon") }}</span>
<time title="{{ print (T "PostLastModTime") (T "SymbolColon") }}{{ $modTime }}" itemprop="dateModified" datetime="{{ $modTime }}">{{ .Lastmod.Format .Site.Params.dateFormat }}</time>
</span>
{{- end }}
{{- end }}

View File

@@ -0,0 +1,27 @@
{{- if .Site.Params.leancloudVisitors.enable }}
<span id="{{ .Permalink }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ .Title }}" title="{{ T "PostViews" }}">
<span class="post-meta-item-icon">
<i class="far fa-eye"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostViews") (T "SymbolColon") }}</span>
<span class="leancloud-visitors-count"></span>
</span>
{{- end }}
{{- if .Site.Params.firestore.enable }}
<span class="post-meta-item" title="{{ T "PostViews" }}">
<span class="post-meta-item-icon">
<i class="far fa-eye"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostViews") (T "SymbolColon") }}</span>
<span class="firestore-visitors-count"></span>
</span>
{{- end }}
{{- if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.postViews }}
<span class="post-meta-item" title="{{ T "PostViews" }}" id="busuanzi_container_page_pv">
<span class="post-meta-item-icon">
<i class="{{ .Site.Params.busuanzi.postViewsIcon }}"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostViews") (T "SymbolColon") }}</span>
<span id="busuanzi_value_page_pv"></span>
</span>
{{- end }}

View File

@@ -0,0 +1,9 @@
{{- if .Site.Params.postMeta.wordCount }}
<span class="post-meta-item" title="{{ T "PostWords" }}">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
<span class="post-meta-item-text">{{ print (T "PostWords") (T "SymbolColon") }}</span>
<span>{{ T "PostWordCount" . }}</span>
</span>
{{- end }}