From f304f30d95af9f9f115f4813d41824c934e15747 Mon Sep 17 00:00:00 2001 From: Kang Cheng <kcheng@utilitywarehouse.co.uk> Date: Thu, 23 Aug 2018 22:51:26 +0100 Subject: [PATCH] feat: add wildfire comment plug-in support --- _config.yml | 26 +++++++++++ _includes/_macro/post.html | 10 +++++ _includes/_partials/comments.html | 2 + _includes/_third-party/comments/index.html | 1 + _includes/_third-party/comments/wildfire.html | 44 +++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 _includes/_third-party/comments/wildfire.html diff --git a/_config.yml b/_config.yml index 6f99140c74..6f631d740a 100644 --- a/_config.yml +++ b/_config.yml @@ -387,6 +387,32 @@ disqus: # count need to be false when hide is true hide: false +# <wildfire> +wildfire: + enable: false + # version - It's recommended to use the following versions. + loaderVersion: 1.2.5 # https://www.npmjs.com/package/wildfire-comment + useDev: true + version: 0.5.6 + # database config + databaseProvider: firebase # or wilddog + firebase: # your firebase config goes here ↓ + apiKey: + authDomain: + databaseURL: + projectId: + storageBucket: + messagingSenderId: + wilddog: # your wilddog config goes here ↓ + siteId: + # other configs + theme: light # or dark + locale: en # or other locales, e.g. zh-CN + defaultAvatarURL: +# Any question? +# Raise an issue here: https://github.com/cheng-kang/wildfire/issues +# </wildfire> + # Hypercomments #hypercomments_id: diff --git a/_includes/_macro/post.html b/_includes/_macro/post.html index b63a1267aa..0036aabf0d 100644 --- a/_includes/_macro/post.html +++ b/_includes/_macro/post.html @@ -146,6 +146,16 @@ data-disqus-identifier="{{ post.url }}" itemprop="commentCount"></span> </a> </span> + {% elsif site.wildfire.enable %} + <span class="post-comments-count"> + <span class="post-meta-divider">|</span> + <span class="post-meta-item-icon"> + <i class="fa fa-comment-o"></i> + </span> + <a href="{{ post.url | relative_url }}#comments" itemprop="discussionUrl"> + <span class="post-comments-count wf-count-unit" wf-page-url="{{ post.url | absolute_url }}" itemprop="commentCount"></span> + </a> + </span> {% elsif site.hypercomments_id %} <!--noindex--> <span class="post-comments-count"> diff --git a/_includes/_partials/comments.html b/_includes/_partials/comments.html index 8233373b76..939ff0f210 100644 --- a/_includes/_partials/comments.html +++ b/_includes/_partials/comments.html @@ -32,6 +32,8 @@ <div id="lv-container" data-id="city" data-uid="{{ site.livere_uid }}"></div> {% elsif site.changyan.appid and site.changyan.appkey %} <div id="SOHUCS"></div> + {% elsif site.wildfire.enable %} + <div class="wildfire_thread"></div> {% endif %} </div> {% endif %} diff --git a/_includes/_third-party/comments/index.html b/_includes/_third-party/comments/index.html index 523c45e498..6e20bf36e6 100644 --- a/_includes/_third-party/comments/index.html +++ b/_includes/_third-party/comments/index.html @@ -6,3 +6,4 @@ {% include _third-party/comments/youyan.html %} {% include _third-party/comments/livere.html %} {% include _third-party/comments/changyan.html %} +{% include _third-party/comments/wildfire.html %} diff --git a/_includes/_third-party/comments/wildfire.html b/_includes/_third-party/comments/wildfire.html new file mode 100644 index 0000000000..7b07d39b0e --- /dev/null +++ b/_includes/_third-party/comments/wildfire.html @@ -0,0 +1,44 @@ +{% if site.wildfire.enable %} + <script type="text/javascript"> + var wildfireConfig = () => ({ + {% if site.wildfire.useDev %} + useDev: {{site.wildfire.useDev}}, + {% endif %} + {% if site.wildfire.version %} + version: '{{site.wildfire.version}}', + {% endif %} + databaseProvider: '{{site.wildfire.databaseProvider}}', + databaseConfig: { + {% if site.wildfire.databaseProvider == 'firebase' %} + apiKey: '{{site.wildfire.firebase.apiKey}}', + authDomain: '{{site.wildfire.firebase.authDomain}}', + databaseURL: '{{site.wildfire.firebase.databaseURL}}', + projectId: '{{site.wildfire.firebase.projectId}}', + storageBucket: '{{site.wildfire.firebase.storageBucket}}', + messagingSenderId: '{{site.wildfire.firebase.messagingSenderId}}' + {% else %} + siteId: '{{site.wildfire.wilddog.siteId}}' + {% endif %} + }, + pageURL: '{{ page.url | absolute_url }}', + pageTitle: '{{ page.title| replace: "'", "\\'" }}', + {% if site.wildfire.theme %} + theme: '{{site.wildfire.theme}}', + {% endif %} + {% if site.wildfire.locale %} + locale: '{{site.wildfire.locale}}', + {% endif %} + {% if site.wildfire.defaultAvatarURL %} + defaultAvatarURL: '{{site.wildfire.defaultAvatarURL}}' + {% endif %} + }); + </script> + {% if page.comments %} + {% if site.wildfire.loaderVersion %} + <script src="https://unpkg.com/wildfire-comment@{{site.wildfire.loaderVersion}}"></script> + {% else %} + <script src="https://unpkg.com/wildfire-comment"></script> + {% endif %} + {% endif %} + <script src="https://unpkg.com/wf-count"></script> +{% endif %}