Browse Source

Added Disqus support

digitalcraftsman 9 years ago
parent
commit
62ef2ef06f
3 changed files with 45 additions and 10 deletions
  1. 17
    0
      README.md
  2. 14
    10
      layouts/_default/single.html
  3. 14
    0
      layouts/partials/disqus.html

+ 17
- 0
README.md View File

13
   - [Sticky sidebar content](#sticky-sidebar-content)
13
   - [Sticky sidebar content](#sticky-sidebar-content)
14
   - [Themes](#themes)
14
   - [Themes](#themes)
15
   - [Reverse layout](#reverse-layout)
15
   - [Reverse layout](#reverse-layout)
16
+  - [Disqus](#disqus)
16
 - [Development](#development)
17
 - [Development](#development)
17
 - [Author](#author)
18
 - [Author](#author)
18
 - [Ported by](#ported-by)
19
 - [Ported by](#ported-by)
92
 </body>
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
 ## Author
112
 ## Author
96
 **Mark Otto**
113
 **Mark Otto**
97
 - <https://github.com/mdo>
114
 - <https://github.com/mdo>

+ 14
- 10
layouts/_default/single.html View File

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
   </body>
18
   </body>
15
 </html>
19
 </html>

+ 14
- 0
layouts/partials/disqus.html View File

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>