diff options
| author | June <liumy.f@outlook.com> | 2022-11-28 11:11:24 +0800 |
|---|---|---|
| committer | June <liumy.f@outlook.com> | 2022-11-28 11:11:24 +0800 |
| commit | d33691eed6c1e5f1f7bf710b77ff3a01a65cea3c (patch) | |
| tree | aa8298538883e6a60838ffd184d365796d46935f /layouts | |
| parent | e018919ead448ff70dd1697c03143a46ad690c71 (diff) | |
Support for more social icons
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/baseof.html | 41 | ||||
| -rw-r--r-- | layouts/partials/nav.html | 6 | ||||
| -rw-r--r-- | layouts/partials/sns-links.html | 128 | ||||
| -rw-r--r-- | layouts/section/archive.html | 2 |
4 files changed, 66 insertions, 111 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 49a4c23..59edd63 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -7,32 +7,30 @@ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> {{ $title := .Title }} - {{ if not .IsHome }} + {{- if not .IsHome }} {{ $title = printf "%s | %s" .Title .Site.Title }} - {{ end }} + {{ end -}} <title>{{ $title }}</title> - {{ with .Site.Params.author }} + {{- with .Site.Params.author }} <meta name="author" content="{{ . }}"> - {{ end }} + {{ end -}} <meta name="description" content="{{ .Description | default (.Summary | default .Site.Params.description ) }}"> <meta name="keywords" content="{{ (delimit .Keywords " ,") | default .Site.Params.keywords }}"> {{ template "_internal/twitter_cards.html" . }} {{ template "_internal/opengraph.html" . }} - <link rel="stylesheet" href="{{ "css/bootstrap.min.css" | relURL }}" crossorigin="anonymous"> - <!-- Hux change font-awesome CDN to qiniu --> - <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" - type="text/css"> + <!-- font-awesome --> + <link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.1/css/all.min.css" rel="stylesheet" type="text/css"> {{ $options := (dict "outputStyle" "compressed" "enableSourceMap" (not hugo.IsProduction) "includePaths" (slice "sass")) }} - {{ $style := resources.Get "sass/main.scss" | resources.ToCSS $options }} + {{- $style := resources.Get "sass/main.scss" | resources.ToCSS $options -}} <link rel="stylesheet" href="{{ $style.RelPermalink }}"> - {{ $zoom_css := resources.Get "zoomjs/zoom.css" | resources.Minify }} + {{ $zoom_css := resources.Get "zoomjs/zoom.css" | resources.Minify -}} <link rel="stylesheet" href="{{ $zoom_css.RelPermalink }}"> {{ range .Site.Params.custom_css -}} @@ -41,18 +39,18 @@ {{ $custom_style := $custom_template | resources.ToCSS | resources.Minify }} <link rel="stylesheet" href="{{ $custom_style.RelPermalink }}"> {{ end }} - {{ end }} + {{- end -}} <script src={{ "js/lazysizes.min.js" | relURL }}></script> <!-- custom js --> - {{ range .Site.Params.custom_js -}} + {{- range .Site.Params.custom_js -}} {{ $custom_template := resources.Get . }} {{ if $custom_template }} {{ $custom_js := $custom_template | resources.Minify | resources.Fingerprint }} <script defer src="{{ $custom_js.RelPermalink }}"></script> {{ end }} - {{ end }} + {{ end -}} {{ range .AlternativeOutputFormats -}} {{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }} @@ -75,20 +73,19 @@ <!-- hack iOS CSS :active style --> <body ontouchstart=""> - - {{ $header_img := .Param "header_img" }} - {{ if .IsHome }} + {{- $header_img := .Param "header_img" -}} + {{- if .IsHome -}} {{ $header_img = .Site.Params.img_home }} - {{ else if eq .Kind "404" }} + {{- else if eq .Kind "404" -}} {{ $header_img = .Site.Params.img_404 }} - {{ end }} - {{ if $header_img }} + {{- end -}} + {{- if $header_img -}} {{ .Scratch.Set "header_img" ( $header_img | relURL ) }} - {{ end }} + {{- end -}} - {{ if and .IsPage (.Params.toc) }} + {{- if and .IsPage (.Params.toc) }} {{ .Scratch.Set "toc" true }} - {{ end }} + {{ end -}} <!-- Nav --> {{ partial "nav.html" . }} diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index 9059e9a..035698c 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -1,8 +1,8 @@ -{{ $header_img := .Scratch.Get "header_img" }} +{{ $header_img := .Scratch.Get "header_img" -}} {{ $navStyle := "invert" }} -{{ with $header_img }} +{{- with $header_img -}} {{ $navStyle = "" }} -{{ end }} +{{- end -}} <nav class="navbar navbar-default navbar-custom navbar-fixed-top {{ $navStyle }}"> <div class="container-fluid"> diff --git a/layouts/partials/sns-links.html b/layouts/partials/sns-links.html index 96f4ec2..eb17865 100644 --- a/layouts/partials/sns-links.html +++ b/layouts/partials/sns-links.html @@ -1,88 +1,46 @@ -{{ $social := .social }} +{{- $socialMap := resources.Get "data/social.toml" | transform.Unmarshal -}} +{{ $socialList := slice }} +{{- range $key, $value := .social -}} + {{ if $value }} + {{- $social := $key | lower | index $socialMap | default dict -}} + {{- if reflect.IsMap $value -}} + {{- $social = merge $social $value -}} -{{ if .center }} + {{- else if and $social (ne $value true) -}} + {{ $social = merge $social (dict "id" $value) }} + + {{- else if $value -}} + {{- else -}} + {{ $social = dict }} + {{- end -}} + {{- with $social -}} + {{ $socialList = $socialList | append (dict "title" $key | merge $social) }} + {{- end -}} + + {{ end }} +{{- end -}} + +{{- if .center -}} <ul class="list-inline text-center"> -{{ else }} +{{- else -}} <ul class="list-inline"> -{{ end}} - {{ with $social.rss_enable }} - <li> - <a href={{"index.xml" | relURL }}> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-rss fa-stack-1x fa-inverse"></i> - </span> - </a> - </li> - {{ end }} - {{ with $social.twitter }} - <li> - <a href="https://twitter.com/{{ . }}"> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-twitter fa-stack-1x fa-inverse"></i> - </span> - </a> - </li> - {{ end }} - {{ with $social.zhihu }} - <li> - <a target="_blank" href="https://www.zhihu.com/people/{{ . }}"> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-stack-1x fa-inverse">知</i> - </span> - </a> - </li> - {{ end }} - {{ with $social.weibo }} - <li> - <a target="_blank" href="http://weibo.com/{{ . }}"> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-weibo fa-stack-1x fa-inverse"></i> - </span> - </a> - </li> - {{ end }} - {{ with $social.facebook }} - <li> - <a target="_blank" href="https://www.facebook.com/{{ . }}"> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-facebook fa-stack-1x fa-inverse"></i> - </span> - </a> - </li> - {{ end }} - {{ with $social.github }} - <li> - <a target="_blank" href="https://github.com/{{ . }}"> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-github fa-stack-1x fa-inverse"></i> - </span> - </a> - </li> - {{ end }} - {{ with $social.gitlab }} - <li> - <a target="_blank" href="https://gitlab.com/{{ . }}"> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-gitlab fa-stack-1x fa-inverse"></i> - </span> - </a> - </li> - {{ end }} - {{ with $social.linkedin }} - <li> - <a target="_blank" href="https://www.linkedin.com/in/{{ . }}"> - <span class="fa-stack fa-lg"> - <i class="fa fa-circle fa-stack-2x"></i> - <i class="fa fa-linkedin fa-stack-1x fa-inverse"></i> - </span> - </a> - </li> - {{ end }} -</ul>
\ No newline at end of file +{{- end -}} + +{{- range sort $socialList "weight" -}} +{{ $destination := "" }} +{{ if .url }} +{{ $destination = .url | relURL }} +{{ else if .format }} +{{ $destination = printf (string .format) .id }} +{{- end -}} +<li> + <a href="{{ $destination | safeURL }}" {{- if (urls.Parse $destination).Host | or .newtab }} target="_blank" {{- end -}}> + <span class="fa-stack fa-lg"> + <i class="fa fa-circle fa-stack-2x"></i> + <i class="{{ .icon }} fa-stack-1x fa-inverse">{{- .text -}}</i> + </span> + </a> +</li> +{{- end -}} + +</ul> diff --git a/layouts/section/archive.html b/layouts/section/archive.html index 08d12f3..315ec76 100644 --- a/layouts/section/archive.html +++ b/layouts/section/archive.html @@ -12,7 +12,7 @@ {{ range $pages.GroupByDate "2006" }} - <section class=""> + <section> <span class="fa listing-seperator"> <span class="tag-text">{{ .Key }}</span></span> {{ range .Pages }} |
