diff options
| author | June <liumy.f@foxmail.com> | 2022-11-28 14:11:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-28 14:11:59 +0800 |
| commit | b8b2081a8a1e0e3fe2e7d34c4168b358fdf021d0 (patch) | |
| tree | d0de16ed7a1a3658dca6346e34478ae787db76f0 | |
| parent | e018919ead448ff70dd1697c03143a46ad690c71 (diff) | |
| parent | 5803c1b8c087b5e3e99200c24e6eb470b7412b8b (diff) | |
Merge pull request #26 from roninro/dev
Support for for social icon
| -rw-r--r-- | assets/data/social.toml | 324 | ||||
| -rw-r--r-- | assets/sass/_sidebar.scss | 1 | ||||
| -rw-r--r-- | exampleSite/config.toml | 8 | ||||
| -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 |
7 files changed, 398 insertions, 112 deletions
diff --git a/assets/data/social.toml b/assets/data/social.toml new file mode 100644 index 0000000..0f69060 --- /dev/null +++ b/assets/data/social.toml @@ -0,0 +1,324 @@ +[github] +weight = 1 +format = "https://github.com/%v" +icon = "fab fa-github" + +[linkedin] +weight = 2 +format = "https://linkedin.com/in/%v" +icon = "fab fa-linkedin" + +[twitter] +weight = 3 +format = "https://twitter.com/%v" +icon = "fab fa-twitter" + +[instagram] +weight = 4 +format = "https://www.instagram.com/%v" +icon = "fab fa-instagram" + +[facebook] +weight = 5 +format = "https://facebook.com/%v" +icon = "fab fa-facebook" + +[telegram] +weight = 6 +format = "https://t.me/%v" +icon = "fab fa-telegram-plane" + +[medium] +weight = 7 +format = "https://medium.com/%v" +icon = "fab fa-medium" + +[gitlab] +weight = 8 +format = "https://gitlab.com/%v" +icon = "fab fa-gitlab" + +[youtubelegacy] +weight = 9 +format = "https://www.youtube.com/user/%v" +icon = "fab fa-youtube" + +[youtubecustom] +weight = 10 +format = "https://www.youtube.com/c/%v" +icon = "fab fa-youtube" + +[youtubechannel] +weight = 11 +format = "https://www.youtube.com/channel/%v" +icon = "fab fa-youtube" + +[tumblr] +weight = 12 +format = "https://%v.tumblr.com/" +icon = "fab fa-tumblr" + +[quora] +weight = 13 +format = "https://www.quora.com/profile/%v" +icon = "fab fa-quora" + +[keybase] +weight = 14 +format = "https://keybase.io/%v" +icon = "fab fa-keybase" + +[pinterest] +weight = 15 +format = "https://www.pinterest.com/%v" +icon = "fab fa-pinterest" + +[reddit] +weight = 16 +format = "https://www.reddit.com/user/%v" +icon = "fab fa-reddit" + +[codepen] +weight = 17 +format = "https://codepen.io/%v" +icon = "fab fa-codepen" + +[freecodecamp] +weight = 18 +format = "https://freecodecamp.org/%v" +icon = "fab fa-free-code-camp" + +[bitbucket] +weight = 19 +format = "https://bitbucket.org/%v" +icon = "fab fa-bitbucket" + +[stackoverflow] +weight = 20 +format = "https://stackoverflow.com/users/%v" +icon = "fab fa-stack-overflow" + +[weibo] +weight = 21 +format = "https://weibo.com/%v" +icon = "fab fa-weibo" + +[odnoklassniki] +weight = 22 +format = "https://ok.ru/%v" +icon = "fab fa-odnoklassniki" + +[vk] +weight = 23 +format = "https://vk.com/%v" +icon = "fab fa-vk" + +[flickr] +weight = 24 +format = "https://www.flickr.com/photos/%v" +icon = "fab fa-flickr" + +[xing] +weight = 25 +format = "https://www.xing.com/profile/%v" +icon = "fab fa-xing" + +[snapchat] +weight = 26 +format = "https://www.snapchat.com/add/%v" +icon = "fab fa-snapchat" + +[soundcloud] +weight = 27 +format = "https://soundcloud.com/%v" +icon = "fab fa-soundcloud" + +[spotify] +weight = 28 +format = "https://open.spotify.com/user/%v" +icon = "fab fa-spotify" + +[bandcamp] +weight = 29 +format = "https://%v.bandcamp.com/" +icon = "fab fa-bandcamp" + +[paypal] +weight = 30 +format = "https://paypal.me/%v" +icon = "fab fa-paypal" + +[fivehundredpx] +weight = 31 +format = "https://500px.com/%v" +icon = "fab fa-500px" + +[mix] +weight = 32 +format = "https://mix.com/%v" +icon = "fab fa-mix" + +[goodreads] +weight = 33 +format = "https://www.goodreads.com/user/show/%v" +icon = "fab fa-goodreads" + +[lastfm] +weight = 34 +format = "https://www.last.fm/user/%v" +icon = "fab fa-lastfm" + +[foursquare] +weight = 35 +format = "https://foursquare.com/%v" +icon = "fab fa-foursquare" + +[hackernews] +weight = 36 +format = "https://news.ycombinator.com/user?id=%v" +icon = "fab fa-hacker-news" + +[kickstarter] +weight = 37 +format = "https://kickstarter.com/profile/%v" +icon = "fab fa-kickstarter" + +[patreon] +weight = 38 +format = "https://patreon.com/%v" +icon = "fab fa-patreon" + +[steam] +weight = 39 +format = "https://steamcommunity.com/id/%v" +icon = "fab fa-steam" + +[twitch] +weight = 40 +format = "https://www.twitch.tv/%v" +icon = "fab fa-twitch" + +[strava] +weight = 41 +format = "https://www.strava.com/athletes/%v" +icon = "fab fa-strava" + +[skype] +weight = 42 +format = "skype:%v" +icon = "fab fa-skype" + +[whatsapp] +weight = 43 +format = "https://wa.me/%v" + +icon = "fab fa-whatsapp" + +[zhihu] +weight = 44 +format = "https://www.zhihu.com/people/%v" +text = "知" +icon = "fab" + +[douban] +weight = 45 +format = "https://www.douban.com/people/%v" +text = "豆" +icon = "fab" + +[angellist] +weight = 46 +format = "https://angel.co/%v" +icon = "fab fa-angellist" + +[slideshare] +weight = 47 +format = "https://slideshare.com/%v" +icon = "fab fa-slideshare" + +[jsfiddle] +weight = 48 +format = "https://jsfiddle.com/%v" +icon = "fab fa-jsfiddle" + +[deviantart] +weight = 49 +format = "https://%v.deviantart.com/" +icon = "fab fa-deviantart" + +[behance] +weight = 50 +format = "https://behance.net/%v" +icon = "fab fa-behance" + +[dribbble] +weight = 51 +format = "https://dribbble.com/%v" +icon = "fab fa-dribbble" + +[wordpress] +weight = 52 +format = "https://%v.wordpress.com/" +icon = "fab fa-wordpress" + +[vine] +weight = 53 +format = "https://vine.co/%v" +icon = "fab fa-vine" + + +[researchgate] +weight = 55 +format = "https://www.researchgate.net/profile/%v" +icon = "fab fa-researchgate" + +[mastodon] +weight = 56 +icon = "fab fa-mastodon" +format = "https://mastodon.social/%v" + +[devto] +weight = 58 +format = "https://dev.to/%v" +icon = "fab fa-dev" + +[bilibili] +weight = 66 +icon = "fab fa-bilibili" +format = "https://space.bilibili.com/%v" + +[discord] +weight = 63 +format = "https://discordapp.com/users/%v" +icon = "fab fa-discord" + +[discordinvite] +weight = 64 +format = "https://discord.gg/%v" +icon = "fab fa-discord" + +[orcid] +weight = 66 +format = "https://orcid.org/%v" +icon = "fab fa-orcid" + +[kaggle] +weight = 68 +format = "https://kaggle.com/%v" +icon = "fab fa-kaggle" + +[phone] +weight = 98 +format = "tel:%v" +icon = "fas fa-phone" + +[email] +weight = 99 +format = "mailto:%v" +icon = "far fa-envelope" + +[rss] +weight = 100 +url = "index.xml" +newtab = true +icon = "fas fa-rss" diff --git a/assets/sass/_sidebar.scss b/assets/sass/_sidebar.scss index 8c82f44..373c486 100644 --- a/assets/sass/_sidebar.scss +++ b/assets/sass/_sidebar.scss @@ -56,6 +56,7 @@ } .list-inline > li { padding-left: 0px; + margin-bottom:5px; } } } diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 91d71b1..d7af5ae 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -88,7 +88,6 @@ avatar = "img/home-bg.jpg" bio = "a personal website" [params.social] -rss_enable = true twitter = "johndoe" facebook = "johndoe" zhihu = "johndoe" @@ -96,6 +95,13 @@ weibo = "johndoe" github = "johndoe" gitlab = "johndoe" linkedin = "johndoe" +rss = true +[params.social.mastodon] +weight = 56 +icon = "fab fa-mastodon" +format = "https://mastodon.social/%v" +id = "johndoe" +url = "" [[params.friends]] name = "John Doe" 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 }} |
