feature(config): add config for home profile/posts

This commit is contained in:
Dillon
2020-02-17 02:19:55 +08:00
parent d87af71176
commit 5a1e0b5d31
12 changed files with 319 additions and 288 deletions

View File

@@ -1,14 +1,16 @@
{{- define "content" -}}
<div class="page home">
{{- /* Home mode [post] */ -}}
{{- if eq .Site.Params.home_mode "post" -}}
{{- /* Profile */ -}}
{{- /* Profile */ -}}
{{- if .Site.Params.home.profile.enable -}}
{{- partial "home/profile.html" . -}}
{{- end -}}
{{- /* Posts */ -}}
{{- if .Site.Params.home.posts.enable -}}
{{- /* Paginate */ -}}
{{- $paginator := where .Site.RegularPages "Type" "posts" -}}
{{- $paginator = where $paginator "Params.show_in_homepage" "!=" false -}}
{{- with .Site.Params.home_paginate -}}
{{- with .Site.Params.home.posts.paginate -}}
{{- $paginator = $.Paginate $paginator . -}}
{{- else -}}
{{- $paginator = $.Paginate $paginator -}}
@@ -17,11 +19,6 @@
{{- .Render "summary" -}}
{{- end -}}
{{- partial "paginator.html" . -}}
{{- /* Home mode [other] */ -}}
{{- else -}}
{{- /* Profile */ -}}
{{- partial "home/profile.html" . -}}
{{- end -}}
</div>
{{- end -}}

View File

@@ -1,8 +1,8 @@
{{- if .Scratch.Get "production" | and .IsPage | and (ne .Params.comment false) -}}
{{- if .Scratch.Get "production" | and .IsPage | and (ne .Site.Params.comment.enable false) | and (ne .Params.comment false) -}}
{{- $CDN := .Scratch.Get "CDN" -}}
{{- /* Disqus Comment System */ -}}
{{- with .Site.Params.disqus.shortname -}}
{{- with .Site.Params.comment.disqus.shortname -}}
<div id="disqus_thread"></div>
{{- $script := printf `<script src="https://%s.disqus.com/embed.js"></script>` . -}}
{{- slice $script | $.Scratch.Add "scriptCDN" -}}
@@ -12,7 +12,8 @@
{{- end -}}
{{- /* Gitalk Comment System */ -}}
{{- if .Site.Params.gitalk.owner -}}
{{- if .Site.Params.comment.gitalk.owner -}}
{{- $gitalk := .Site.Params.comment.gitalk -}}
<div id="gitalk"></div>
{{- with $CDN.gitalk_css -}}
{{- slice . | $.Scratch.Add "linkCDN" -}}
@@ -29,11 +30,11 @@
var gitalk = new Gitalk({
id: '{{ .Date }}',
title: '{{ .Title }}',
clientID: '{{ .Site.Params.gitalk.clientId }}',
clientSecret: '{{ .Site.Params.gitalk.clientSecret }}',
repo: '{{ .Site.Params.gitalk.repo }}',
owner: '{{ .Site.Params.gitalk.owner }}',
admin: ['{{ .Site.Params.gitalk.owner }}'],
clientID: '{{ $gitalk.clientId }}',
clientSecret: '{{ $gitalk.clientSecret }}',
repo: '{{ $gitalk.repo }}',
owner: '{{ $gitalk.owner }}',
admin: ['{{ $gitalk.owner }}'],
body: decodeURI(location.href),
});
gitalk.render('gitalk');
@@ -45,7 +46,8 @@
{{- end -}}
{{- /* Valine Comment System */ -}}
{{- if .Site.Params.valine.enable -}}
{{- if .Site.Params.comment.valine.enable -}}
{{- $valine := .Site.Params.comment.valine -}}
<div id="valine"></div>
{{- slice "css/lib/valine/dark.scss" | .Scratch.Add "linkLocal" -}}
{{- with $CDN.valine_js -}}
@@ -57,31 +59,31 @@
document.addEventListener("DOMContentLoaded", function(event) {
new Valine({
el: '#valine',
appId: '{{ .Site.Params.valine.appId }}',
appKey: '{{ .Site.Params.valine.appKey }}',
{{- with .Site.Params.valine.placeholder -}}
appId: '{{ $valine.appId }}',
appKey: '{{ $valine.appKey }}',
{{- with $valine.placeholder -}}
placeholder: '{{ . }}',
{{- end -}}
{{- if .Site.Params.valine.notify -}}
{{- if $valine.notify -}}
notify: true,
{{- end -}}
{{- if .Site.Params.valine.verify -}}
{{- if $valine.verify -}}
verify: true,
{{- end -}}
{{- with .Site.Params.valine.avatar -}}
{{- with $valine.avatar -}}
avatar: '{{ . }}',
{{- end -}}
{{- with .Site.Params.valine.meta -}}
{{- with $valine.meta -}}
meta: {{ . | safeJS }},
{{- end -}}
{{- with .Site.Params.valine.pageSize -}}
{{- with $valine.pageSize -}}
pageSize: {{ . | safeJS }},
{{- end -}}
lang: '{{ T "valineLang" }}',
{{- if .Site.Params.valine.visitor -}}
{{- if $valine.visitor -}}
visitor: true,
{{- end -}}
{{- if .Site.Params.valine.recordIP -}}
{{- if $valine.recordIP -}}
recordIP: true,
{{- end -}}
});
@@ -93,16 +95,17 @@
{{- end -}}
{{- /* Facebook Comment System */ -}}
{{- if .Site.Params.facebook.enable -}}
{{- if .Site.Params.comment.facebook.enable -}}
{{- $facebook := .Site.Params.comment.facebook -}}
<div id="fb-root"></div>
<div
class="fb-comments"
data-href="{{ .Site.Params.baseURL }}{{ .Permalink | absURL }}"
data-width="{{ .Site.Params.facebook.width }}"
data-numposts="{{ .Site.Params.facebook.numPosts }}"
data-width="{{ $facebook.width }}"
data-numposts="{{ $facebook.numPosts }}"
></div>
{{- $script := `<script src="https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" crossorigin="anonymous"></script>` -}}
{{- $script = printf $script .Site.Params.facebook.languageCode .Site.Params.facebook.appId -}}
{{- $script = printf $script $facebook.languageCode $facebook.appId -}}
{{- slice $script | .Scratch.Add "scriptCDN" -}}
<noscript>
Please enable JavaScript to view the <a href="https://developers.facebook.com/docs/plugins/comments/">comments powered by Facebook.</a>

View File

@@ -8,7 +8,7 @@
<div class="copyright-line">
{{- /* Copyright year */ -}}
<i class="far fa-copyright fa-fw"></i>
{{- with .Site.Params.since -}}
{{- with .Site.Params.footer.since -}}
<span itemprop="copyrightYear">
{{- if lt . now.Year }}{{ . }} - {{ end }}{{ now.Year -}}
</span>
@@ -22,12 +22,12 @@
{{- end -}}
{{- /* License */ -}}
{{- with .Site.Params.license -}}
{{- with .Site.Params.footer.license -}}
&nbsp;|&nbsp;<span class="license">{{ . | safeHTML }}</span>
{{- end -}}
{{- /* ICP */ -}}
{{- with .Site.Params.icp -}}
{{- with .Site.Params.footer.icp -}}
<span class="icp-splitter">&nbsp;|&nbsp;</span><br class="icp-br"/>
<span class="icp">{{ . | safeHTML }}</span>
{{- end -}}

View File

@@ -1,19 +1,3 @@
{{- with .Site.Params.google_verification -}}
<meta name="google-site-verification" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.bing_verification -}}
<meta name="msvalidate.01" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.yandex_verification -}}
<meta name="yandex-verification" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.pinterest_verification -}}
<meta name="p:domain_verify" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.baidu_verification -}}
<meta name="baidu-site-verification" content="{{ . }}" />
{{- end -}}
{{- template "_internal/opengraph.html" . -}}
{{- template "_internal/twitter_cards.html" . -}}

View File

@@ -1,3 +1,19 @@
{{- with .Site.Params.verification.google -}}
<meta name="google-site-verification" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.bing -}}
<meta name="msvalidate.01" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.yandex -}}
<meta name="yandex-verification" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.pinterest -}}
<meta name="p:domain_verify" content="{{ . }}" />
{{- end -}}
{{- with .Site.Params.verification.baidu -}}
<meta name="baidu-site-verification" content="{{ . }}" />
{{- end -}}
{{- /* Home SEO */ -}}
{{- if .IsHome -}}
<script type="application/ld+json">

View File

@@ -44,6 +44,6 @@
</header>
<script>
window.desktopHeaderMode = {{ .Site.Params.desktopHeaderMode }};
window.mobileHeaderMode = {{ .Site.Params.mobileHeaderMode }};
window.desktopHeaderMode = {{ .Site.Params.header.desktopMode }};
window.mobileHeaderMode = {{ .Site.Params.header.mobileMode }};
</script>

View File

@@ -1,34 +1,38 @@
<div class="home-profile">
{{- $avatar := "" -}}
{{- if .Site.Params.gravatar.email -}}
{{- $avatar = (printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" (md5 .Site.Params.gravatar.email)) -}}
{{- else if .Site.Params.avatar -}}
{{- $avatar = .Site.Params.avatar -}}
{{- $avatar := .Site.Params.home.profile.avatarURL -}}
{{- with .Site.Params.home.profile.gravatarEmail -}}
{{- $avatar = md5 . | printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" -}}
{{- end -}}
{{- if $avatar -}}
{{- with $avatar -}}
<div class="home-avatar">
<a href="/posts">
<img src={{ $avatar | relURL }} alt="avatar" title="{{ T "home" }}">
<img src={{ . | relURL }} alt="avatar" title="{{ T "home" }}">
</a>
</div>
{{- end -}}
{{- with .Site.Params.subtitle -}}
{{- with .Site.Params.home.profile.subtitle -}}
<h2 class="home-description">
{{- $id := md5 . | printf "tp-%s" -}}
<div id={{ printf "r%s" $id }} hidden=true>
{{- . | safeHTML -}}
</div>
<div id={{ $id }} class="typeit"></div>
{{- with $.Scratch.Get "typeitMap" -}}
{{- $.Scratch.Set "typeitMap" (dict $id (slice $id) | merge .) -}}
{{- if $.Site.Params.home.profile.typeit -}}
{{- $id := md5 . | printf "tp-%s" -}}
<div id={{ printf "r%s" $id }} hidden=true>
{{- . | safeHTML -}}
</div>
<div id={{ $id }} class="typeit"></div>
{{- with $.Scratch.Get "typeitMap" -}}
{{- $.Scratch.Set "typeitMap" (dict $id (slice $id) | merge .) -}}
{{- else -}}
{{- $.Scratch.Set "typeitMap" (dict $id (slice $id)) -}}
{{- end -}}
{{- else -}}
{{- $.Scratch.Set "typeitMap" (dict $id (slice $id)) -}}
{{- . | safeHTML -}}
{{- end -}}
</h2>
{{- end -}}
<div class="home-social-links">
{{- partial "home/social.html" . -}}
{{- if .Site.Params.home.profile.social -}}
{{- partial "home/social.html" . -}}
{{- end -}}
</div>
</div>

View File

@@ -17,7 +17,7 @@
</div>
<div class="post-info-line">
<div class="post-info-md">
{{- if .Site.Params.linkToMarkdown -}}
{{- if .Site.Params.page.linkToMarkdown -}}
{{- with .OutputFormats.Get "markdown" -}}
<span>
<a class="link-to-markdown" href="{{ .Permalink }}" target="_blank">
@@ -28,7 +28,7 @@
{{- end -}}
</div>
<div class="post-info-share">
{{- if and ( .Param "socialShare" ) (gt (len (.Param "share")) 0) -}}
{{- if .Site.Params.page.socialShare -}}
<span>
{{- partial "post/share.html" . -}}
</span>