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 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;

View file

@ -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
@ -340,6 +342,8 @@ enableEmoji = true
gravatarEmail = ""
# 主页显示头像的 URL
avatarURL = "/images/avatar.png"
# 主页显示的网站标题
title = ""
# 主页显示的网站副标题
subtitle = "一个简洁、优雅且高效的 Hugo 主题"
# 是否为副标题显示打字机动画
@ -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

View file

@ -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

View file

@ -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

View file

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

View file

@ -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 -}}
@ -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 -}}

View file

@ -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" -}}
@ -33,7 +39,7 @@
</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 -}}
@ -58,7 +64,7 @@
</div>
{{- end -}}
{{- with .Site.Params.home.profile.disclaimer -}}
{{- with $profile.disclaimer -}}
<h3 class="home-disclaimer">
{{- . | safeHTML -}}
</h3>