<%
var pageId = page.path;
var pageUrl = page.permalink;
var pageTitle = page.title;
%>

<% if (theme.disqus_shortname && page.comments){ %>
    <section id="comment">
        <div id="disqus_thread"></div>
        <script>
            var disqus_config = function() {
                this.page.url = '<%= pageUrl %>';
                this.page.identifier = '<%= pageId %>';
            };
            (function() {
                var d = document,
                    s = d.createElement('script');
                s.src = '//<%= theme.disqus_shortname %>.disqus.com/embed.js';
                s.setAttribute('data-timestamp', + new Date());
                (d.head || d.body).appendChild(s);
            })();
        </script>
        <noscript>Please enable JavaScript to view the
            <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a>
        </noscript>
    </section>
<% } else if (theme.duoshuo_shortname && page.comments){ %>
    <section id="comment">
        <div class="card">
            <div class="card-content">
                <!-- Duoshuo Comment BEGIN -->
                <div class="ds-thread" data-thread-key="<%= pageId %>" data-title="<%= pageTitle %>" data-url="<%= pageUrl %>"></div>

                <script type="text/javascript">
                    console.log(document.querySelector('.ds-thread'));
                    var duoshuoQuery = {
                        short_name: '<%= theme.duoshuo_shortname %>'
                    };
                    (function() {
                        var ds = document.createElement('script');
                        ds.type = 'text/javascript';
                        ds.async = true;
                        ds.src = (document.location.protocol == 'https:'
                            ? 'https:'
                            : 'http:') + '//static.duoshuo.com/embed.js';
                        ds.charset = 'UTF-8';
                        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds);
                    })();
                </script>
                <!-- Duoshuo Comment END -->
            </div>
        </div>
    </section>

<% } else if (theme.yungentie_product_key && page.comments){ %>
    <div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
    <script>
      var cloudTieConfig = {
        url: document.location.href,
        sourceId: "",
        productKey: "<%= theme.yungentie_product_key %>",
        target: "cloud-tie-wrapper"
      };
    </script>
    <script src="https://img1.cache.netease.com/f2e/tie/yun/sdk/loader.js"></script>
<% } %>
