[new feature] footer link support, google tag manager support, contact getform support

This commit is contained in:
zzossig 2020-02-10 18:12:52 +09:00
parent ff273b5ebb
commit bad32c9006
21 changed files with 203 additions and 35 deletions

View File

@ -292,6 +292,7 @@ showSocialLinks = true # email, facebook, twitter ...
enableLangChange = true # show button at bottom left of footer.
# service
googleTagManager = "" # GTM-XXXXXX
baiduAnalytics = "" # alternative of google analytics
enableBusuanzi = false # if set true, total page view, total unique visitors show up in the footer.
busuanziSiteUV = true # unique visitors (total number of visitors)
@ -396,6 +397,13 @@ commento = false
username = ""
[[share]]
name = "twitter"
[[footerLinks]]
name = ""
link = ""
[[footerLinks]]
name = ""
link = ""
```
## Gallery

View File

@ -300,6 +300,7 @@ showSocialLinks = true # email, facebook, twitter ...
enableLangChange = true # show button at bottom left of footer.
# service
googleTagManager = "" # GTM-XXXXXX
baiduAnalytics = "" # alternative of google analytics
enableBusuanzi = false # if set true, total page view, total unique visitors show up in the footer.
busuanziSiteUV = true # unique visitors (total number of visitors)
@ -404,6 +405,13 @@ commento = false
[[share]]
name = "twitter"
username = ""
[[footerLinks]]
name = ""
link = ""
[[footerLinks]]
name = ""
link = ""
```
## Gallery

View File

@ -3,6 +3,7 @@ title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
description:
type: contact
service: formspree
service: formspree # formspree, getform
formId: ""
getformToken: ""
---

View File

@ -15,3 +15,9 @@
.grow {
@include flex-grow(1);
}
.basicflex {
@include flexbox();
@include align-items(center);
@include justify-content(center);
}

View File

@ -38,6 +38,11 @@
}
}
&__link {
font-size: 0.8rem;
margin: 0.25rem 0.5rem 0;
}
.dropdown {
position: absolute;
left: 0.5rem;

View File

@ -25,7 +25,9 @@
@include flexbox();
@include flex-direction(column);
@include flex-grow(1);
@include flex-grow(1);
@include flex-shrink(1);
@include flex-basis(0);
}
&--container {

View File

@ -6,9 +6,9 @@ custom_js = []
useFaviconGenerator = true # https://www.favicon-generator.org/
themeOptions = ["dark", "light", "hacker", "solarized", "kimbie"]
notAllowedTypesInHome = ["contact", "talks", "about", "showcase", "publication", "presentation"]
notAllowedTypesInHomeSidebar = ["about", "archive", "showcase", "publication", "presentation"]
notAllowedTypesInArchive = ["about", "talks", "showcase", "publication", "presentation"]
notAllowedTypesInHome = ["contact", "talks", "about", "showcase", "publication", "presentation", "resume"]
notAllowedTypesInHomeSidebar = ["about", "archive", "showcase", "publication", "presentation", "resume"]
notAllowedTypesInArchive = ["about", "talks", "showcase", "publication", "presentation", "resume"]
# header
homeHeaderType = "text" # text, img, slide
@ -63,6 +63,7 @@ enableLangChange = true
enableThemeChange = true
# service
googleTagManager = "" # GTM-XXXXXX
baiduAnalytics = ""
enableBusuanzi = false
busuanziSiteUV = true
@ -159,4 +160,11 @@ commento = false
name = "facebook"
username = ""
[[share]]
name = "twitter"
name = "twitter"
[[footerLinks]]
name = ""
link = ""
[[footerLinks]]
name = ""
link = ""

View File

@ -61,12 +61,21 @@ other = "Name"
[contact-email]
other = "Email"
[contact-tel]
other = "Tel"
[contact-file]
other = "File"
[contact-message]
other = "Message"
[contact-send]
other = "Send"
[contact-browse]
other = "Browse"
[tooltip-home]
other = "Home"

View File

@ -61,12 +61,21 @@ other = "نام"
[contact-email]
other = "ایمیل"
[contact-tel]
other = "Tel"
[contact-file]
other = "File"
[contact-message]
other = "پیام"
[contact-send]
other = "ارسال"
[contact-browse]
other = "Browse"
[tooltip-home]
other = "خانه"

View File

@ -61,12 +61,21 @@ other = "이름"
[contact-email]
other = "이메일"
[contact-tel]
other = "전화번호"
[contact-file]
other = "파일"
[contact-message]
other = "내용"
[contact-send]
other = "보내기"
[contact-browse]
other = "Browse"
[tooltip-home]
other = "홈페이지"

View File

@ -61,12 +61,21 @@ other = "姓名"
[contact-email]
other = "电子邮件"
[contact-tel]
other = "Tel"
[contact-file]
other = "File"
[contact-message]
other = "消息"
[contact-send]
other = "发送"
[contact-browse]
other = "Browse"
[tooltip-home]
other = "主页"

View File

@ -6,15 +6,13 @@
</header>
<main class="main">
<div class="contact">
<article class="single__contents contact__desc" data-dir="{{ if ne ($.Param "languagedir") "rtl" }}ltr{{ else }}rtl{{ end }}">
{{ .Content }}
</article>
{{ if eq .Params.service "formspree" }}
<article class="single__contents contact__desc" data-dir="{{ if ne ($.Param "languagedir") "rtl" }}ltr{{ else }}rtl{{ end }}">
{{ .Content }}
</article>
{{ partial "contact/formspree" . }}
{{ else }}
<article class="single__contents contact__desc" data-dir="{{ if ne ($.Param "languagedir") "rtl" }}ltr{{ else }}rtl{{ end }}">
{{ .Content }}
</article>
{{ else if eq .Params.service "getform" }}
{{ partial "contact/getform" . }}
{{ end }}
</div>
</main>

View File

@ -0,0 +1,51 @@
<form action="https://getform.io/f/{{ with .Params.getformToken }}{{ . }}{{ end }}" method="POST" class="contact__form">
<div class="contact__input--container">
<div class="contact__input--wrapper">
<label class="contact__label">
{{ i18n "contact-name" }}
</label>
<input type="text" name="name" class="contact__input" aria-label="{{ i18n "contact-name" }}">
</div>
<div class="contact__input--wrapper">
<label class="contact__label">
{{ i18n "contact-email" }}
</label>
<input type="email" name="email" class="contact__input" aria-label="{{ i18n "contact-email" }}">
</div>
</div>
<div class="contact__input--container">
<div class="contact__input--wrapper">
<label class="contact__label">
{{ i18n "contact-tel" }}
</label>
<input type="text" name="tel" class="contact__input" aria-label="{{ i18n "contact-tel" }}">
</div>
<div class="contact__input--wrapper">
<label class="contact__label">
{{ i18n "contact-file" }}
</label>
<input type="file" id="upload" name="file" style="display: none;">
<input type="button" id="uploadBtn" value="{{ i18n "contact-browse" | default "Browse..." }}" class="contact__input" aria-label="{{ i18n "contact-file" }}"/>
</div>
</div>
<input type="submit" value="{{ i18n "contact-send" }}" class="contact__send">
</form>
<script>
var uploadBtn = document.querySelector('#uploadBtn');
uploadBtn.addEventListener('click', function(elem) {
var upload = document.querySelector('#upload');
upload.click();
upload.onchange = function(e) {
var fullPath = e.target.value;
if (fullPath) {
var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/'));
var filename = fullPath.substring(startIndex);
if (filename.indexOf('\\') === 0 || filename.indexOf('/') === 0) {
filename = filename.substring(1);
}
uploadBtn.setAttribute('value', filename);
}
}
});
</script>

View File

@ -4,6 +4,12 @@
{{ partial "footer/go-to-top" . }}
<hr />
<div class="basicflex">
{{ range $.Param "footerLinks" }}
<a href="{{ .link }}" class="footer__link" target="_blank" rel="noreferrer">{{ .name }}</a>
{{ end }}
</div>
<div class="footer__poweredby">
{{ partial "footer/site-counter" . }}
{{ if $.Site.Copyright }}
@ -26,5 +32,6 @@
{{ if $.Param "showPoweredBy" }}
<p class="caption">Powered by <a href="https://gohugo.io/" rel="noreferrer">Hugo</a> and the <a href="https://github.com/zzossig/hugo-theme-zzo" rel="noreferrer">Zzo theme</a></p>
{{ end }}
</div>
</footer>

View File

@ -1,21 +1,4 @@
{{ template "_internal/google_analytics.html" . }}
{{ template "_internal/google_analytics_async.html" . }}
{{ if .Site.Params.baiduAnalytics }}
<script>
{{ $baiduAnalyticsId := .Site.Params.baiduAnalytics }}
var baiduAnalyticsId = JSON.parse({{ $baiduAnalyticsId | jsonify }});
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?" + baiduAnalyticsId;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
{{ end }}
{{ if .Site.Params.enableBusuanzi }}
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{{ end }}
{{ partial "service/google-analytics" . }}
{{ partial "service/google-tag-manager" . }}
{{ partial "service/baidu-analytics" . }}
{{ partial "service/busuanzi" . }}

View File

@ -0,0 +1,14 @@
{{ if and (.Site.Params.baiduAnalytics) (not .Site.IsServer) }}
<script>
{{ $baiduAnalyticsId := .Site.Params.baiduAnalytics }}
var baiduAnalyticsId = JSON.parse({{ $baiduAnalyticsId | jsonify }});
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?" + baiduAnalyticsId;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
{{ end }}

View File

@ -0,0 +1,3 @@
{{ if .Site.Params.enableBusuanzi }}
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{{ end }}

View File

@ -0,0 +1,15 @@
{{ if and (not .Site.IsServer) (not ($.Param "disableAdsense")) }}
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins
class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="ca-pub-xxxxxx"
data-ad-slot="xxxxx"
>
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
{{ end }}

View File

@ -0,0 +1,4 @@
{{ if not .Site.IsServer }}
{{ template "_internal/google_analytics.html" . }}
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}

View File

@ -0,0 +1,19 @@
{{ if and ($.Site.Params.googleTagManager) (not .Site.IsServer) }}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ $.Site.Params.googleTagManager }}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{{ end }}
{{ if and ($.Site.Params.googleTagManager) (not .Site.IsServer) }}
<!-- Google Tag Manager -->
<!-- create dataLayer -->
<script>
var dataLayer = window.dataLayer = window.dataLayer || [];
dataLayer.push({
page:'{{ .Title }}',
categories:'only examples about your dataLayer'
});
</script>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','{{ $.Site.Params.googleTagManager }}');</script>
<!-- End Google Tag Manager -->
{{ end }}