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
10 changed files with 44 additions and 28 deletions

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>