diff options
author | Vivek R <vividvilla@gmail.com> | 2019-04-19 21:52:50 +0300 |
---|---|---|
committer | Vivek R <vividvilla@gmail.com> | 2019-04-19 21:52:50 +0300 |
commit | b89ed755ef2aa9a7303301f480e3d1d459173506 (patch) | |
tree | 2c3cc4b4dbbff17d3f3eb27a332d2457aa3deaf0 /layouts | |
parent | e9b2b8f64d295c0b24233fd7b62e5fd7536ba395 (diff) |
feat: add social icons and template bug fixes
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/list.html | 5 | ||||
-rw-r--r-- | layouts/_default/single.html | 14 | ||||
-rw-r--r-- | layouts/index.html | 12 | ||||
-rw-r--r-- | layouts/partials/disqus.html | 17 | ||||
-rw-r--r-- | layouts/partials/head.html | 15 | ||||
-rw-r--r-- | layouts/partials/header.html | 20 |
6 files changed, 69 insertions, 14 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index ce70d26..958d67b 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -13,11 +13,14 @@ {{ end }} <ul class="posts"> - {{- range first .Site.Params.SidebarRecentLimit .Data.Pages -}} + {{- range .Data.Pages -}} + {{- if (in (.Site.Params.excludedTypes | default (slice "page")) .Type) -}} + {{- else -}} <li class="post"> <a href="{{ .RelPermalink }}">{{.Title}}</a> <span class="meta">{{ dateFormat "Jan 2, 2006" .Date }}</span> </li> {{- end -}} + {{- end -}} </ul> </div> diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 0abbe00..beee7b7 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -14,9 +14,19 @@ {{ .Content }} </div> - {{ partial "disqus.html" . }} - </div> + {{- $.Scratch.Set "isDisqus" true -}} + {{- if and (isset .Params "disqus") (eq .Params.disabledisqus false) -}} + {{- $.Scratch.Set "isDisqus" false -}} + {{- end -}} + + {{- if and (isset .Params "type") (in (.Site.Params.disableDisqusTypes | default (slice "page")) .Params.type) -}} + {{- $.Scratch.Set "isDisqus" false -}} + {{- end -}} + {{- if eq ($.Scratch.Get "isDisqus") true -}} + {{- partial "disqus.html" . -}} + {{- end -}} + </div> {{ partial "footer.html" . }} </body> </html> diff --git a/layouts/index.html b/layouts/index.html index bd08629..fefffe4 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -10,7 +10,11 @@ Recent posts </h2> <div class="posts"> - {{- range first .Site.Params.SidebarRecentLimit .Data.Pages -}} + {{- $.Scratch.Set "counter" 0 -}} + {{- range .Data.Pages -}} + {{- if (in (.Site.Params.excludedTypes | default (slice "page")) .Type) -}} + {{- else -}} + {{- if lt ($.Scratch.Get "counter") (.Site.Params.RecentPostsCount | default 10) -}} <div class="post"> <div class="meta">{{ dateFormat "Jan 2, 2006" .Date }}</div> <a class="title" href="{{ .RelPermalink }}">{{.Title}}</a> — @@ -24,6 +28,9 @@ {{ end }} </span> </div> + {{- $.Scratch.Set "counter" (add ($.Scratch.Get "counter") 1) -}} + {{- end -}} + {{- end -}} {{- end -}} <a href="/posts">All articles →</a> @@ -32,5 +39,8 @@ </div> {{ partial "footer.html" . }} {{ template "_internal/google_analytics_async.html" . }} + {{- with .Site.Params.Social -}} + <script>feather.replace()</script> + {{- end -}} </body> </html> diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html new file mode 100644 index 0000000..8a829eb --- /dev/null +++ b/layouts/partials/disqus.html @@ -0,0 +1,17 @@ +<div id="disqus_thread"></div> +<script type="text/javascript"> + (function () { + // Don't ever inject Disqus on localhost--it creates unwanted + // discussions from 'localhost:1313' on your Disqus account... + if (window.location.hostname == "localhost") + return; + + var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; + var disqus_shortname = '{{ .Site.DisqusShortname }}'; + dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; + (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); + })(); +</script> +<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by + Disqus.</a></noscript> +<a href="http://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a> diff --git a/layouts/partials/head.html b/layouts/partials/head.html index e59ec08..a1055ad 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,6 +1,17 @@ <div class="header"> - <h1>{{ .Site.Title }}</h1> - <h2>{{ .Site.Params.TitleTag | markdownify }}</h2> + <h1 class="site-title">{{ .Site.Title }}</h1> + <div class="site-description"> + {{- if isset .Site.Params "subtitle" -}} + <h2>{{ .Site.Params.Subtitle | markdownify }}</h2> + {{- end -}} + <nav class="nav social"> + <ul class="flat"> + {{- range $index, $key := .Site.Params.Social -}} + <a href="{{ $key.link }}" title="{{ $key.name }}"><i data-feather="{{ $key.icon }}"></i></a> + {{- end -}} + </ul> + </nav> + </div> <nav class="nav"> <ul class="flat"> diff --git a/layouts/partials/header.html b/layouts/partials/header.html index b3a22cd..59bf2c9 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,22 +1,26 @@ <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> - {{- $title := ( .Title ) -}} {{- $siteTitle := ( .Site.Title ) -}} - {{- if .IsHome -}} - <title>{{ $siteTitle }}</title> + <title>{{ $siteTitle }} {{- if isset .Site.Params "subtitle" -}} - {{ .Site.Params.Subtitle }}{{- end -}} </title> {{- else -}} - <title>{{ $title }} - {{ $siteTitle }}</title> + <title>{{ $title }} - {{ $siteTitle }}</title> {{- end -}} <meta name="viewport" content="width=device-width, initial-scale=1"> - {{ template "_internal/opengraph.html" . }} - {{ template "_internal/twitter_cards.html" . }} - + {{- template "_internal/opengraph.html" . -}} + {{- template "_internal/twitter_cards.html" . -}} <link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,300italic,400italic|Raleway:500,100,300" rel="stylesheet"> + <link rel="stylesheet" type="text/css" media="screen" href="/css/normalize.css" /> <link rel="stylesheet" type="text/css" media="screen" href="/css/main.css" /> - <script src="main.js"></script> + + {{- if and (isset .Site.Params "social") (isset .Site.Params "feathericonscdn") (eq .Site.Params.featherIconsCDN true) -}} + <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> + {{- else if (isset .Site.Params "social") -}} + <script src="/js/feather.min.js"></script> + {{- end -}} + <script src="/js/main.js"></script> </head> |