Temporarily enable disqus just to see what happens

This commit is contained in:
Rico Sta. Cruz 2017-09-02 03:20:24 +08:00
parent 7c9dbfddad
commit b9ad710b7a
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
7 changed files with 120 additions and 5 deletions

View File

@ -1,4 +1,7 @@
# gems #
# Jekyll configuration
#
whitelist: whitelist:
- jekyll-redirect-from - jekyll-redirect-from
- jekyll-github-metadata - jekyll-github-metadata
@ -7,7 +10,6 @@ plugins:
- jekyll-redirect-from - jekyll-redirect-from
- jekyll-github-metadata - jekyll-github-metadata
# files
exclude: exclude:
- Makefile - Makefile
- README.md - README.md
@ -17,7 +19,10 @@ exclude:
- vendor - vendor
- _deprecated - _deprecated
#
# Markdown # Markdown
#
highlighter: false highlighter: false
markdown: kramdown markdown: kramdown
kramdown: kramdown:
@ -27,6 +32,10 @@ kramdown:
syntax_highlighter_opts: syntax_highlighter_opts:
disable: true disable: true
#
# Defaults
#
defaults: defaults:
- scope: - scope:
path: "" path: ""
@ -44,15 +53,25 @@ defaults:
- elixir - elixir
- ruby - ruby
#
# Site info # Site info
#
url: http://ricostacruz.com/cheatsheets url: http://ricostacruz.com/cheatsheets
title: Cheatsheets title: Cheatsheets
#
# Google analytics # Google analytics
#
#
analytics: analytics:
hostname: ricostacruz.com hostname: ricostacruz.com
id: "UA-20473929-1" id: "UA-20473929-1"
#
# Categories
#
category_names: category_names:
- Ansible - Ansible
- Apps - Apps
@ -78,3 +97,9 @@ category_names:
# https://help.github.com/articles/repository-metadata-on-github-pages/ # https://help.github.com/articles/repository-metadata-on-github-pages/
repository: rstacruz/cheatsheets repository: rstacruz/cheatsheets
#
# Disqus comments: uncomment to disable disqus
#
disqus_host: devhints.disqus.com

View File

@ -0,0 +1,10 @@
<section class='comments-area'>
<div class='container'>
<div class='comments-section'>
<div class='comments'>
<div id='disqus_thread'></div>
<noscript data-js-disqus='{"host":"{{ site.disqus_host }}","url":"{{ site.url }}{{ include.page.url | remove: '.html' }}","identifier": "{{ include.page.url | remove: '.html' | remove_first: '/' }}"}'></noscript>
</div>
</div>
</div>
</section>

View File

@ -26,6 +26,10 @@ type: article
</main> </main>
</div> </div>
{% if site.disqus_host %}
{% include 2017/comments-area.html page=page %}
{% endif %}
<div class='pre-footer'><i class='icon'></i></div> <div class='pre-footer'><i class='icon'></i></div>
{% include 2017/search-footer.html %} {% include 2017/search-footer.html %}

View File

@ -0,0 +1,16 @@
/*
* Disqus
*/
.comments-area {
& {
margin: 32px 0;
}
& > .container {
@include gutter(padding-left);
@include gutter(padding-right);
max-width: $area-width;
margin: 0 auto;
}
}

View File

@ -0,0 +1,25 @@
/*
* Disqus
*/
.comments-section {
& {
display: flex;
}
// Mobile: full width
@media (max-width: 480px) {
& > .comments {
flex: 1 0 100%;
width: 100%;
}
}
// Desktop: partial width
@media (min-width: 481px) {
& > .comments {
flex: 0 1 66%;
min-width: 300px;
}
}
}

View File

@ -17,6 +17,8 @@
@import './components/attribute-peg'; @import './components/attribute-peg';
@import './components/back-button'; @import './components/back-button';
@import './components/body-area'; @import './components/body-area';
@import './components/comments-area';
@import './components/comments-section';
@import './components/h2-section'; @import './components/h2-section';
@import './components/h3-section'; @import './components/h3-section';
@import './components/h3-section-list'; @import './components/h3-section-list';

View File

@ -1,5 +1,5 @@
/* /*
* Wrapping * Behavior: Wrapping
*/ */
$(function () { $(function () {
@ -8,7 +8,7 @@ $(function () {
}) })
/* /*
* Isotope * Behavior: Isotope
*/ */
$(function () { $(function () {
@ -21,7 +21,7 @@ $(function () {
}) })
/* /*
* Search * Behavior: Search
*/ */
$(function () { $(function () {
@ -50,6 +50,10 @@ $(function () {
}) })
}) })
/*
* Behavior: search input
*/
$(function () { $(function () {
$('[data-js-search-input]').each(function () { $('[data-js-search-input]').each(function () {
const $this = $(this) const $this = $(this)
@ -83,6 +87,35 @@ $(function () {
}) })
}) })
/*
* Behavior: Disqus
*/
$(function () {
$('[data-js-disqus]').each(function () {
const $this = $(this)
const data = $this.data('js-disqus')
window.disqus_config = function () {
this.page.url = data.url
this.page.identifier = data.identifier
}
injectDisqus(data.host)
})
})
/*
* Helper: injects disqus
*/
function injectDisqus (host) {
var d = document, s = d.createElement('script')
s.src = 'https://' + host + '/embed.js'
s.setAttribute('data-timestamp', +new Date())
;(d.head || d.body).appendChild(s)
}
/* /*
* Helper for splitting to words * Helper for splitting to words
*/ */