🏗️ Finish post copy right widget coding.

This commit is contained in:
凡梦星尘
2022-06-03 22:37:33 +08:00
parent 5d1b38416e
commit fa5195c8a2
19 changed files with 408 additions and 171 deletions

View File

@@ -1,5 +1,6 @@
{{ with .ctx }}
<div class="post-body" itemprop="articleBody">
{{- if not .IsHome }}
{{- if $.IsHome }}
{{- if .Params.Expand }}
{{ .Content }}
{{- else }}
@@ -8,4 +9,5 @@
{{- else }}
{{ .Content }}
{{- end }}
</div>
</div>
{{ end }}

View File

@@ -0,0 +1,32 @@
{{- if .Site.Params.creativeCommons.post }}
<div class="post-copyright">
<img src="/imgs/cc/cc.svg" width="75" height="75" align="right" />
<ul>
<li class="post-copyright-author">
{{- if isset .Params "author" }}
<strong>{{ print (T "PostCROriginAuthor") (T "SymbolColon") }} </strong>
{{ .Params.Author }}
{{- else }}
<strong>{{ print (T "PostCRAuthor") (T "SymbolColon") }} </strong>
{{ .Site.Params.author }}
{{- end }}
</li>
<li class="post-copyright-link">
{{- if isset .Params "originlink" }}
<strong>{{ print (T "PostCROriginLink") (T "SymbolColon") }} </strong>
<a target="_blank" href="{{ .Params.OriginLink }}" title="{{ .Title }}">{{ .Params.OriginLink }}</a>
{{- else }}
<strong>{{ print (T "PostCRLink") (T "SymbolColon") }}</strong>
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Permalink }}</a>
{{- end }}
</li>
<li class="post-copyright-license">
<strong>{{ print (T "PostCRLink") (T "SymbolColon") }} </strong>
{{- $ccText := .Site.Params.creativeCommons.license | upper }}
{{- $lang := .Scratch.Get "lang" }}
{{- $ccLink := printf "<a target='_blank' href='https://creativecommons.org/licenses/by-nc-sa/4.0/deed.%s'>%s</a>" (substr $lang 0 2) $ccText }}
{{ printf (T "PostCRLicenseContent") $ccLink | safeHTML }}
</li>
</ul>
</div>
{{- end }}

View File

@@ -1,4 +1,5 @@
{{- if .Scratch.Get "IsHome" }}
{{ with .ctx }}
{{- if $.IsHome }}
{{- if and .Site.Params.readMoreBtn (not .Params.Expand) }}
<div class="post-button">
<a class="btn" href="{{ .Permalink }}#more" rel="contents">
@@ -8,6 +9,7 @@
{{- end }}
<div class="post-eof"></div>
{{- else }}
{{ partial "post/post_copyright.html" . }}
<div class="post-nav">
<div class="post-nav-next post-nav-item">
{{- with .NextInSection }}
@@ -25,4 +27,5 @@
{{- end }}
</div>
</div>
{{- end }}
{{- end }}
{{ end }}

View File

@@ -1,3 +1,4 @@
{{ with .ctx }}
<link itemprop="mainEntityOfPage" href="{{ .Permalink }}">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="{{ .Site.Params.avatar.url }}">
@@ -13,30 +14,33 @@
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
{{- if and (isset .Params "sticky") (gt .Params.Sticky 0) }}
{{- if and .Weight (gt .Weight 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>
{{- if $.IsHome }}
{{- 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 }}
{{- else }}
<a href="{{ .Permalink }}" itemprop="url" class="post-title-link">{{ .Title }}</a>
{{ .Title }}
{{- 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") }}
{{- if not $.IsHome }}
{{ partial "post/post_meta/words.html" . }}
{{ partial "post/post_meta/readtime.html" . }}
{{ partial "post/post_meta/views.html" . }}
{{ end }}
</div>
</header>
</header>
{{ end }}