🏗️ Finish post content template split and the single page coding.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
{{- $P := .Site.Params -}}
|
||||
{{- $lang := replaceRE "-([a-z]+)" (upper (substr .Site.Language -3)) .Site.Language -}}
|
||||
{{- .Scratch.Set "lang" $lang -}}
|
||||
{{- $vendors := .Site.Data.resources.vendors -}}
|
||||
{{- $pluginVen := $P.vendors.plugins -}}
|
||||
{{- $pluginVen := .Site.Params.vendors.plugins -}}
|
||||
{{- $pluginCDN := index $vendors $pluginVen -}}
|
||||
{{- .Scratch.Set "pluginCDN" $pluginCDN -}}
|
||||
{{ $posts := len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
|
||||
{{- .Scratch.Set "posts" $posts -}}
|
||||
{{/* TODO IsHome */}}
|
||||
{{- .Scratch.Set "IsHome" .IsHome }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ $lang }}">
|
||||
|
||||
@@ -14,11 +15,11 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
{{ hugo.Generator }}
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{{ $P.favicon.icon }}">
|
||||
<link rel="icon" type="image/x-icon" href="{{ $P.favicon.icon }}">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{{ $P.favicon.small }}">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{{ $P.favicon.medium }}">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ $P.favicon.appleTouchIcon }}">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}">
|
||||
<link rel="icon" type="image/x-icon" href="{{ .Site.Params.favicon.icon }}">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{{ .Site.Params.favicon.small }}">
|
||||
<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>
|
||||
<noscript>
|
||||
@@ -26,7 +27,7 @@
|
||||
</noscript>
|
||||
</head>
|
||||
|
||||
<body itemscope itemtype="http://schema.org/WebPage" {{ if $P.motion.enable }} class="use-motion" {{ end }}>
|
||||
<body itemscope itemtype="http://schema.org/WebPage" {{ if .Site.Params.motion.enable }} class="use-motion" {{ end }}>
|
||||
<div class="headband"></div>
|
||||
<main class="main">
|
||||
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
|
||||
@@ -34,13 +35,13 @@
|
||||
{{- partial "header.html" . }}
|
||||
</div>
|
||||
<!-- Sidebar -->
|
||||
{{- if ne $P.sidebar.display "remove" }}
|
||||
{{- if ne .Site.Params.sidebar.display "remove" }}
|
||||
{{- partial "sidebar.html" . }}
|
||||
{{- end }}
|
||||
</header>
|
||||
<!-- Widgets -->
|
||||
{{ partial "widgets.html" . }}
|
||||
<div class="main-inner {{ if .IsHome }}index{{ else }}page{{ end }} posts-expand">
|
||||
<div class="main-inner {{ block "main_class" . }}{{ end }} posts-expand">
|
||||
<!-- Submenu,Content,Comment -->
|
||||
{{- block "main" . }}{{- end }}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{{- define "main_class" }}page{{- end }}
|
||||
{{- define "main" }}
|
||||
{{ partial "post_content.html" . }}
|
||||
{{- end }}
|
||||
@@ -1,64 +1,10 @@
|
||||
{{- define "main_class" }}index{{- end }}
|
||||
{{- define "main" }}
|
||||
{{- $lang := .Scratch.Get "lang" }}
|
||||
{{/* TODO IsHome */}}
|
||||
{{- print "Get IsHome value from scratch before paginate: " (.Scratch.Get "IsHome") }}
|
||||
{{ $paginator := .Paginate (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
|
||||
{{- range $paginator.Pages }}
|
||||
<div class="post-block">
|
||||
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="{{ $lang }}">
|
||||
<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">
|
||||
{{/*- with .Sticky }}
|
||||
{{- if gt . 0 }}
|
||||
<span class="post-sticky-flag" title="{{ T "PostStickyTitle" }}">
|
||||
<i class="fa fa-thumbtack"></i>
|
||||
</span>
|
||||
{{- end }}
|
||||
{{- end */}}
|
||||
{{/*- if not (eq .Link "") }}
|
||||
<a href="{{ .Link }}" rel="noopener external nofollow noreferrer" target="_blank" class="exturl post-title-link post-title-link-external">{{ .Title }}</a>
|
||||
{{- else */}}
|
||||
<a href="{{ .Permalink }}" itemprop="url" class="post-title-link">{{ .Title }}</a>
|
||||
{{/*- end */}}
|
||||
</h2>
|
||||
<div class="post-meta-container">
|
||||
{{ partial "post_meta/created_date.html" . }}
|
||||
{{ partial "post_meta/update_date.html" . }}
|
||||
{{ partial "post_meta/categories.html" . }}
|
||||
{{ partial "post_meta/words.html" . }}
|
||||
</div>
|
||||
</header>
|
||||
<!-- POST BODY -->
|
||||
<div class="post-body" itemprop="articleBody">
|
||||
{{- if .Params.Expand }}
|
||||
{{ .Content }}
|
||||
{{- else }}
|
||||
{{ .Summary }}
|
||||
{{- end }}
|
||||
</div>
|
||||
<footer class="post-footer">
|
||||
{{- if and .Site.Params.readMoreBtn (not .Params.Expand) }}
|
||||
<div class="post-button">
|
||||
<a class="btn" href="{{ .Permalink }}#more" rel="contents">
|
||||
{{ T "PostReadMore" }} »
|
||||
</a>
|
||||
</div>
|
||||
{{- end }}
|
||||
<div class="post-eof"></div>
|
||||
</footer>
|
||||
</article>
|
||||
</div>
|
||||
{{ partial "post_content.html" . }}
|
||||
{{- end }}
|
||||
{{- partial "partials/pagination.html" . }}
|
||||
{{- end }}
|
||||
@@ -14,7 +14,7 @@
|
||||
{{- end }}
|
||||
{{- .Scratch.Set "metaImg" $img }}
|
||||
<meta itemprop="image" content="{{ $img | absURL }}" />
|
||||
<meta itemprop="keywords" content="{{ if .IsPage}}{{ delimit .Params.tags ", " }}{{ else }}{{ .Site.Params.keywords }}{{ end }}" />
|
||||
<meta itemprop="keywords" content="{{ if and .IsPage (isset .Params "tags")}}{{ delimit .Params.tags "," }}{{ else }}{{ .Site.Params.keywords }}{{ end }}" />
|
||||
{{- if .Site.Params.darkmode }}
|
||||
<meta name="theme-color" content="{{ .Site.Params.themeColor.dark }}" media="(prefers-color-scheme: dark)" />
|
||||
{{- else }}
|
||||
|
||||
11
layouts/partials/post/post_body.html
Normal file
11
layouts/partials/post/post_body.html
Normal 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>
|
||||
28
layouts/partials/post/post_footer.html
Normal file
28
layouts/partials/post/post_footer.html
Normal 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" }} »
|
||||
</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 }}
|
||||
42
layouts/partials/post/post_header.html
Normal file
42
layouts/partials/post/post_header.html
Normal 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>
|
||||
10
layouts/partials/post_content.html
Normal file
10
layouts/partials/post_content.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<div class="post-block">
|
||||
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="{{ .Scratch.Get "lang" }}">
|
||||
{{ partial "post/post_header.html" . }}
|
||||
<!-- POST BODY -->
|
||||
{{ partial "post/post_body.html" . }}
|
||||
<footer class="post-footer">
|
||||
{{ partial "post/post_footer.html" . }}
|
||||
</footer>
|
||||
</article>
|
||||
</div>
|
||||
Reference in New Issue
Block a user