Skip to content

Commit

Permalink
feat(profile): Add optional title above subtitle (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveA-W authored May 4, 2020
1 parent 417851b commit 67617b8
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 28 deletions.
12 changes: 7 additions & 5 deletions assets/css/_page/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@
@include border-radius(100%);
@include box-shadow(0 0 0 .3618em rgba(0, 0, 0, .05));
@include transition(all 0.4s ease);
}

a img {
cursor: pointer;

&:hover {
position: relative;
@include transform(translateY(-.75rem));
cursor: pointer;
}
}
}

.home-title {
font-size: 1.2rem;
font-weight: bold;
margin: 0;
padding: .4rem;
}

.home-subtitle {
font-size: 1rem;
font-weight: normal;
Expand Down
6 changes: 6 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ enableEmoji = true
gravatarEmail = ""
# URL of avatar shown in home page
avatarURL = "/images/avatar.png"
# title shown in home page
title = ""
# subtitle shown in home page
subtitle = "A Clean, Elegant but Advanced Hugo Theme"
# whether to use typeit animation for subtitle
Expand Down Expand Up @@ -340,6 +342,8 @@ enableEmoji = true
gravatarEmail = ""
# 主页显示头像的 URL
avatarURL = "/images/avatar.png"
# 主页显示的网站标题
title = ""
# 主页显示的网站副标题
subtitle = "一个简洁、优雅且高效的 Hugo 主题"
# 是否为副标题显示打字机动画
Expand Down Expand Up @@ -534,6 +538,8 @@ enableEmoji = true
gravatarEmail = ""
# URL of avatar shown in home page
avatarURL = "/images/avatar.png"
# title shown in home page
title = ""
# subtitle shown in home page
subtitle = "Un thème Hugo simple, élégant et efficace"
# whether to use typeit animation for subtitle
Expand Down
2 changes: 2 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ Please open the code block below to view the complete sample configuration :(far
gravatarEmail = ""
# URL of avatar shown in home page
avatarURL = "/images/avatar.png"
# {{< version 0.2.5 >}} title shown in home page
title = ""
# subtitle shown in home page
subtitle = "This is My New Hugo Site"
# whether to use typeit animation for subtitle
Expand Down
2 changes: 2 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ Please open the code block below to view the complete sample configuration :(far
gravatarEmail = ""
# URL of avatar shown in home page
avatarURL = "/images/avatar.png"
# {{< version 0.2.5 >}} title shown in home page
title = ""
# subtitle shown in home page
subtitle = "This is My New Hugo Site"
# whether to use typeit animation for subtitle
Expand Down
2 changes: 2 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ hugo
gravatarEmail = ""
# 主页显示头像的 URL
avatarURL = "/images/avatar.png"
# {{< version 0.2.5 >}} 主页显示的网站标题
title = ""
# 主页显示的网站副标题
subtitle = "这是我的全新 Hugo 网站"
# 是否为副标题显示打字机动画
Expand Down
8 changes: 2 additions & 6 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
<div class="menu">
<div class="menu-inner">
{{- range .Site.Menus.main -}}
{{- $url := "" -}}
{{- $url := .URL | relLangURL -}}
{{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- else -}}
{{- $url = .URL | relLangURL -}}
{{- end -}}
<a class="menu-item{{ if $.IsMenuCurrent `main` . | or ($.HasMenuCurrent `main` .) | or (eq $.RelPermalink $url) }} active{{ end }}" href="{{ $url }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if (urls.Parse $url).Host }} rel="noopener noreffer" target="_blank"{{ end }}>
{{- .Pre | safeHTML }} {{ .Name }} {{ .Post | safeHTML -}}
Expand Down Expand Up @@ -137,11 +135,9 @@
{{- end -}}
{{- $currentPage := . -}}
{{- range .Site.Menus.main -}}
{{- $url := "" -}}
{{- $url := .URL | relLangURL -}}
{{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- else -}}
{{- $url = .URL | relLangURL -}}
{{- end -}}
<a class="menu-item" href="{{ $url }}" title="{{ .Title }}"{{ if (urls.Parse $url).Host }} rel="noopener noreffer" target="_blank"{{ end }}>
{{- .Pre | safeHTML }}{{ .Name }}{{ .Post | safeHTML -}}
Expand Down
34 changes: 20 additions & 14 deletions layouts/partials/home/profile.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
{{- $profile := .Site.Params.home.profile -}}
<div class="home-profile">
{{- $avatar := .Site.Params.home.profile.avatarURL -}}
{{- with .Site.Params.home.profile.gravatarEmail -}}
{{- $avatar := $profile.avatarURL -}}
{{- with $profile.gravatarEmail -}}
{{- $avatar = md5 . | printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" -}}
{{- end -}}
{{- if $avatar -}}
<div class="home-avatar">
{{- $firstMenu := "" -}}
{{- if .Site.Menus.main -}}
{{- range first 1 $.Site.Menus.main -}}
{{- $firstMenu = . -}}
{{- $menus := $.Site.Menus.main | default slice -}}
{{- with index $menus 0 -}}
{{- $url := .URL | relLangURL -}}
{{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- end -}}
{{- end -}}
{{- with $firstMenu -}}
<a href="{{- .URL -}}" title="{{- .Name -}}">
<a href="{{ $url }}"{{ with .Title | default .Name }} title="{{ . }}"{{ end }}{{ if (urls.Parse $url).Host }} rel="noopener noreffer" target="_blank"{{ end }}>
{{- dict "src" $avatar "alt" .Name | partial "plugin/image.html" -}}
</a>
{{- else -}}
{{- dict "src" $avatar "alt" " " | partial "plugin/image.html" -}}
{{- dict "src" $avatar | partial "plugin/image.html" -}}
{{- end -}}
</div>
{{- end -}}

{{- with .Site.Params.home.profile.subtitle -}}
{{- with $profile.title -}}
<h1 class="home-title">
{{- . -}}
</h1>
{{- end -}}

{{- with $profile.subtitle -}}
<h2 class="home-subtitle">
{{- if $.Site.Params.home.profile.typeit -}}
{{- if $profile.typeit -}}
{{- $id := dict "content" . "scratch" $.Scratch | partial "function/id.html" -}}
<div id="{{ $id }}" class="typeit"></div>
{{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}}
Expand All @@ -33,7 +39,7 @@ <h2 class="home-subtitle">
</h2>
{{- end -}}

{{- if .Site.Params.home.profile.social -}}
{{- if $profile.social -}}
<div class="social-links">
{{- $socialMap := resources.Get "data/social.yaml" | transform.Unmarshal -}}
{{- $socialArr := slice -}}
Expand All @@ -58,7 +64,7 @@ <h2 class="home-subtitle">
</div>
{{- end -}}

{{- with .Site.Params.home.profile.disclaimer -}}
{{- with $profile.disclaimer -}}
<h3 class="home-disclaimer">
{{- . | safeHTML -}}
</h3>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 67617b8

Please sign in to comment.