Skip to content

Commit

Permalink
beautify post-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
张文兵 committed Mar 8, 2024
1 parent 5a35df9 commit 0f3cc78
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
23 changes: 23 additions & 0 deletions assets/_markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,29 @@
margin-top: 0;
}
}

.book-post-title{
text-align: center;
}

.book-post-meta{
text-align: center;
font-size: 12px;
}

.book-post-meta-date,
[class^="book-post-meta-separator-"]{
color: #999;
}

@media screen and (max-width: $container-max-width) {
.book-post-meta-tags,
.book-post-meta-series,
.book-post-meta-separator-tags,
.book-post-meta-separator-series {
display: none;
}
}
}

.markdown-inner {
Expand Down
42 changes: 22 additions & 20 deletions layouts/partials/docs/post-meta.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
{{ with .Date }}
<h5>{{ partial "docs/date" (dict "Date" . "Format" $.Site.Params.BookDateFormat) }}</h5>
{{ end }}

{{ range $taxonomy, $_ := .Site.Taxonomies }}
{{ with $terms := $.GetTerms $taxonomy }}
<div>
{{ range $n, $term := $terms }}{{ if $n }}, {{ end }}
<a href="{{ $term.RelPermalink }}">{{ $term.Title }}</a>
{{- end }}
</div>
<div class="book-post-meta">
{{ with .Date }}
<span class="book-post-meta-date">{{ partial "docs/date" (dict "Date" . "Format" $.Site.Params.BookDateFormat) }}</span>
{{ end }}
{{ range $taxonomy, $key := .Site.Taxonomies }}
{{ with $terms := $.GetTerms $taxonomy }}
<span class="book-post-meta-separator-{{ $taxonomy }}">&nbsp; | &nbsp;</span>
<span class="book-post-meta-{{ $taxonomy }}">
{{ range $n, $term := $terms }}{{ if $n }}, {{ end }}
<a href="{{ $term.RelPermalink }}">{{ $term.Title }}</a>
{{- end }}
</span>
{{ end }}
{{ end }}
{{ end }}

{{ if .Params.image }}
<p>
{{ with .Resources.GetMatch .Params.image }}
<img src={{ .RelPermalink }} />
{{ else }}
<img src={{ .Params.image | relURL }} />
{{ if .Params.image }}
<p>
{{ with .Resources.GetMatch .Params.image }}
<img src={{ .RelPermalink }} />
{{ else }}
<img src={{ .Params.image | relURL }} />
{{ end }}
</p>
{{ end }}
</p>
{{ end }}
</div>
2 changes: 1 addition & 1 deletion layouts/posts/list.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ define "main" }}
{{ range sort .Paginator.Pages }}
<article class="markdown book-post">
<h2>
<h2 class="book-post-title">
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
</h2>
{{ partial "docs/post-meta" . }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/posts/single.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ define "main" }}
<article class="markdown book-post">
<h1>
<h1 class="book-post-title">
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
</h1>
{{ partial "docs/post-meta" . }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/taxonomy/taxonomy.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ define "main" }}
{{ range sort .Paginator.Pages }}
<article class="markdown book-post">
<h2>
<h2 class="book-post-title">
<a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a>
</h2>
{{ partial "docs/post-meta" . }}
Expand Down

0 comments on commit 0f3cc78

Please sign in to comment.