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

{{ .Title }}

+ {{ with .Param "summary" }} +

{{ . | markdownify }}

+ {{ end }} + +
+ + {{ if .Param "showTags" }} + + {{ $taxonomy := "tags" }} + {{ with .Param $taxonomy }} + +
+ {{ range $index, $tag := . }} + {{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}} + + #{{ .LinkTitle }} + + {{ end }} + {{ end }} +
+ + {{ end }} + {{ end }} + + {{/* Table of Content */}} + + {{ if .Param "toc" }} + + {{ end }} + + {{/* Page content */}} + +
+ {{ .Content }} + {{ if .Site.Params.giscus.enable }} + {{ if not .Params.disableComment }} + {{ partial "comments.html" . }} + {{ end }} + {{ end }} +
+ + {{ if .Store.Get "hasMermaid" }} + {{ $mermaidDarkTheme := default "dark" (or .Params.mermaidDarkTheme .Site.Params.mermaidDarkTheme) }} + {{ $mermaidTheme := default "default" (or .Params.mermaidTheme .Site.Params.mermaidTheme) }} + + {{ end }} + +
+ +{{ end }} diff --git a/layouts/_default/home.html b/layouts/_default/home.html new file mode 100644 index 0000000..973d6e6 --- /dev/null +++ b/layouts/_default/home.html @@ -0,0 +1,61 @@ +{{ define "main" }} + +{{ .Content }} + +{{/* Intro summary section */}} + +{{ if or .Site.Params.homeIntroTitle .Site.Params.homeIntroContent }} +
+ {{ with .Site.Params.homeIntroTitle }} +

{{ . }}

+ {{ end }} + + {{ with .Site.Params.homeIntroContent }} +

{{ . | markdownify }}

+ {{ end }} +
+{{ end }} + +{{/* Social Icons */}} + +{{ with site.Params.social }} +
+ {{- range . }} + + {{ partial "svg.html" . }} + + {{- end }} +
+{{ end }} + +{{/* Collection Section */}} + +{{ if .Site.Params.homeCollection }} + +
+ {{ with .Site.Params.homeCollectionTitle}} +

{{ . }}

+ {{ 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 }} +
+ +{{ end }} \ No newline at end of file diff --git a/layouts/_default/list.html b/layouts/_default/list.html new file mode 100644 index 0000000..e28da1b --- /dev/null +++ b/layouts/_default/list.html @@ -0,0 +1,32 @@ +{{ define "main" }} + +
+ + {{ partial "breadcrumbs.html" . }} + +

{{ .Title }}

+ {{ .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}} + +
+{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html new file mode 100644 index 0000000..d8b3bb5 --- /dev/null +++ b/layouts/_default/single.html @@ -0,0 +1,150 @@ +{{ define "main" }} + +{{/* Breadcrumbs */}} + +{{ if not .IsHome }} +{{ partial "breadcrumbs.html" . }} +{{ end }} + +
+ +
+ + {{/* Title and Summary */}} + +

{{ .Title }}

+ {{ with .Param "summary" }} +

{{ . | markdownify }}

+ {{ end }} + + {{/* Reading Time */}} + +

+ {{ 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 }} + + {{ 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 }} +

+ + + + + {{ if .Param "showTags" }} + + {{ $taxonomy := "tags" }} + {{ with .Param $taxonomy }} + +
+ {{ range $index, $tag := . }} + {{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}} + + #{{ .LinkTitle }} + + {{ end }} + {{ end }} +
+ + {{ end }} + {{ end }} + + {{/* Table of Content */}} + + {{ if .Param "toc" }} + + {{ end }} + + {{/* Page content */}} + +
+ {{ .Content }} + {{ if .Site.Params.giscus.enable }} + {{ if not .Params.disableComment }} + {{ partial "comments.html" . }} + {{ end }} + {{ end }} +
+ + {{ if .Store.Get "hasMermaid" }} + {{ $mermaidDarkTheme := default "dark" (or .Params.mermaidDarkTheme .Site.Params.mermaidDarkTheme) }} + {{ $mermaidTheme := default "default" (or .Params.mermaidTheme .Site.Params.mermaidTheme) }} + + {{ end }} + + {{/* Next prev controls */}} + + {{ if not (.Param "hidePagination") }} + {{ partial "pagination-single.html" . }} + {{ end }} + + {{/* Back to top */}} + + {{ if not (.Param "hideBackToTop") }} + + {{ end }} + +
+ +{{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..fa490d5 --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,56 @@ + + + +{{ $faviconPath := (.Site.Params.faviconPath | default "" | absURL) }} + + + + + + + + + + + + + + + +{{ with .OutputFormats.Get "rss" -}} +{{ printf `` .Rel .MediaType.Type .Permalink site.Title | safeHTML }} +{{ end }} + +{{- if .IsHome -}} + +{{- else -}} + +{{- end }} + +{{ if .Param "fediverse" }} + +{{ end }} + + + {{ if .IsHome }} + {{ site.Title }} + {{ else }} + {{ printf "%s | %s" .Title site.Title }} + {{ end }} + + + + +{{ 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 }} + diff --git a/layouts/partials/home-post-entry.html b/layouts/partials/home-post-entry.html new file mode 100644 index 0000000..5878f00 --- /dev/null +++ b/layouts/partials/home-post-entry.html @@ -0,0 +1,21 @@ +
+ + {{ $dateFormat := "2 Jan 2006"}} + {{ with .Site.Params.homeDateFormat }} + {{ $dateFormat = .}} + {{ end }} + +

{{ .Date | time.Format $dateFormat }}

+ +
+

+ + {{ .Title }} + +

+ + {{ if .Site.Params.listSummaries }} +

{{ .Summary }}

+ {{ end }} +
+
\ No newline at end of file diff --git a/layouts/partials/pagination-controls.html b/layouts/partials/pagination-controls.html new file mode 100644 index 0000000..ac835e4 --- /dev/null +++ b/layouts/partials/pagination-controls.html @@ -0,0 +1,24 @@ +{{ if gt .TotalPages 1 }} + +{{ end }} \ No newline at end of file diff --git a/static/apple-touch-icon.png b/static/apple-touch-icon.png new file mode 100644 index 0000000..a931fc6 Binary files /dev/null and b/static/apple-touch-icon.png differ diff --git a/static/favicon-96x96.png b/static/favicon-96x96.png new file mode 100644 index 0000000..61ccb7d Binary files /dev/null and b/static/favicon-96x96.png differ diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..824904a Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/favicon.svg b/static/favicon.svg new file mode 100644 index 0000000..ca37803 --- /dev/null +++ b/static/favicon.svg @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/static/site.webmanifest b/static/site.webmanifest new file mode 100644 index 0000000..8e650c3 --- /dev/null +++ b/static/site.webmanifest @@ -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" +} \ No newline at end of file diff --git a/static/web-app-manifest-192x192.png b/static/web-app-manifest-192x192.png new file mode 100644 index 0000000..c1a3946 Binary files /dev/null and b/static/web-app-manifest-192x192.png differ diff --git a/static/web-app-manifest-512x512.png b/static/web-app-manifest-512x512.png new file mode 100644 index 0000000..1c6d1a7 Binary files /dev/null and b/static/web-app-manifest-512x512.png differ