Skip to content

Commit

Permalink
add iconfont and show profile at article bottom.
Browse files Browse the repository at this point in the history
  • Loading branch information
cntrump committed May 2, 2020
1 parent 04960a4 commit ff0cad1
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 10 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Features
- Custom article cover supporting
- Article share supporting (thanks [@jianyuanzh](https://github.com/jianyuanzh))
- [Twitter Card](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary) supporting
- Builtin iconfont (3KB)
- Display author profile at article bottom

Preview the exampleSite:

Expand Down Expand Up @@ -364,6 +366,30 @@ cover = "01.png"
+++
```

### Display author profile at article bottom

Edit `config.toml`

```toml
[params.author]
enable = true
avatar = "/img/avatar.jpg"
name = "XXX"
bio = "XXX" # support markdown syntax

[params.author.twitter]
name = "XXX" # https://twitter.com/XXX

[params.author.github]
name = "XXX" # https://github.com/XXX

[params.author.docker]
name = "XXX" # https://hub.docker.com/u/XXX

[params.author.email]
name = "[email protected]" # mailto:[email protected]
```

## Thanks

- [**Hugo**](https://gohugo.io/)
Expand Down
38 changes: 38 additions & 0 deletions assets/css/iconfont.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@font-face {
font-family: "iconfont";
src: url('/assets/fonts/iconfont.ttf?t=1588390362269') format('truetype');
}

.iconfont {
font-family: "iconfont" !important;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.icon-pagenext:before {
content: "\e66b";
}

.icon-pagepreview:before {
content: "\e66c";
}

.icon-twitter:before {
content: "\e655";
}

.icon-github:before {
content: "\e732";
}

.icon-email:before {
content: "\e651";
}

.icon-article:before {
content: "\e67d";
}

.icon-docker:before {
content: "\e521";
}
33 changes: 31 additions & 2 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ b {

.article.labels,
.article.license,
.article.author,
.article.navigation,
.article.discussion,
.article.share {
Expand All @@ -447,8 +448,6 @@ b {

.article.navigation .li {
display: inline-block;
font-size: 85%;
opacity: .5;
margin-right: 5px;
}

Expand All @@ -460,6 +459,36 @@ b {
border: 2px dashed #ddd;
}

.article.author {
text-align: center;
}

.article.author>* {
margin-top: 16px;
}

.article.author .avatar {
display: block;
max-width: 260px;
margin: auto;
border-radius: 3px;
}

.article.author .name {
font-size: 1.125em;
}

.article.author .bio {
color: #999;
}

.article.author .details .item {
display: inline-block;
font-size: 1.375em;
margin-left: 10px;
margin-right: 10px;
}

.slogan,
.date,
.license {
Expand Down
32 changes: 29 additions & 3 deletions layouts/partials/article-author.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
<!--
for user-side override
-->
{{- with site.Params.author -}}
{{- if .enable -}}
<section class="article author">
{{- with .avatar -}}<img class="avatar" src="{{- . | relURL -}}" alt>{{- end -}}

{{- with .name -}}<p class="name">{{- . | safeHTML -}}<p>{{- end -}}

{{- with .bio -}}<div class="bio">{{- . | markdownify -}}</div>{{- end -}}

<div class="details">
{{- with .github -}}
<a class="item" href="/{{- .name | safeURL -}}" target="_blank"><span class="iconfont icon-github"></span></a>
{{- end -}}

{{- with .docker -}}
<a class="item" href="https://hub.docker.com/u/{{- .name | safeURL -}}" target="_blank"><span class="iconfont icon-docker"></span></a>
{{- end -}}

{{- with .twitter -}}
<a class="item" href="https://twitter.com/{{- .name | safeURL -}}" target="_blank"><span class="iconfont icon-twitter"></span></a>
{{- end -}}

{{- with .email -}}
<a class="item" href="mailto:{{- .name | safeURL -}}" target="_blank"><span class="iconfont icon-email"></span></a>
{{- end -}}
</div>
</section>
{{- end -}}
{{- end -}}
4 changes: 2 additions & 2 deletions layouts/partials/article-bottom-navigation.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{- if and (not (eq .Params.single true)) (or .PrevInSection .NextInSection) -}}
<section class="article navigation">
{{- with .NextInSection -}}
<p><a class="link" href="{{- .RelPermalink -}}"><span class="li">&larr;</span>{{- .Title | safeHTML -}}</a></p>
<p><a class="link" href="{{- .RelPermalink -}}"><span class="li iconfont icon-article"></span>{{- .Title | safeHTML -}}</a></p>
{{- end -}}
{{- with .PrevInSection -}}
<p><a class="link" href="{{- .RelPermalink -}}"><span class="li">&rarr;</span>{{- .Title | safeHTML -}}</a></p>
<p><a class="link" href="{{- .RelPermalink -}}"><span class="li iconfont icon-article"></span>{{- .Title | safeHTML -}}</a></p>
{{- end -}}
</section>
{{- end -}}
4 changes: 2 additions & 2 deletions layouts/partials/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="pagination">
<ul>
{{- if gt $row 1 -}}
<li><a href="{{- $paginator.Prev.URL -}}" class="previous_page">&laquo;</a></li>
<li><a href="{{- $paginator.Prev.URL -}}"><span class="iconfont icon-pagepreview"></span></a></li>
{{- end -}}

{{- range $paginator.Pagers -}}
Expand All @@ -27,7 +27,7 @@
{{- end -}}

{{- if lt $row $rows -}}
<li><a href="{{- $paginator.Next.URL -}}" class="next_page">&raquo;</a></li>
<li><a href="{{- $paginator.Next.URL -}}"><span class="iconfont icon-pagenext"></span></a></li>
{{- end -}}
</ul>
</div>
Expand Down
5 changes: 4 additions & 1 deletion layouts/partials/style.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@
{{- end -}}

{{- if $syntaxCSS -}}
{{- $coreCSS = slice $coreCSS $syntaxCSS | resources.Concat "css/tmp_core.css" -}}
{{- $coreCSS = slice $coreCSS $syntaxCSS | resources.Concat "css/tmp_core.css" -}}
{{- end -}}

{{- $iconfontCSS := (resources.Get "css/iconfont.css") -}}
{{- $coreCSS = slice $coreCSS $iconfontCSS | resources.Concat "css/tmp_iconfont_core.css" -}}

{{- with partial "custom-css.html" . -}}
{{- if ne . "" -}}
{{- $coreCSS = slice $coreCSS . | resources.Concat "css/custom_core.css" -}}
Expand Down
Binary file added static/assets/fonts/iconfont.ttf
Binary file not shown.

0 comments on commit ff0cad1

Please sign in to comment.