Skip to content

Commit

Permalink
style(partial): split comments to file
Browse files Browse the repository at this point in the history
  • Loading branch information
Zijung Chueh committed Oct 3, 2018
1 parent 8bb9615 commit 9278fc3
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 50 deletions.
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
.sass-cache
.DS_Store
.eslintcache
npm-debug.log
yarn-error.log
node_modules
!.gitignore
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ disqusShortname = "disqus_shortname"

[params]
# Changyan Comments (China Only)
changyan = false
changyanId = "your_changyan_id"
changyanConf = "your_changyan_conf"
Changyan = false
ChangyanId = "your_changyan_id"
ChangyanConf = "your_changyan_conf"
```

If you want to use Disqus, you should disable `changyan` to `false`.

### The works page

The works page layout is under development, you can use github homepage for replacement temporarily.
Expand Down
6 changes: 3 additions & 3 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ copyright = "© This post is licensed under a Creative Commons Attribution-NonCo
# bilibili = "bilibili_id_number"

# Changyan Comments (China Only)
changyan = false
changyanId = "cyt3toRiB"
changyanConf = "prod_0908b1cb9a581501753cce1ed074dbe3"
Changyan = false
ChangyanId = "cyt3toRiB"
ChangyanConf = "prod_0908b1cb9a581501753cce1ed074dbe3"

# Google Webmaster
# https://www.google.com/webmasters/
Expand Down
15 changes: 1 addition & 14 deletions layouts/_default/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,7 @@
<h1 class="post-title">{{ .Title }}</h1>
</header>
<article class="post-content">{{ .Content }}</article>
{{ if ne .Params.comments false }}
{{ if .Site.Params.changyan }}
<div id="SOHUCS" sid="{{ .URL }}" ></div>
<script type="text/javascript">
(function(){
var appid = '{{ .Site.Params.changyanId }}';
var conf = '{{ .Site.Params.changyanConf }}';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>
{{ else if .Site.Params.Gitment }}{{ partial "gitment.html" . }}
{{ else if .Site.DisqusShortname }}{{ template "_internal/disqus.html" . }}
{{ else }}{{ end }}
{{ end }}
{{ partial "comments.html" . }}
</section>
{{ partial "footer.html" . }}
{{ end }}
12 changes: 6 additions & 6 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
<div class="suspension">
<a title="Go to top" class="to-top is-hide"><span class="icon icon-up"></span></a>
{{ if and (eq .Type "post") (eq .Kind "page") }}
{{ if .Site.Params.changyan }}
<a title="Go to comments" class="to-comment" href="#SOHUCS"><span class="icon icon-comment"></span></a>
{{ else if .Site.DisqusShortname }}
<a title="Go to comments" class="to-comment" href="#disqus_thread"><span class="icon icon-comment"></span></a>
{{ if .Site.DisqusShortname }}
<a title="Go to comments" class="to-comment" href="#disqus_thread"><span class="icon icon-comment"></span></a>
{{ else if .Site.Params.Gitment }}
<a title="Go to comments" class="to-comment" href="#gitment-container"><span class="icon icon-comment"></span></a>
{{ else }}{{ end }}
<a title="Go to comments" class="to-comment" href="#gitment-container"><span class="icon icon-comment"></span></a>
{{ else if .Site.Params.Changyan }}
<a title="Go to comments" class="to-comment" href="#SOHUCS"><span class="icon icon-comment"></span></a>
{{ end }}
{{ end }}
</div>
{{ end }}
Expand Down
13 changes: 13 additions & 0 deletions layouts/partials/changyan.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div id="cyReward" role="cylabs" data-use="reward"></div>
<script src="https://changyan.itc.cn/js/lib/jquery.js"></script>
<script src="https://changyan.sohu.com/js/changyan.labs.https.js?appid={{ .Site.Params.ChangyanId }}"></script>
<div id="SOHUCS" sid="{{ .URL }}" ></div>
<script>
(function(){
var appid = '{{ .Site.Params.ChangyanId }}';
var conf = '{{ .Site.Params.ChangyanConf }}';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); }
})();
</script>
5 changes: 5 additions & 0 deletions layouts/partials/comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ if ne .Params.comments false }}
{{ if .Site.DisqusShortname }}{{ template "_internal/disqus.html" . }}{{ end }}
{{ if .Site.Params.Gitment }}{{ partial "gitment.html" . }}{{ end }}
{{ if .Site.Params.Changyan }}{{ partial "changyan.html" . }}{{ end }}
{{ end }}
18 changes: 1 addition & 17 deletions layouts/post/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,7 @@ <h1 class="post-title">{{ .Title }}</h1>
{{ if .Site.Copyright }}{{ .Site.Copyright }}{{ end }}{{ if gt (div (sub now.Unix .Lastmod.Unix) 86400) 100 }}This post was published <strong>{{ div (sub now.Unix .Lastmod.Unix) 86400 }}</strong> days ago, content in the post may be inaccurate, even wrong now, please take risk yourself.{{ end }}
</p>
</footer>
{{ if ne .Params.comments false }}
{{ if .Site.Params.changyan }}
<div id="cyReward" role="cylabs" data-use="reward"></div>
<script src="//changyan.itc.cn/js/lib/jquery.js"></script>
<script src="//changyan.sohu.com/js/changyan.labs.https.js?appid={{ .Site.Params.changyanId }}"></script>
<div id="SOHUCS" sid="{{ .URL }}" ></div>
<script>
(function(){
var appid = '{{ .Site.Params.changyanId }}';
var conf = '{{ .Site.Params.changyanConf }}';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>
{{ else if .Site.Params.Gitment }}{{ partial "gitment.html" . }}
{{ else if .Site.DisqusShortname }}{{ template "_internal/disqus.html" . }}
{{ else }}{{ end }}
{{ end }}
{{ partial "comments.html" . }}
</section>
{{ partial "footer.html" . }}
{{ end }}

0 comments on commit 9278fc3

Please sign in to comment.