Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
chore(style): update code style and add an i18n word
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq committed Feb 3, 2020
1 parent 8aba226 commit 52c7ad2
Show file tree
Hide file tree
Showing 23 changed files with 270 additions and 155 deletions.
8 changes: 8 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ dateFormatToUse = "2006-01-02"
tabWidth = 4
# Goldmark is from Hugo 0.60 the default library used for Markdown
[markup.goldmark]
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true
[markup.goldmark.renderer]
# whether to use HTML tags directly in the document
unsafe = true
Expand Down
8 changes: 8 additions & 0 deletions exampleSite/zh/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ dateFormatToUse = "2006-01-02"
tabWidth = 4
# Goldmark 是 Hugo 0.60 以来的默认 Markdown 解析库
[markup.goldmark]
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true
[markup.goldmark.renderer]
# 是否在文档中直接使用 HTML 标签
unsafe = true
Expand Down
5 changes: 5 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ other = "Powered by %s"
other = "Theme - "
# === partials/footer.html ===

# === partials/post/share.html ===
[share]
other = "Share on"
# === partials/post/share.html ===

# === posts/single.html ===
[toc]
other = "Contents"
Expand Down
5 changes: 5 additions & 0 deletions i18n/zh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ other = "由 %s 强力驱动"
other = "主题 - "
# === partials/footer.html ===

# === partials/post/share.html ===
[share]
other = "分享到"
# === partials/post/share.html ===

# === posts/single.html ===
[toc]
other = "目录"
Expand Down
8 changes: 4 additions & 4 deletions layouts/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

{{- define "content" -}}
<div class="notfound">
<h1 class="error-emoji"></h1>
<h1 id="error-emoji"></h1>
<p class="error-text">
{{- T "pageNotFoundText" -}}&nbsp;
<a href="{{ .Site.BaseURL }}" title="{{ T "backToHome" }}">↩︎</a>
</p>
</div>
<script>
var errorEmojiContainer = document.getElementsByClassName('error-emoji')[0];
var emojiArray = [
const emojiArray = [
'\\(o_o)/', '(o^^)o', '(˚Δ˚)b', '(^-^*)', '(≥o≤)', '(^_^)b', '(·_·)',
'(=\'X\'=)', '(>_<)', '(;-;)', '\\(^Д^)/',
];
var errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
const errorEmoji = emojiArray[Math.floor(Math.random() * emojiArray.length)];
const errorEmojiContainer = document.getElementById('error-emoji');
errorEmojiContainer.appendChild(document.createTextNode(errorEmoji));
</script>
{{- end -}}
14 changes: 7 additions & 7 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<figure>
{{- /* Lazyload */ -}}
{{- $loading := resources.Get "svg/loading.svg" | minify -}}
<img src="{{ $loading.RelPermalink }}" data-sizes="auto" data-src="{{ .Destination | safeURL }}" alt="{{ .Text }}"{{ with .Title }} title="{{ . }}"{{ end }} class="lazyload">
<figcaption class="image-caption">
{{- if .Title -}}
{{- .Title -}}
{{- else -}}
{{- .Text -}}
{{- end -}}
</figcaption>
{{- $caption := .Title | default .Text -}}
{{- with $caption -}}
<figcaption class="image-caption">
{{- . -}}
</figcaption>
{{- end -}}
</figure>
11 changes: 10 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{- /* LoveIt theme version detection */ -}}
{{- if ne .Site.Params.version "0.1.X" -}}
{{- errorf "\n\nThere are two possible situations that led to this error:\n 1. You haven't copied the config.toml yet. See https://github.com/dillonzq/LoveIt#installation \n 2. You have an incompatible update. See https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n\n有两种可能的情况会导致这个错误发生:\n 1. 你还没有复制 config.toml 参考 https://github.com/dillonzq/LoveIt#installation \n 2. 你进行了一次不兼容的更新 参考 https://github.com//dillonzq/LoveIt/blob/master/CHANGELOG.md \n" -}}
{{- end -}}

<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<head>
Expand All @@ -12,10 +14,13 @@
{{- partial "head.html" . -}}
</head>
<body>
{{- /* Check theme isDark before body rendering */ -}}
<script>
window.isDark = (window.localStorage && window.localStorage.getItem('theme')) === 'dark';
window.isDark && document.body.classList.add('dark-theme');
</script>

{{- /* Body wrapper */ -}}
<div class="wrapper">
{{- partial "header.html" . -}}
<main class="main">
Expand All @@ -24,10 +29,14 @@
</div>
</main>
{{- partial "footer.html" . -}}
{{- partial "scripts.html" . -}}
</div>

{{- /* Dynamic to top button */ -}}
<a href="#" class="dynamic-to-top" id="dynamic-to-top" data-scroll>
<span>&nbsp;</span>
</a>

{{- /* Load scripts */ -}}
{{- partial "scripts.html" . -}}
</body>
</html>
3 changes: 2 additions & 1 deletion layouts/_default/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
{{- end -}}

{{- define "content" -}}
{{- $data := .Data -}}
<div class="page archive">
{{- /* Title */ -}}
<h2 class="post-title animated pulse faster">
{{- T "all" | humanize}}{{ T .Section | default .Section | humanize -}}
</h2>

{{- /* Paginate */ -}}
{{- range (.Paginate (.Pages.GroupByDate "2006")).PageGroups -}}
<h3>{{ .Key }}</h3>
{{- range .Pages -}}
Expand Down
3 changes: 3 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

{{- define "content" -}}
<div class="page single">
{{- /* Title */ -}}
<h1 class="post-title animated pulse faster">
{{- .Title -}}
</h1>

{{- /* Content */ -}}
<div class="post-content">
{{- partial "hook/content.html" .Content | safeHTML -}}
</div>
Expand Down
22 changes: 14 additions & 8 deletions layouts/_default/summary.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<article class="post" itemscope itemtype="http://schema.org/Article">
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}

<!--featured_image-->
{{- /* Featured image */ -}}
{{- with .Params.featured_image -}}
<div class="post-featured-image-preview">
{{- $image := $.Params.featured_image_preview | default . -}}
{{- partial "image" $image -}}
</div>
{{- end -}}
<!-- end featured_image-->

{{- /* Title */ -}}
<h1 class="post-title post-list-title" itemprop="name headline">
<a href="{{ .Permalink }}">{{ .Title }}</a>
</h1>

{{- /* Meta */ -}}
<div class="post-meta">
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
<a class="author" href="{{ $author_link }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}
</a>
{{ T "publish" }}&nbsp;<time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;

{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{ T "publish" }} <time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;

{{- with .Params.categories -}}
<span class="post-category">
{{- T "included" -}}&nbsp;
Expand All @@ -34,6 +36,8 @@ <h1 class="post-title post-list-title" itemprop="name headline">
</span>
{{- end -}}
</div>

{{- /* Content */ -}}
<div class="post-content">
{{- if .Params.show_description -}}
<p>
Expand All @@ -43,6 +47,8 @@ <h1 class="post-title post-list-title" itemprop="name headline">
{{- partial "hook/content.html" .Summary | safeHTML -}}
{{- end -}}
</div>

{{- /* Footer */ -}}
<div class="post-footer">
<a href="{{ .Permalink }}">{{ T "readMore" }}</a>
{{- with .Params.tags -}}
Expand Down
7 changes: 6 additions & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{- define "content" -}}
{{- /* Home mode [post] */ -}}
{{- if eq .Site.Params.home_mode "post" -}}
<div class="page">
{{- /* Profile */ -}}
{{- partial "home/profile.html" . -}}

{{- /* Paginate */ -}}
{{- $paginator := where .Site.RegularPages "Type" "posts" -}}
{{- $paginator = where $paginator "Params.show_in_homepage" "!=" false -}}
{{- with .Site.Params.home_paginate -}}
Expand All @@ -13,10 +16,12 @@
{{- range $paginator.Pages -}}
{{- .Render "summary" -}}
{{- end -}}

{{- partial "paginator.html" . -}}
</div>

{{- /* Home mode [other] */ -}}
{{- else -}}
{{- /* Profile */ -}}
{{- partial "home/profile.html" . -}}
{{- end -}}
{{- end -}}
76 changes: 44 additions & 32 deletions layouts/partials/comments.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{{- if eq (getenv "HUGO_ENV") "production" | and .IsPage | and (ne .Params.comment false) -}}
<!-- Disqus Comment System-->
{{- /* Disqus Comment System */ -}}
{{- if .Site.Params.disqus.shortname -}}
<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...
// discussions from "localhost" 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.Params.disqus.shortname }}";
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="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com/" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{{- end -}}

<!-- gitalk Comment System-->
{{- /* Gitalk Comment System */ -}}
{{- if .Site.Params.gitalk.owner -}}
<div id="gitalk-container"></div>
{{- if .Site.Params.cdn.gitalk_css -}}
Expand All @@ -35,22 +33,28 @@
<script src="{{ $res.RelPermalink }}"></script>
{{- end -}}
<script type="text/javascript">
var gitalk = new Gitalk({
id: "{{ .Date }}",
title: "{{ .Title }}",
clientID: "{{ .Site.Params.gitalk.clientId }}",
clientSecret: "{{ .Site.Params.gitalk.clientSecret }}",
repo: "{{ .Site.Params.gitalk.repo }}",
owner: "{{ .Site.Params.gitalk.owner }}",
admin: ["{{ .Site.Params.gitalk.owner }}"],
body: decodeURI(location.href)
});
gitalk.render("gitalk-container");
(function () {
// Don't ever inject Gitalk on localhost--it creates unwanted
// discussions from "localhost" on your Gitalk account...
if (window.location.hostname == "localhost")
return;
var gitalk = new Gitalk({
id: "{{ .Date }}",
title: "{{ .Title }}",
clientID: "{{ .Site.Params.gitalk.clientId }}",
clientSecret: "{{ .Site.Params.gitalk.clientSecret }}",
repo: "{{ .Site.Params.gitalk.repo }}",
owner: "{{ .Site.Params.gitalk.owner }}",
admin: ["{{ .Site.Params.gitalk.owner }}"],
body: decodeURI(location.href)
});
gitalk.render("gitalk-container");
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by gitalk.</a></noscript>
<noscript>Please enable JavaScript to view the <a href="https://github.com/gitalk/gitalk">comments powered by Gitalk.</a></noscript>
{{- end -}}

<!-- valine -->
{{- /* Valine Comment System */ -}}
{{- if .Site.Params.valine.enable -}}
<div id="vcomments"></div>
{{- if .Site.Params.cdn.valine_js -}}
Expand All @@ -60,23 +64,30 @@
<script src="{{ $res.RelPermalink }}"></script>
{{- end -}}
<script type="text/javascript">
new Valine({
el: "#vcomments",
appId: "{{ .Site.Params.valine.appId }}",
appKey: "{{ .Site.Params.valine.appKey }}",
meta: ["nick", "mail"],
notify: "{{ .Site.Params.valine.notify }}",
verify: "{{ .Site.Params.valine.verify }}",
avatar: "{{ .Site.Params.valine.avatar }}",
placeholder: "{{ .Site.Params.valine.placeholder }}",
visitor: "{{ .Site.Params.valine.visitor }}",
recordIP: "{{ .Site.Params.valine.recordIP }}",
lang: "{{ T `valineLang` }}",
});
(function () {
// Don't ever inject Valine on localhost--it creates unwanted
// discussions from "localhost" on your Valine account...
if (window.location.hostname == "localhost")
return;
new Valine({
el: "#vcomments",
appId: "{{ .Site.Params.valine.appId }}",
appKey: "{{ .Site.Params.valine.appKey }}",
meta: ["nick", "mail"],
notify: "{{ .Site.Params.valine.notify }}",
verify: "{{ .Site.Params.valine.verify }}",
avatar: "{{ .Site.Params.valine.avatar }}",
placeholder: "{{ .Site.Params.valine.placeholder }}",
visitor: "{{ .Site.Params.valine.visitor }}",
recordIP: "{{ .Site.Params.valine.recordIP }}",
lang: "{{ T `valineLang` }}",
});
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://valine.js.org/">comments powered by Valine.</a></noscript>
{{- end -}}

<!-- facebook comment -->
{{- /* Facebook Comment System */ -}}
{{- if .Site.Params.facebook.enable -}}
<div id="fb-root"></div>
<script
Expand All @@ -91,5 +102,6 @@
data-width="{{ .Site.Params.facebook.width }}"
data-numposts="{{ .Site.Params.facebook.numPosts }}"
></div>
<noscript>Please enable JavaScript to view the <a href="https://developers.facebook.com/docs/plugins/comments/">comments powered by Facebook.</a></noscript>
{{- end -}}
{{- end -}}
Loading

0 comments on commit 52c7ad2

Please sign in to comment.