Add new layout templates and update site configuration for improved structure and content presentation

This commit is contained in:
2025-03-25 22:16:30 +08:00
parent df84cb55cf
commit 5cdd59020a
16 changed files with 482 additions and 44 deletions

View File

@@ -39,3 +39,5 @@ button a,
background-image: none !important; background-image: none !important;
text-decoration: none !important; text-decoration: none !important;
} }

View File

@@ -8,16 +8,12 @@ hasCJKLanguage = true
enableEmoji = true enableEmoji = true
canonifyURLs = true canonifyURLs = true
# SEO & 分析
googleAnalytics = "xxx" # 生产环境请填入 G-XXXXXX
enableRobotsTXT = true
# 构建性能 # 构建性能
timeout = "300s" timeout = "300s"
# 永久链接结构 # 永久链接结构
[permalinks] [permalinks]
posts = "/posts/:year/:month/:day/:slug/" posts = ":slug/"
# 自定义分类标签 # 自定义分类标签
[taxonomies] [taxonomies]
@@ -25,7 +21,6 @@ timeout = "300s"
category = "categories" category = "categories"
series = "series" series = "series"
# 菜单设置 # 菜单设置
[[params.menu]] [[params.menu]]
name = "首页" name = "首页"
@@ -37,12 +32,7 @@ url = "/posts/"
[[params.menu]] [[params.menu]]
name = "片语" name = "片语"
url = "/memos/" url = "https://memos.7wate.com/explore"
newTab = true
[[params.menu]]
name = "挚友"
url = "/friend/"
newTab = true newTab = true
[[params.menu]] [[params.menu]]
@@ -52,27 +42,40 @@ newTab = true
# Typo 主题参数 # Typo 主题参数
[params] [params]
description = "一个喜欢异想天开的家伙 💨" description = "愿我们都能:执着于热爱,纯粹于当下。"
theme = "auto" theme = "auto"
colorPalette = "default" colorPalette = "base16-default"
hideHeader = true # default;
# catpuccin;
# gruvebox;
# eink;
# base16-default;
# base16-eighties;
# base16-ocean;
# base16-mocha;
# base16-cupcake.
# 首页设置 # 首页设置
homeIntroTitle = "👋👋👋" homeIntroTitle = "👋👋👋"
homeIntroContent = """ homeIntroContent = """
一个喜欢异想天开的家伙 💨 愿我们都能:执着于热爱,纯粹于当下。
""" """
# 文辑设置
homeCollectionTitle = "文辑" homeCollectionTitle = "文辑"
homeCollection = "posts" homeCollection = "posts"
# 文章设置
hideHeader = true
readTime = true
paginationSize = 7 paginationSize = 7
listSummaries = false listSummaries = false
listDateFormat = "2 Jan" listDateFormat = "2006 Jan"
homeDateFormat = "2 Jan"
# 页脚设置 # 页脚设置
showFooter = true showFooter = true
footerContent = "Your **custom** md `footer`" footerContent = "© 2025 向阳而生"
# 面包屑导航 # 面包屑导航
[params.breadcrumbs] [params.breadcrumbs]
@@ -80,34 +83,26 @@ enabled = true
showCurrentPage = true showCurrentPage = true
home = "首页" home = "首页"
# Favicon / Logo / SEO 元数据(可选)
# params.logo = "/images/logo.png"
# params.favicon = "/favicon.ico"
# params.keywords = ["技术博客", "分布式系统", "编程", "数据库"]
# 社交链接 # 社交链接
# [[params.social]] [[params.social]]
# name = "github" name = "github"
# url = "https://github.com/yourusername" url = "https://github.com/7wate"
# [[params.social]] [[params.social]]
# name = "linkedin" name = "gmail"
# url = "https://www.linkedin.com/in/yourprofile/" url = "mailto:zhouzhongping@7wate.com"
# [[params.social]] [[params.social]]
# name = "medium" name = "rss"
# url = "https://medium.com/@yourusername" url = "https://blog.7wate.com/feed.xml"
# Markdown 与高亮设置 # Markdown 与高亮设置
[markup] [markup]
[markup.highlight] [markup.highlight]
style = "algol" style = "algol"
lineNos = true
lineNumbersInTable = true
noClasses = false
[markup.goldmark.renderer] [markup.goldmark.renderer]
unsafe = false # 更安全,建议通过短代码插入 HTML而不是直接 HTML unsafe = false
# 安全设置 # 安全设置
[security] [security]
@@ -119,6 +114,12 @@ home = "首页"
priority = 0.5 priority = 0.5
filename = "sitemap.xml" filename = "sitemap.xml"
# 网站分析
[params.umami]
enable = true
websiteId = "ce53db0e-af27-4703-ba19-d4792c8cff78"
jsLocation = "https://umami.7wate.com/script.js"
# 隐私与 GDPR # 隐私与 GDPR
[privacy] [privacy]
[privacy.googleAnalytics] [privacy.googleAnalytics]
@@ -130,10 +131,3 @@ home = "首页"
# 构建压缩设置 # 构建压缩设置
[minify] [minify]
minifyOutput = true minifyOutput = true
# 针对不同构建环境的配置(可选)
[environment.production]
minifyOutput = true
[environment.development]
minifyOutput = false

View File

@@ -0,0 +1,74 @@
{{ define "main" }}
{{/* Breadcrumbs */}}
{{ if not .IsHome }}
{{ partial "breadcrumbs.html" . }}
{{ end }}
<div {{ if .Param "autonumber" }} class="autonumber" {{ end }}>
<div class="single-intro-container">
{{/* Title and Summary */}}
<h1 class="single-title">{{ .Title }}</h1>
{{ with .Param "summary" }}
<p class="single-summary">{{ . | markdownify }}</p>
{{ end }}
</div>
{{ if .Param "showTags" }}
{{ $taxonomy := "tags" }}
{{ with .Param $taxonomy }}
<div class="single-tags">
{{ range $index, $tag := . }}
{{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
<span>
<a href="{{ .Permalink }}">#{{ .LinkTitle }}</a>
</span>
{{ end }}
{{ end }}
</div>
{{ end }}
{{ end }}
{{/* Table of Content */}}
{{ if .Param "toc" }}
<aside class="toc">
<p><strong>Table of contents</strong></p>
{{ .TableOfContents }}
</aside>
{{ end }}
{{/* Page content */}}
<div class="single-content">
{{ .Content }}
{{ if .Site.Params.giscus.enable }}
{{ if not .Params.disableComment }}
{{ partial "comments.html" . }}
{{ end }}
{{ end }}
</div>
{{ if .Store.Get "hasMermaid" }}
{{ $mermaidDarkTheme := default "dark" (or .Params.mermaidDarkTheme .Site.Params.mermaidDarkTheme) }}
{{ $mermaidTheme := default "default" (or .Params.mermaidTheme .Site.Params.mermaidTheme) }}
<script defer
type="module"
id="mermaid_script"
data-light-theme="{{ $mermaidTheme }}"
data-dark-theme="{{ $mermaidDarkTheme }}"
src='{{ "js/mermaid.js" | relURL }}'>
</script>
{{ end }}
</div>
{{ end }}

View File

@@ -0,0 +1,61 @@
{{ define "main" }}
{{ .Content }}
{{/* Intro summary section */}}
{{ if or .Site.Params.homeIntroTitle .Site.Params.homeIntroContent }}
<div class="intro">
{{ with .Site.Params.homeIntroTitle }}
<h1>{{ . }}</h1>
{{ end }}
{{ with .Site.Params.homeIntroContent }}
<p>{{ . | markdownify }}</p>
{{ end }}
</div>
{{ end }}
{{/* Social Icons */}}
{{ with site.Params.social }}
<div class="social-icons">
{{- range . }}
<a href="{{ trim .url " " | safeURL }}" target="_blank"
rel="noopener noreferrer me"
title="{{ (.title | default .name) | title }}">
{{ partial "svg.html" . }}
</a>
{{- end }}
</div>
{{ end }}
{{/* Collection Section */}}
{{ if .Site.Params.homeCollection }}
<div class="list-container">
{{ with .Site.Params.homeCollectionTitle}}
<h1> {{ . }} </h1>
{{ end }}
{{ $pages := where .Site.RegularPages "Section" .Site.Params.homeCollection
}}
{{ $paginationSize := 1}}
{{ if (gt .Site.Params.paginationSize 0) }}
{{ $paginationSize = .Site.Params.paginationSize }}
{{ end }}
{{ $paginator := .Paginate $pages $paginationSize }}
{{ range $index, $page := $paginator.Pages }}
{{ partial "home-post-entry.html" $page}}
{{ end }}
{{ partial "pagination-controls.html" $paginator}}
{{ end }}
</div>
{{ end }}

View File

@@ -0,0 +1,32 @@
{{ define "main" }}
<div class="list-container">
{{ partial "breadcrumbs.html" . }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ $tagsPage := eq .Title "Tags"}}
{{ $paginationSize := 1 }}
{{ if (gt .Site.Params.paginationSize 0) }}
{{ $paginationSize = mul .Site.Params.paginationSize 2 }}
{{ end }}
{{ $paginator := .Paginate (.Pages) $paginationSize }}
{{ range $index, $page := $paginator.Pages }}
{{ if $tagsPage }}
{{ partial "tag-entry.html" $page}}
{{ else }}
{{ partial "post-entry.html" $page}}
{{ end }}
{{ end }}
{{ partial "pagination-controls.html" $paginator}}
</div>
{{ end }}

View File

@@ -0,0 +1,150 @@
{{ define "main" }}
{{/* Breadcrumbs */}}
{{ if not .IsHome }}
{{ partial "breadcrumbs.html" . }}
{{ end }}
<div {{ if .Param "autonumber" }} class="autonumber" {{ end }}>
<div class="single-intro-container">
{{/* Title and Summary */}}
<h1 class="single-title">{{ .Title }}</h1>
{{ with .Param "summary" }}
<p class="single-summary">{{ . | markdownify }}</p>
{{ end }}
{{/* Reading Time */}}
<p class="single-readtime">
{{ with .Date }}
{{/* 古风日期转换 */}}
{{ $year := .Year }}
{{ $heavenlyStems := slice "甲" "乙" "丙" "丁" "戊" "己" "庚" "辛" "壬" "癸" }}
{{ $earthlyBranches := slice "子" "丑" "寅" "卯" "辰" "巳" "午" "未" "申" "酉" "戌" "亥" }}
{{ $stemIndex := mod (sub $year 4) 10 }}
{{ $branchIndex := mod (sub $year 4) 12 }}
{{ $yearStr := printf "%s%s年" (index $heavenlyStems $stemIndex) (index $earthlyBranches $branchIndex) }}
{{/* 月份转换 */}}
{{ $monthNum := int .Month }}
{{ $monthMap := slice "一月" "二月" "三月" "四月" "五月" "六月" "七月" "八月" "九月" "十月" "十一月" "十二月" }}
{{ $monthStr := index $monthMap (sub $monthNum 1) }}
{{/* 日转换为中文日期(简化版) */}}
{{ $day := .Day }}
{{ $chineseDigits := slice "零" "一" "二" "三" "四" "五" "六" "七" "八" "九" "十" }}
{{ $.Scratch.Set "dayStr" "" }}
{{ if le $day 10 }}
{{ $.Scratch.Set "dayStr" (printf "初%s" (index $chineseDigits $day)) }}
{{ else if le $day 20 }}
{{ if eq $day 20 }}
{{ $.Scratch.Set "dayStr" "二十" }}
{{ else }}
{{ $.Scratch.Set "dayStr" (printf "十%s" (index $chineseDigits (sub $day 10))) }}
{{ end }}
{{ else if lt $day 30 }}
{{ $.Scratch.Set "dayStr" (printf "廿%s" (index $chineseDigits (sub $day 20))) }}
{{ else if eq $day 30 }}
{{ $.Scratch.Set "dayStr" "三十" }}
{{ else }}
{{ $.Scratch.Set "dayStr" "三十一" }}
{{ end }}
{{ $dayStr := $.Scratch.Get "dayStr" }}
{{/* 拼接完整古风日期 */}}
{{ $fullDate := printf "%s%s%s日" $yearStr $monthStr $dayStr }}
<time datetime="{{ . | time.Format "2006-01-02T15:04:05-07:00" }}">{{ $fullDate }} · </time>
{{ end }}
{{ if or $.Site.Params.readTime (.Param "readTime") }}
{{ $rt := .ReadingTime }}
{{ if le $rt 5 }}
弹指可览
{{ else if le $rt 15 }}
阅需一刻
{{ else if le $rt 30 }}
半炷香可读
{{ else if le $rt 60 }}
移更漏而尽
{{ else }}
烛烬阅毕
{{ end }}
{{ end }}
</p>
{{ if .Param "showTags" }}
{{ $taxonomy := "tags" }}
{{ with .Param $taxonomy }}
<div class="single-tags">
{{ range $index, $tag := . }}
{{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
<span>
<a href="{{ .Permalink }}">#{{ .LinkTitle }}</a>
</span>
{{ end }}
{{ end }}
</div>
{{ end }}
{{ end }}
{{/* Table of Content */}}
{{ if .Param "toc" }}
<aside class="toc">
<p><strong>Table of contents</strong></p>
{{ .TableOfContents }}
</aside>
{{ end }}
{{/* Page content */}}
<div class="single-content">
{{ .Content }}
{{ if .Site.Params.giscus.enable }}
{{ if not .Params.disableComment }}
{{ partial "comments.html" . }}
{{ end }}
{{ end }}
</div>
{{ if .Store.Get "hasMermaid" }}
{{ $mermaidDarkTheme := default "dark" (or .Params.mermaidDarkTheme .Site.Params.mermaidDarkTheme) }}
{{ $mermaidTheme := default "default" (or .Params.mermaidTheme .Site.Params.mermaidTheme) }}
<script defer
type="module"
id="mermaid_script"
data-light-theme="{{ $mermaidTheme }}"
data-dark-theme="{{ $mermaidDarkTheme }}"
src='{{ "js/mermaid.js" | relURL }}'>
</script>
{{ end }}
{{/* Next prev controls */}}
{{ if not (.Param "hidePagination") }}
{{ partial "pagination-single.html" . }}
{{ end }}
{{/* Back to top */}}
{{ if not (.Param "hideBackToTop") }}
<div class="back-to-top">
<a href="#top">
◈ 扶摇直上 ◈
</a>
</div>
{{ end }}
</div>
{{ end }}

View File

@@ -0,0 +1,56 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
{{ $faviconPath := (.Site.Params.faviconPath | default "" | absURL) }}
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-title" content="{{ site.Title }}" />
<link rel="manifest" href="/site.webmanifest" />
<link rel=“icon” type=“image/png” href=“/favicon-96x96.png” sizes=“96x96” />
<link rel=“icon” type=“image/svg+xml” href=“/favicon.svg” />
<link rel=“快捷方式图标” href=“/favicon.ico” />
<link rel=“apple-touch-icon” sizes=“180x180” href=“/apple-touch-icon.png” />
<meta name=“apple-mobile-web-app-title” content=“{{ site.Title }} />
<link rel=“manifest” href=“/site.webmanifest” />
{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
{{ end }}
{{- if .IsHome -}}
<meta name="description" content="{{ site.Params.Description }}"/>
{{- else -}}
<meta name="description" content="{{ .Params.Description }}"/>
{{- end }}
{{ if .Param "fediverse" }}
<meta name="fediverse:creator" content="{{ .Params.Fediverse }}">
{{ end }}
<title>
{{ if .IsHome }}
{{ site.Title }}
{{ else }}
{{ printf "%s | %s" .Title site.Title }}
{{ end }}
</title>
<link rel="canonical" href="{{ .Permalink }}"/>
{{ template "_internal/opengraph.html" . }}
{{ partialCached "head/css.html" . }}
{{ partialCached "head/js.html" . }}
{{ if hugo.IsProduction }}
{{ template "_internal/google_analytics.html" . }}
{{ if .Site.Params.umami.enable }}
{{ partial "umami.html" . }}
{{ end }}
{{ end }}

View File

@@ -0,0 +1,21 @@
<div class="post-line">
{{ $dateFormat := "2 Jan 2006"}}
{{ with .Site.Params.homeDateFormat }}
{{ $dateFormat = .}}
{{ end }}
<p class="line-date">{{ .Date | time.Format $dateFormat }} </p>
<div>
<p class="line-title">
<a href="{{ .RelPermalink }}">
{{ .Title }}
</a>
</p>
{{ if .Site.Params.listSummaries }}
<p class="line-summary"> {{ .Summary }} </p>
{{ end }}
</div>
</div>

View File

@@ -0,0 +1,24 @@
{{ if gt .TotalPages 1 }}
<div class="pagination">
<div class="pagination-control">
{{ if .HasPrev }}
<a href="{{ .Prev.URL | absURL }}">
<< 前尘
</a>
{{ end }}
</div>
<!-- <div class="page-number">
<p>
{{ .PageNumber }}/{{ .TotalPages }}
</p>
</div> -->
<div class="pagination-control">
{{ if .HasNext }}
<a href="{{ .Next.URL | absURL }}">
来途 >>
</a>
{{ end }}
</div>
</div>
{{ end }}

BIN
static/apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
static/favicon-96x96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

3
static/favicon.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 313 KiB

21
static/site.webmanifest Normal file
View File

@@ -0,0 +1,21 @@
{
"name": "向阳而生",
"short_name": "向阳而生",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB