chore: format code

This commit is contained in:
Dillon 2019-08-09 21:25:13 +08:00
parent 0e48c9f3e3
commit c16db324fa
8 changed files with 137 additions and 147 deletions

View file

@ -55,29 +55,29 @@ jQuery(function($) {
};
_Blog.toggleTheme = function() {
const currentTheme = window.localStorage && window.localStorage.getItem('theme')
const isDark = currentTheme === 'dark'
$('body').toggleClass('dark-theme', isDark)
const currentTheme = window.localStorage && window.localStorage.getItem('theme');
const isDark = currentTheme === 'dark';
$('body').toggleClass('dark-theme', isDark);
$('.theme-switch').on('click', () => {
$('body').toggleClass('dark-theme')
$('body').toggleClass('dark-theme');
window.localStorage &&
window.localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light', )
})
window.localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light', );
});
}
_Blog.toggleMobileMenu = function() {
$('.menu-toggle').on('click', () => {
$('.menu-toggle').toggleClass('active')
$('#mobile-menu').toggleClass('active')
})
$('.menu-toggle').toggleClass('active');
$('#mobile-menu').toggleClass('active');
});
}
$(document).ready(function() {
_Blog.toggleTheme()
_Blog.prettify()
_Blog.countdown()
_Blog.changeTitle()
_Blog.toggleMobileMenu()
_Blog.typeit()
_Blog.toggleTheme();
_Blog.prettify();
_Blog.countdown();
_Blog.changeTitle();
_Blog.toggleMobileMenu();
_Blog.typeit();
});
});

View file

@ -11,7 +11,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>{{ block "title" . -}}{{ .Site.Title }}{{- end }}</title>
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
{{ partial "head.html" . }}
</head>
<body class="">

View file

@ -2,27 +2,29 @@
<div class="post-warp">
<div class="intro">
{{ with .Site.Params.avatar}}
{{ $avatar := .}}
<div class="avatar">
<a href="/posts/"> <img src="{{ (printf "%s%s" $cdn_url $avatar)}}"> </a>
</div>
{{ end }}
{{ $avatar := "" }}
{{ if or .Params.gravatar.Email (and .Site.Params.gravatar.Email (ne .Params.gravatar.Email false)) }}
<div class="avatar">
<a href="/posts/"> <img
src="https://www.gravatar.com/avatar/{{ md5 .Site.Params.gravatar.email }}?s=240&d=mp"
alt="gravatar"> </a>
</div>
{{ $avatar = (printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" (md5 .Site.Params.gravatar.email)) }}
{{ else if .Site.Params.avatar }}
{{ $avatar = (printf "%s%s" $cdn_url .) }}
{{ end }}
{{ if $avatar }}
<div class="avatar">
<a href="/posts/"> <img src={{ $avatar }} alt="avatar"></a>
</div>
{{ end }}
{{ with .Site.Params.subtitle }}
<h2 class="description">
<div id="subtitle"></div>
</h2>
<script>
var typeitMap = window.typeitMap || {};
typeitMap["#subtitle"] = "{{ . }}";
</script>
{{ end }}
</div>
{{ range (.Paginate .Pages).Pages }}
<article class="post" itemscope itemscope="" itemtype="http://schema.org/Article">

View file

@ -2,20 +2,25 @@
<div class="intro">
{{ $avatar := "" }}
{{ with .Site.Params.avatar}}
{{ $avatar = (printf "%s%s" $cdn_url .) }}
{{ end }}
{{ if or .Params.gravatar.Email (and .Site.Params.gravatar.Email (ne .Params.gravatar.Email false)) }}
{{ $avatar = (printf "https://www.gravatar.com/avatar/%s?s=240&d=mp" (md5 .Site.Params.gravatar.email)) }}
{{ else if .Site.Params.avatar }}
{{ $avatar = (printf "%s%s" $cdn_url .) }}
{{ end }}
{{ if $avatar }}
<div class="avatar"><a href="/posts/"> <img src={{ $avatar }} alt="avatar"></a></div>
<div class="avatar">
<a href="/posts/"> <img src={{ $avatar }} alt="avatar"></a>
</div>
{{ end }}
{{ with .Site.Params.subtitle }}
<h2 class="description">
<div id="subtitle"></div>
</h2>
<script>
var typeitMap = window.typeitMap || {};
typeitMap["#subtitle"] = "{{ . }}";
</script>
{{ end }}
<div class="social-links">

View file

@ -47,14 +47,6 @@
{{ $jquery | safeHTML }}
{{ $typeit | safeHTML }}
{{ with .Site.Params.subtitle }}
<script>
if (!window.typeitMap) {
var typeitMap = {}
}
typeitMap["#subtitle"] = "{{ . }}";
</script>
{{ end }}
{{ if .IsPage }}
{{ if .Params.Code }}

View file

@ -1,102 +1,97 @@
{{ if .IsHome -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "{{ .Site.BaseURL }}",
{{ if .Site.Author.name -}}
"author": {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
},
{{- end }}
{{ if .Site.Params.description -}}
"description": "{{ .Site.Params.description }}",
{{- end }}
{{ with .Site.Params.image -}}
"image": "{{ .url | absURL }}",
{{- end }}
{{ with .Site.Params.logo -}}
"thumbnailUrl": "{{ .url | absURL }}",
{{- end }}
{{ with .Site.Copyright -}}
"license": "{{ . }}",
{{- end }}
"name": "{{ .Site.Title }}"
}
</script>
{{/*
"potentialAction": {
"@type": "SearchAction",
"target": "http://example.com/search?&q={query}",
"query-input": "required"
} */}}
{{- else if .IsPage -}}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "{{ .Title }}",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ .Permalink }}"
},
{{ if ge (.Param "lua.image.width") 696 -}}
"image": {
"@type": "ImageObject",
"url": "{{ .Param "lua.image.url" | absURL }}",
"width": {{ .Param "lua.image.width" }},
"height": {{ .Param "lua.image.height" }}
},
{{- else if ge .Site.Params.image.width 696 -}}
"image": {
"@type": "ImageObject",
"url": "{{ .Site.Params.image.url | absURL }}",
"width": {{ .Site.Params.image.width }},
"height": {{ .Site.Params.image.height }}
},
{{- end }}
"genre": "{{ .Type }}",
{{ with .Params.tags -}}
"keywords": "{{ delimit . ", " }}",
{{- end }}
"wordcount": {{ .WordCount }},
"url": "{{ .Permalink }}",
{{ if not .PublishDate.IsZero -}}
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
{{- else if not .Date.IsZero -}}
"datePublished": "{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
{{- end }}
{{ with .Lastmod -}}
"dateModified": "{{ .Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
{{- end }}
{{ with .Site.Copyright -}}
"license": "{{ . }}",
{{- end }}
{{ with .Site.Params.publisher -}}
"publisher": {
"@type": "Organization",
"name": "{{ .name }}",
"logo": {
"@type": "ImageObject",
"url": "{{ .logo.url | absURL }}",
"width": {{ .logo.width }},
"height": {{ .logo.height }}
{{ if .IsHome }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "{{ .Site.BaseURL }}",
{{ if .Site.Author.name }}
"author": {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
},
{{ end }}
{{ if .Site.Params.description }}
"description": "{{ .Site.Params.description }}",
{{ end }}
{{ with .Site.Params.image }}
"image": "{{ .url | absURL }}",
{{ end }}
{{ with .Site.Params.logo }}
"thumbnailUrl": "{{ .url | absURL }}",
{{ end }}
{{ with .Site.Copyright }}
"license": "{{ . }}",
{{ end }}
"name": "{{ .Site.Title }}"
}
},
{{- end }}
{{ if .Params.author -}}
"author": {
"@type": "Person",
"name": "{{ .Params.author }}"
},
{{- else if .Site.Author.name -}}
"author": {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
},
{{- end }}
"description": "{{ .Description }}"
}
</script>
{{- end }}
</script>
{{ else if .IsPage }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "{{ .Title }}",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{ .Permalink }}"
},
{{ if ge (.Param "lua.image.width") 696 }}
"image": {
"@type": "ImageObject",
"url": "{{ .Param "lua.image.url" | absURL }}",
"width": {{ .Param "lua.image.width" }},
"height": {{ .Param "lua.image.height" }}
},
{{ else if ge .Site.Params.image.width 696 }}
"image": {
"@type": "ImageObject",
"url": "{{ .Site.Params.image.url | absURL }}",
"width": {{ .Site.Params.image.width }},
"height": {{ .Site.Params.image.height }}
},
{{ end }}
"genre": "{{ .Type }}",
{{ with .Params.tags }}
"keywords": "{{ delimit . ", " }}",
{{ end }}
"wordcount": {{ .WordCount }},
"url": "{{ .Permalink }}",
{{ if not .PublishDate.IsZero }}
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
{{ else if not .Date.IsZero }}
"datePublished": "{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
{{ end }}
{{ with .Lastmod }}
"dateModified": "{{ .Format "2006-01-02T15:04:05-07:00" | safeHTML }}",
{{ end }}
{{ with .Site.Copyright }}
"license": "{{ . }}",
{{ end }}
{{ with .Site.Params.publisher }}
"publisher": {
"@type": "Organization",
"name": "{{ .name }}",
"logo": {
"@type": "ImageObject",
"url": "{{ .logo.url | absURL }}",
"width": {{ .logo.width }},
"height": {{ .logo.height }}
}
},
{{ end }}
{{ if .Params.author }}
"author": {
"@type": "Person",
"name": "{{ .Params.author }}"
},
{{ else if .Site.Author.name }}
"author": {
"@type": "Person",
"name": "{{ .Site.Author.name }}"
},
{{ end }}
"description": "{{ .Description }}"
}
</script>
{{ end }}

View file

@ -8,9 +8,7 @@
{{ $id = printf "#%s" $id }}
{{ with .Get "date" }}
<script>
if (!window.countdownMap) {
var countdownMap = {}
}
var countdownMap = window.countdownMap || {};
countdownMap["{{ $id }}"] = {{ . }};
</script>
{{ end }}

View file

@ -7,9 +7,7 @@
{{ end }}
{{ $id = printf "#%s" $id }}
<script>
if (!window.typeitMap) {
var typeitMap = {}
}
var typeitMap = window.typeitMap || {};
typeitMap["{{ $id }}"] = {{ .Inner | safeHTML }};
</script>
{{ end }}