Skip to content

Commit

Permalink
修复博客页面展示错误问题 (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
Duan-0916 and [email protected] authored May 21, 2024
1 parent 35926e2 commit a3e6cbd
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 76 deletions.
4 changes: 2 additions & 2 deletions layouts/partials/aside/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ <h2 class="card-title">
</h2>
<div class="ss-aside-project">
{{ range .Params.projects }}
<a class="link" href="{{ .link }}">{{ .name }}</a>
<a class="link" href="{{ .link }}/">{{ .name }}</a>
{{ end }}
</div>
</div>
{{ end }}
{{ end }}
18 changes: 9 additions & 9 deletions layouts/partials/card/project_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
<div class="header">
<div class="header-first">
{{ if isset .Params "icon" }}
<img class="project-icon" src="{{ .Params.icon | relURL }}" />
<img class="project-icon" src="{{ .Params.icon | relURL }}" />
{{ end }}
<h3 class="card-title">
{{ $link := "" }}
{{ if isset .Params "link" }}
{{ if hasPrefix .Params.link "/" }}
{{ $link = path.Join .RelPermalink .Params.link }}
{{ else }}
{{ $link = .Params.link }}
{{ end }}
{{ if hasPrefix .Params.link "/" }}
{{ $link = path.Join .RelPermalink .Params.link "/"}}
{{ else }}
{{ $link = path.Join .RelPermalink "/overview" }}
{{ $link = .Params.link}}
{{ end }}
<a href={{ $link }}>
{{ else }}
{{ $link = path.Join .RelPermalink "/overview/" }}
{{ end }}
<a href={{ printf "%s/" $link }}>
{{ .Title }}
</a>
</h3>
</div>
<div class="gitstar">
<a class="github-button" href={{ .Params.github }} data-icon="octicon-star" data-size="large"
data-show-count="true">
data-show-count="true">
</a>
</div>
</div>
Expand Down
66 changes: 31 additions & 35 deletions layouts/partials/card/toc_list_card.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,45 @@
{{ $allPages := (where .Pages "Section" "projects").ByWeight }}
{{ $parent := .GetPage "projects" }}

{{ $pages := slice }}
{{ range $allPages }}
{{ if eq .Parent $parent }}{{ $pages = $pages | append . }}{{ end }}
{{ if eq .Parent $parent }}{{ $pages = $pages | append . }}{{ end }}
{{ end }}

{{ $main_projects := where $pages ".Params.level" "main" }}
{{ $incubating_projects := where $pages ".Params.level" "incubating" }}
{{ $tool_projects := where $pages ".Params.level" "tool" }}
{{ $ecosystem_projects := where $pages ".Params.level" "ecosystem" }}

{{ $title_list := slice "main_project" "incubating_project" "tool_projects" "ecosystem_projects" }}
{{ $list := slice $main_projects $incubating_projects $tool_projects $ecosystem_projects }}

<div class="ss-toc-list-card -hidden-mobile">
<svg class="icon -hidden-mobile" aria-hidden="true">
<use xlink:href="#icon-menu1"></use>
</svg>
<div class="ss-tooltip">
<svg class="icon -hidden-mobile" aria-hidden="true">
<use xlink:href="#icon-menu1"></use>
</svg>
<div class="ss-tooltip">
{{ range $idx, $val := $list }}
{{ if ne (len $val) 0 }}
<div class="toc-list">
<h4 class="title">{{ i18n (index $title_list $idx) }}</h4>
<ul class="list">
{{ range $val }}
<li class="item">
{{ $link := "" }}
{{ if isset .Params "link" }}
{{ if hasPrefix .Params.link "/" }}
{{ $link = path.Join .RelPermalink .Params.link }}
{{ else }}
{{ $link = .Params.link }}
{{ end }}
{{ else }}
{{ $link = path.Join .RelPermalink "/overview" }}
{{ end }}
<a href={{ $link }}>
{{ .Title }}
</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ if ne (len $val) 0 }}
<div class="toc-list">
<h4 class="title">{{ i18n (index $title_list $idx) }}</h4>
<ul class="list">
{{ range $val }}
<li class="item">
{{ $link := "" }}
{{ if isset .Params "link" }}
{{ if hasPrefix .Params.link "/" }}
{{ $link = path.Join .RelPermalink .Params.link | safeURL }}
{{ else }}
{{ $link = printf "%s/" .Params.link | safeURL }}
{{ end }}
{{ else }}
{{ $link = printf "%s/" (path.Join .RelPermalink "/overview/") | safeURL }}
{{ end }}
<a href={{ $link }}>
{{ .Title }}
</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}
</div>
</div>
{{ end }}
</div>
</div>
28 changes: 14 additions & 14 deletions layouts/partials/pagination/pagination_next.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

{{ if or .PrevInSection .NextInSection }}
<nav class="ss-pagination-next">
{{ with .PrevInSection -}}
<a class="link-prev" href="{{ .RelPermalink }}">
<span class="text">{{ i18n "prev_article" }}: </span>
<span class="text">{{ .Title }}</span>
</a>
{{- end }}
{{ with .NextInSection -}}
<a class="link-next" href="{{ .RelPermalink }}">
<span class="text">{{ i18n "next_article" }}: </span>
<span class="text">{{ .Title }}</span>
</a>
{{- end }}
</nav>
<nav class="ss-pagination-next">
{{ with .PrevInSection -}}
<a class="link-prev" href="{{ .Permalink }}">
<span class="text">{{ i18n "prev_article" }}: </span>
<span class="text">{{ .Title }}</span>
</a>
{{- end }}
{{ with .NextInSection -}}
<a class="link-next" href="{{ .Permalink }}">
<span class="text">{{ i18n "next_article" }}: </span>
<span class="text">{{ .Title }}</span>
</a>
{{- end }}
</nav>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/toc/toc_leaf.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="link{{if eq $baseDir .link }} -current{{end}}">
<a
title="{{ .title }}"
href="{{ relLangURL (path.Join $project .link) }}"
href="{{ printf "%s/" (relLangURL (path.Join $project .link)) }}"
>{{ .title }}</a>
</div>
</li>
Expand Down
28 changes: 13 additions & 15 deletions layouts/projects/section.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{{ $isProjectHome := eq (path.Dir .File.Dir) "projects" }}

{{ if $isProjectHome }}
{{ .Render "list" }}
{{ .Render "list" }}
{{ else }}
{{ $link := "" }}
{{ if isset .Params "link" }}
{{ if hasPrefix .Params.link "/" }}
{{ $link = path.Join .RelPermalink .Params.link }}
{{ else }}
{{ $link = .Params.link }}
{{ end }}
{{ else }}
{{ $link = path.Join .RelPermalink "/overview" }}
{{ end }}
<head>
<meta http-equiv="refresh" content="0; url={{$link}}" />
</head>
{{ $link := "" }}
{{ if isset .Params "link" }}
{{ $link = .Params.link }}
{{ if not (strings.HasSuffix $link "/") }}
{{ $link = printf "%s/" $link }}
{{ end }}
{{ else }}
{{ $link = printf "%s/overview/" .RelPermalink }}
{{ end }}
<head>
<meta http-equiv="refresh" content="0; url={{$link}}" />
</head>
{{ end }}

0 comments on commit a3e6cbd

Please sign in to comment.