refactor: change config.toml structure

This commit is contained in:
Jimmy Cai 2020-09-06 12:56:44 +02:00
parent 292e96d764
commit 47fb5af201
3 changed files with 21 additions and 13 deletions

View file

@ -10,11 +10,13 @@ title = "Example Site"
[params]
postSection = "post"
emoji = "🍥"
avatar = "img/avatar.png"
subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
postLicense = "Licenced under CC BY-NC-SA 4.0"
favicon = ""
[params.sidebar]
emoji = "🍥"
avatar = "img/avatar.png"
subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
[params.article]
defaultLicense = "Licenced under CC BY-NC-SA 4.0"
[params.widgets]
enabled = ['archive', 'tag-cloud']
[params.widgets.archive]

View file

@ -7,10 +7,10 @@
</section>
{{ end }}
{{ if .Site.Params.postLicense }}
{{ if .Site.Params.article.defaultLicense }}
<section class="article-copyright">
{{ (resources.Get "icons/copyright.svg").Content | safeHTML }}
<span>{{ .Site.Params.postLicense }}</span>
<span>{{ .Site.Params.article.defaultLicense }}</span>
</section>
{{ end }}
</footer>

View file

@ -6,17 +6,23 @@
</button>
<header class="site-info">
{{ if .Site.Params.avatar }}
{{ with .Site.Params.sidebar.avatar }}
<figure class="site-avatar">
{{ $avatar := resources.Get (.Site.Params.avatar) }}
{{ $avatarResized := $avatar.Resize "300x300" }}
<img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}"
height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar">
<span class="emoji">{{ .Site.Params.emoji }}</span>
{{ $avatar := resources.Get (.) }}
{{ if $avatar }}
{{ $avatarResized := $avatar.Resize "300x300" }}
<img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}"
height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar">
{{ else }}
{{ errorf "Failed loading avatar from %q" . }}
{{ end }}
<span class="emoji">{{ $.Site.Params.sidebar.emoji }}</span>
</figure>
{{ end }}
<h1 class="site-name"><a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a></h1>
<h2 class="site-description">{{ .Site.Params.subtitle }}</h2>
<h2 class="site-description">{{ .Site.Params.sidebar.subtitle }}</h2>
</header>
<nav class="menu" id="main-menu">