소스 검색

Added Disqus support

digitalcraftsman 9 년 전
부모
커밋
62ef2ef06f
3개의 변경된 파일45개의 추가작업 그리고 10개의 파일을 삭제
  1. 17
    0
      README.md
  2. 14
    10
      layouts/_default/single.html
  3. 14
    0
      layouts/partials/disqus.html

+ 17
- 0
README.md 파일 보기

@@ -13,6 +13,7 @@ It pairs a prominent sidebar with uncomplicated content.
13 13
   - [Sticky sidebar content](#sticky-sidebar-content)
14 14
   - [Themes](#themes)
15 15
   - [Reverse layout](#reverse-layout)
16
+  - [Disqus](#disqus)
16 17
 - [Development](#development)
17 18
 - [Author](#author)
18 19
 - [Ported by](#ported-by)
@@ -92,6 +93,22 @@ Hyde's page orientation can be reversed with a single class.
92 93
 </body>
93 94
 ```
94 95
 
96
+### Disqus
97
+
98
+You can optionally enable a comment system powered by Disqus for the posts. Simply add the variable `disqusShortname` to the `params` in your config file.
99
+
100
+**TOML**
101
+```toml
102
+[params]
103
+  disqusShortname = "spf13"
104
+```
105
+
106
+**YAML**
107
+```yaml
108
+params:
109
+  disqusShortname: "spf13"
110
+```
111
+
95 112
 ## Author
96 113
 **Mark Otto**
97 114
 - <https://github.com/mdo>

+ 14
- 10
layouts/_default/single.html 파일 보기

@@ -1,15 +1,19 @@
1
-{{ partial "head.html" . }}
2
-<body class="{{ .Site.Params.themeColor }}">
1
+	{{ partial "head.html" . }}
2
+	<body class="{{ .Site.Params.themeColor }}">
3
+		{{ partial "sidebar.html" . }}
3 4
 
4
-{{ partial "sidebar.html" . }}
5
+		<div class="content container">
6
+			<div class="post">
7
+			 	<h1>{{ .Title }}</h1>
8
+			  <span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
9
+			      {{ .Content }}
10
+			</div>
5 11
 
6
-    <div class="content container">
7
-<div class="post">
8
-  <h1>{{ .Title }}</h1>
9
-  <span class="post-date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
10
-      {{ .Content }}
11
-</div>
12
-</div>
12
+			{{ if and (isset .Site.Params "disqusShortname") (ne .Site.Params.disqusShortname "") }}
13
+				<h2>Comments</h2>
14
+				{{ partial "disqus" . }}
15
+			{{ end }}
16
+		</div>
13 17
 
14 18
   </body>
15 19
 </html>

+ 14
- 0
layouts/partials/disqus.html 파일 보기

@@ -0,0 +1,14 @@
1
+<div id="disqus_thread"></div>
2
+<script type="text/javascript">
3
+    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
4
+    var disqus_shortname = '{{ .Site.Params.disqusShortname }}'; // Required - Replace '<example>' with your forum shortname
5
+
6
+    /* * * DON'T EDIT BELOW THIS LINE * * */
7
+    (function() {
8
+        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
9
+        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
10
+        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
11
+    })();
12
+</script>
13
+<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
14
+</div>