feat(profile): Add optional title above subtitle (#308)

This commit is contained in:
Dave A-W 2020-05-04 16:43:47 +08:00 committed by GitHub
parent 417851b1cd
commit 67617b82dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 28 deletions

View file

@ -17,19 +17,21 @@
@include border-radius(100%); @include border-radius(100%);
@include box-shadow(0 0 0 .3618em rgba(0, 0, 0, .05)); @include box-shadow(0 0 0 .3618em rgba(0, 0, 0, .05));
@include transition(all 0.4s ease); @include transition(all 0.4s ease);
}
a img {
cursor: pointer;
&:hover { &:hover {
position: relative; position: relative;
@include transform(translateY(-.75rem)); @include transform(translateY(-.75rem));
cursor: pointer;
} }
} }
} }
.home-title {
font-size: 1.2rem;
font-weight: bold;
margin: 0;
padding: .4rem;
}
.home-subtitle { .home-subtitle {
font-size: 1rem; font-size: 1rem;
font-weight: normal; font-weight: normal;

View file

@ -142,6 +142,8 @@ enableEmoji = true
gravatarEmail = "" gravatarEmail = ""
# URL of avatar shown in home page # URL of avatar shown in home page
avatarURL = "/images/avatar.png" avatarURL = "/images/avatar.png"
# title shown in home page
title = ""
# subtitle shown in home page # subtitle shown in home page
subtitle = "A Clean, Elegant but Advanced Hugo Theme" subtitle = "A Clean, Elegant but Advanced Hugo Theme"
# whether to use typeit animation for subtitle # whether to use typeit animation for subtitle
@ -340,6 +342,8 @@ enableEmoji = true
gravatarEmail = "" gravatarEmail = ""
# 主页显示头像的 URL # 主页显示头像的 URL
avatarURL = "/images/avatar.png" avatarURL = "/images/avatar.png"
# 主页显示的网站标题
title = ""
# 主页显示的网站副标题 # 主页显示的网站副标题
subtitle = "一个简洁、优雅且高效的 Hugo 主题" subtitle = "一个简洁、优雅且高效的 Hugo 主题"
# 是否为副标题显示打字机动画 # 是否为副标题显示打字机动画
@ -534,6 +538,8 @@ enableEmoji = true
gravatarEmail = "" gravatarEmail = ""
# URL of avatar shown in home page # URL of avatar shown in home page
avatarURL = "/images/avatar.png" avatarURL = "/images/avatar.png"
# title shown in home page
title = ""
# subtitle shown in home page # subtitle shown in home page
subtitle = "Un thème Hugo simple, élégant et efficace" subtitle = "Un thème Hugo simple, élégant et efficace"
# whether to use typeit animation for subtitle # whether to use typeit animation for subtitle

View file

@ -304,6 +304,8 @@ Please open the code block below to view the complete sample configuration :(far
gravatarEmail = "" gravatarEmail = ""
# URL of avatar shown in home page # URL of avatar shown in home page
avatarURL = "/images/avatar.png" avatarURL = "/images/avatar.png"
# {{< version 0.2.5 >}} title shown in home page
title = ""
# subtitle shown in home page # subtitle shown in home page
subtitle = "This is My New Hugo Site" subtitle = "This is My New Hugo Site"
# whether to use typeit animation for subtitle # whether to use typeit animation for subtitle

View file

@ -309,6 +309,8 @@ Please open the code block below to view the complete sample configuration :(far
gravatarEmail = "" gravatarEmail = ""
# URL of avatar shown in home page # URL of avatar shown in home page
avatarURL = "/images/avatar.png" avatarURL = "/images/avatar.png"
# {{< version 0.2.5 >}} title shown in home page
title = ""
# subtitle shown in home page # subtitle shown in home page
subtitle = "This is My New Hugo Site" subtitle = "This is My New Hugo Site"
# whether to use typeit animation for subtitle # whether to use typeit animation for subtitle

View file

@ -311,6 +311,8 @@ hugo
gravatarEmail = "" gravatarEmail = ""
# 主页显示头像的 URL # 主页显示头像的 URL
avatarURL = "/images/avatar.png" avatarURL = "/images/avatar.png"
# {{< version 0.2.5 >}} 主页显示的网站标题
title = ""
# 主页显示的网站副标题 # 主页显示的网站副标题
subtitle = "这是我的全新 Hugo 网站" subtitle = "这是我的全新 Hugo 网站"
# 是否为副标题显示打字机动画 # 是否为副标题显示打字机动画

View file

@ -28,11 +28,9 @@
<div class="menu"> <div class="menu">
<div class="menu-inner"> <div class="menu-inner">
{{- range .Site.Menus.main -}} {{- range .Site.Menus.main -}}
{{- $url := "" -}} {{- $url := .URL | relLangURL -}}
{{- with .Page -}} {{- with .Page -}}
{{- $url = .RelPermalink -}} {{- $url = .RelPermalink -}}
{{- else -}}
{{- $url = .URL | relLangURL -}}
{{- end -}} {{- 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 }}> <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 -}} {{- .Pre | safeHTML }} {{ .Name }} {{ .Post | safeHTML -}}
@ -137,11 +135,9 @@
{{- end -}} {{- end -}}
{{- $currentPage := . -}} {{- $currentPage := . -}}
{{- range .Site.Menus.main -}} {{- range .Site.Menus.main -}}
{{- $url := "" -}} {{- $url := .URL | relLangURL -}}
{{- with .Page -}} {{- with .Page -}}
{{- $url = .RelPermalink -}} {{- $url = .RelPermalink -}}
{{- else -}}
{{- $url = .URL | relLangURL -}}
{{- end -}} {{- end -}}
<a class="menu-item" href="{{ $url }}" title="{{ .Title }}"{{ if (urls.Parse $url).Host }} rel="noopener noreffer" target="_blank"{{ 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 -}} {{- .Pre | safeHTML }}{{ .Name }}{{ .Post | safeHTML -}}

View file

@ -1,29 +1,35 @@
{{- $profile := .Site.Params.home.profile -}}
<div class="home-profile"> <div class="home-profile">
{{- $avatar := .Site.Params.home.profile.avatarURL -}} {{- $avatar := $profile.avatarURL -}}
{{- with .Site.Params.home.profile.gravatarEmail -}} {{- with $profile.gravatarEmail -}}
{{- $avatar = md5 . | printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" -}} {{- $avatar = md5 . | printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" -}}
{{- end -}} {{- end -}}
{{- if $avatar -}} {{- if $avatar -}}
<div class="home-avatar"> <div class="home-avatar">
{{- $firstMenu := "" -}} {{- $menus := $.Site.Menus.main | default slice -}}
{{- if .Site.Menus.main -}} {{- with index $menus 0 -}}
{{- range first 1 $.Site.Menus.main -}} {{- $url := .URL | relLangURL -}}
{{- $firstMenu = . -}} {{- with .Page -}}
{{- $url = .RelPermalink -}}
{{- end -}} {{- end -}}
{{- end -}} <a href="{{ $url }}"{{ with .Title | default .Name }} title="{{ . }}"{{ end }}{{ if (urls.Parse $url).Host }} rel="noopener noreffer" target="_blank"{{ end }}>
{{- with $firstMenu -}}
<a href="{{- .URL -}}" title="{{- .Name -}}">
{{- dict "src" $avatar "alt" .Name | partial "plugin/image.html" -}} {{- dict "src" $avatar "alt" .Name | partial "plugin/image.html" -}}
</a> </a>
{{- else -}} {{- else -}}
{{- dict "src" $avatar "alt" " " | partial "plugin/image.html" -}} {{- dict "src" $avatar | partial "plugin/image.html" -}}
{{- end -}} {{- end -}}
</div> </div>
{{- end -}} {{- end -}}
{{- with .Site.Params.home.profile.subtitle -}} {{- with $profile.title -}}
<h1 class="home-title">
{{- . -}}
</h1>
{{- end -}}
{{- with $profile.subtitle -}}
<h2 class="home-subtitle"> <h2 class="home-subtitle">
{{- if $.Site.Params.home.profile.typeit -}} {{- if $profile.typeit -}}
{{- $id := dict "content" . "scratch" $.Scratch | partial "function/id.html" -}} {{- $id := dict "content" . "scratch" $.Scratch | partial "function/id.html" -}}
<div id="{{ $id }}" class="typeit"></div> <div id="{{ $id }}" class="typeit"></div>
{{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}} {{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}}
@ -33,7 +39,7 @@
</h2> </h2>
{{- end -}} {{- end -}}
{{- if .Site.Params.home.profile.social -}} {{- if $profile.social -}}
<div class="social-links"> <div class="social-links">
{{- $socialMap := resources.Get "data/social.yaml" | transform.Unmarshal -}} {{- $socialMap := resources.Get "data/social.yaml" | transform.Unmarshal -}}
{{- $socialArr := slice -}} {{- $socialArr := slice -}}
@ -58,7 +64,7 @@
</div> </div>
{{- end -}} {{- end -}}
{{- with .Site.Params.home.profile.disclaimer -}} {{- with $profile.disclaimer -}}
<h3 class="home-disclaimer"> <h3 class="home-disclaimer">
{{- . | safeHTML -}} {{- . | safeHTML -}}
</h3> </h3>