From c7a4791bc39b28711ea2ba4210e3653953444309 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 18 Apr 2025 14:34:47 +0800 Subject: feat: better telegram link style --- assets/css/components/_comment.scss | 16 ++++++++++++++++ layouts/partials/components/comment.html | 7 ++++++- static/img/telegram.svg | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 static/img/telegram.svg diff --git a/assets/css/components/_comment.scss b/assets/css/components/_comment.scss index 6b1c0e92..82019dec 100644 --- a/assets/css/components/_comment.scss +++ b/assets/css/components/_comment.scss @@ -31,3 +31,19 @@ margin: 1rem 0 } } + +.telegram-link-container { + text-align: center; + display: flex; + justify-content: center; + a { + @include small-button; + font-size: .9rem; + display: inline-flex; + align-items: center; + gap: 0.25rem; + img { + width: 1rem; + } + } +} diff --git a/layouts/partials/components/comment.html b/layouts/partials/components/comment.html index cfdfa886..64f3d554 100644 --- a/layouts/partials/components/comment.html +++ b/layouts/partials/components/comment.html @@ -26,7 +26,12 @@

{{ if eq .Site.Language.Lang "zh" }} -

你也可以加入本站的 Telegram 群组参与讨论

+ {{ end }} -- cgit v1.2.3 From 4f0ebaeed13c1c44c7d7c5778b187b69f5849552 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 18 Apr 2025 14:40:33 +0800 Subject: refactor: separate post single template and page template --- layouts/_default/single.html | 61 +++--------------------------------- layouts/posts/single.html | 73 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 57 deletions(-) create mode 100644 layouts/posts/single.html diff --git a/layouts/_default/single.html b/layouts/_default/single.html index f81f9208..bfe80ad5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,46 +1,10 @@ {{ define "main" }} - {{ if eq .Type "posts" }} - {{ partial "components/post-page-header.html" . }} - {{ else }} - {{ partial "header.html" . }} - {{ end }} + {{ partial "header.html" . }}
- -
- {{ if in .Site.Params.mainSections .Type }} - {{ partial "components/banner.html" . }} - -

- {{ .Title }} - {{ with .Params.subtitle }} - {{ . }} - {{ end }} -

- - - {{ end }} -
- - +
{{ if .Params.toc }} @@ -48,23 +12,8 @@ {{ end }} {{ .Site.Params.postHeaderContent | safeHTML }} {{ .Content }} - {{ if and (eq .Site.Language.Lang "zh") (eq .Section "posts") }} -

如果你觉得文章对你有帮助,可以考虑赞助作者

- {{ end }}
- {{ if in .Site.Params.mainSections .Type }} - {{ partial "components/comment.html" . }} - {{ with site.RegularPages.Related . | first 5 }} -

{{ T "relatedContent" }}

- - {{ end }} - {{ end }} -
- {{ if ne .Type "posts" }} - {{ partial "footer.html" . }} - {{ end }} + {{ partial "footer.html" . }} {{ end }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html new file mode 100644 index 00000000..525db84d --- /dev/null +++ b/layouts/posts/single.html @@ -0,0 +1,73 @@ +{{ define "main" }} + {{ partial "components/post-page-header.html" . }} +
+ +
+ {{ partial "components/banner.html" . }} + +

+ {{ .Title }} + {{ with .Params.subtitle }} + {{ . }} + {{ end }} +

+ + +
+ + +
+ {{ if .Params.toc }} +
+ {{ end }} + {{ .Site.Params.postHeaderContent | safeHTML }} + {{ .Content }} + {{ if eq .Site.Language.Lang "zh" }} +

如果你觉得文章对你有帮助,可以考虑赞助作者

+ {{ end }} +
+ + {{ partial "components/comment.html" . }} + + {{ with site.RegularPages.Related . | first 5 }} +

{{ T "relatedContent" }}

+ + {{ end }} + + + + +
+{{ end }} -- cgit v1.2.3 From 8825eab3e3e82e0719f58d013218e2b957a2b1c4 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 18 Apr 2025 14:59:48 +0800 Subject: feat: related posts style & reading time estimate --- assets/css/components/_card.scss | 2 +- assets/css/components/_post.scss | 21 +++++++++++++++++++++ layouts/cards/single.html | 2 +- layouts/posts/single.html | 24 ++++++++++++++++++------ 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/assets/css/components/_card.scss b/assets/css/components/_card.scss index 787c4e2d..932ce6a5 100644 --- a/assets/css/components/_card.scss +++ b/assets/css/components/_card.scss @@ -46,7 +46,7 @@ } .card-page { - .referenced-articles { + .related-posts { h2 { font-size: 1.2rem; color: var(--secondary-text-color); diff --git a/assets/css/components/_post.scss b/assets/css/components/_post.scss index 5ab58c85..01c0deff 100644 --- a/assets/css/components/_post.scss +++ b/assets/css/components/_post.scss @@ -82,3 +82,24 @@ } } } + +/* related posts */ + +.related-posts { + .related-posts-list { + padding-inline-start: 0; + .related-posts-item { + display: flex; + justify-content: space-between; + align-items: center; + .related-post-subtitle { + color: var(--secondary-text-color); + } + .related-post-reading-time { + font-family: var(--mono-font-family); + color: var(--secondary-text-color); + font-size: 0.9rem; + } + } + } +} diff --git a/layouts/cards/single.html b/layouts/cards/single.html index 58f712d3..0048ad4d 100644 --- a/layouts/cards/single.html +++ b/layouts/cards/single.html @@ -31,7 +31,7 @@ {{- /* 如果有文章引用这个卡片,就显示它们 */ -}} {{ if gt (len $referencedBy) 0 }} -
+

引用了本卡片的文章

    {{- range $referencedBy }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 525db84d..efea94f0 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -47,16 +47,28 @@ {{ end }} - {{ partial "components/comment.html" . }} + + {{ partial "components/comment.html" . }} - {{ with site.RegularPages.Related . | first 5 }} -

    {{ T "relatedContent" }}

    -
      + + {{ with site.RegularPages.Related . | first 3 }} +
      +

      {{ T "relatedContent" }}

      + - {{ end }} +
      + {{ end }}