🎨 Modify some Hugo syntax & use CSS style replace HTML DOM style.

This commit is contained in:
凡梦星尘
2022-06-05 21:35:40 +08:00
parent 3b81f46c4e
commit 531e65da7f
10 changed files with 121 additions and 79 deletions

View File

@@ -4,8 +4,6 @@
{{- $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 -}}
<!DOCTYPE html>
<html lang="{{ $lang }}">

View File

@@ -16,23 +16,6 @@
{{- $sn = (sort .nav "weight") }}
{{- $fc = index $sn 0 }}
{{- $sc = index $sn 1 }}
<style type="text/css">
.first-comment {
color: {{ $fc.color }};
{{- if eq .active (lower $fc.name) }}
font-weight: bold;
{{- end }}
}
.comment-switch .move, .switch-btn {
background-color: {{- if eq .active (lower $fc.name) }}{{ $fc.color }}{{ else }} {{ $sc.color }}{{ end }};
}
.second-comment {
color: {{ $sc.color }};
{{- if eq .active (lower $sc.name) }}
font-weight: bold;
{{- end }}
}
</style>
<div class="comment-switch">
<span class="first-comment">{{ $fc.title }}</span>
<span class="switch-btn {{ if eq .active (lower $sc.name) }}move{{ end }}"></span>
@@ -44,7 +27,7 @@
{{ $cp := "_thirdparty/comment/%s.html" }}
{{- if $tc }}
{{- range $sn }}
<div style="display: {{ if eq $active (lower .name) }} block {{ else }} none {{ end }};">
<div>
{{- partial (printf $cp (lower .name)) $root }}
</div>
{{- end }}

View File

@@ -1,15 +1,7 @@
{{- partial "head/meta.html" . }}
{{- if .Site.Params.openGraph.enable }}
{{- partial "head/opengraph.html" . }}
{{- end }}
{{ if isset .Site.Params.openGraph "twitter" }}
{{- partial "head/twitter.html" . }}
{{- end }}
{{- if isset .Site.Params.openGraph "googleplus" }}
{{- partial "head/googleplus.html" . }}
{{- end }}
{{- if isset .Site.Params.openGraph "facebook" }}
{{- partial "head/facebook.html" . }}
{{- end }}
{{ partial "head/verify.html" . }}
{{- partial "head/style.html" . }}

View File

@@ -1,3 +1,4 @@
{{- if .Site.Params.openGraph.enable }}
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:title" content="{{ .Title | default .Site.Title }}" />
<meta property="og:description" content="{{ .Description | default .Site.Params.Description }}" />
@@ -6,10 +7,11 @@
<meta property="og:image:height" content="312" />
<meta property="og:image:type" content="image/jpeg/png/svg/jpg" />
<meta property="og:url" content="{{ .Permalink }}"/>
<meta property="og:site_name" content="{{ .Title | default .Site.Title }}" />
<meta property="og:site_name" content="{{ .Site.Title }}" />
<meta property="og:locale" content="{{ .Scratch.Get "lang" }}"/>
{{- if .IsHome }}
{{- if .IsPage }}
<meta property="article:author" content="{{ .Params.Author | default .Site.Params.Author }}" />
<meta property="article:published_time" content="{{ .PublishDate }}" />
<meta property="article:modified_time" content="{{ .Lastmod }}" />
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,7 +1,9 @@
{{- $img := .Site.Params.openGraph.twitter.image | default (.Scratch.Get "metaImg") }}
{{- with .Site.Params.openGraph.twitter }}
{{- $img := $.Params.openGraph.twitter.image | default ($.Scratch.Get "metaImg") }}
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:creator" content="{{ .Site.Params.openGraph.twitter.creator }}"/>
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ .Site.Params.description }}{{ end }}{{ end }}"/>
<meta name="twitter:creator" content="{{ .creator }}"/>
<meta name="twitter:description" content="{{ with $.Page.Description }}{{ . }}{{ else }}{{if $.Page.IsPage}}{{ .Summary }}{{ else }}{{ $.Params.description }}{{ end }}{{ end }}"/>
<meta name="twitter:image" content="{{ $img | absURL }}"/>
<meta name="twitter:title" content="{{ .Title }}"/>
<meta name="twitter:site" content="@{{ .Site.Params.openGraph.twitter.site }}"/>
<meta name="twitter:title" content="{{ $.Page.Title }}"/>
<meta name="twitter:site" content="@{{ .site }}"/>
{{ end }}

View File

@@ -1,6 +1,7 @@
{{ $posts := len (where .Page.Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
{{- .Scratch.Set "posts" $posts -}}
{{- $ms := .Site.Params.menuSets }}
{{- $curP := .Page }}
{{- $posts := .Scratch.Get "posts" }}
<nav class="site-nav">
<ul class="main-menu menu">
{{- range $curP.Site.Menus.main }}

View File

@@ -13,7 +13,7 @@
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="{{ "/archives/" | relLangURL }}">
<span class="site-state-item-count">{{ len .Site.RegularPages }}</span>
<span class="site-state-item-count">{{ .Scratch.Get "posts" }}</span>
<span class="site-state-item-name">{{ T "SbPostsLable" }}</span>
</a>
</div>