diff --git a/assets/js/process.js b/assets/js/process.js
index 19712533..15f14c3e 100644
--- a/assets/js/process.js
+++ b/assets/js/process.js
@@ -1,5 +1,6 @@
if (typeof auth !== 'undefined') {
var viewsCollection = db.collection('views');
+ var likesCollection = db.collection('likes');
function numberWithCommas(x) {
//return x.toString().replace(/\B(? {
+ var data = doc.data();
+ if (data) {
+ var label = document.querySelectorAll("span[id='" + oid + "']")[0].innerText.split(' ')[1]
+ document.querySelectorAll("span[id='" + oid + "']")[0].innerText = numberWithCommas(data.likes) + " " + label
+ }
+ })
+ }
+
auth.signInAnonymously()
.then(() => {
@@ -28,6 +39,16 @@ if (typeof auth !== 'undefined') {
update_views(oid, id)
}
}
+
+ var likes_nodes = document.querySelectorAll("span[id^='likes_']")
+
+ for (var i in likes_nodes) {
+ var oid = likes_nodes[i].id
+ var id = oid ? oid.replaceAll("/", "-") : oid
+ if (id) {
+ update_likes(oid, id)
+ }
+ }
})
.catch((error) => {
var errorCode = error.code;
diff --git a/config/_default/params.toml b/config/_default/params.toml
index b6b05bb9..16d479d5 100644
--- a/config/_default/params.toml
+++ b/config/_default/params.toml
@@ -31,6 +31,7 @@ enableCodeCopy = true
[article]
showDate = true
#showViews = true
+ #showLikes = true
showDateUpdated = false
showAuthor = true
showBreadcrumbs = true
diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml
index 3ba885d4..7b2a55c2 100644
--- a/exampleSite/config/_default/params.toml
+++ b/exampleSite/config/_default/params.toml
@@ -31,6 +31,7 @@ mainSections = ["docs", "samples"]
[article]
showDate = true
showViews = true
+ showLikes = true
showDateUpdated = false
showAuthor = true
showBreadcrumbs = true
@@ -44,7 +45,7 @@ mainSections = ["docs", "samples"]
showReadingTime = true
showTableOfContents = true
showTaxonomies = false
- showWordCount = true
+ showWordCount = false
showSummary = true
sharingLinks = [ "linkedin", "twitter", "whatsapp", "pinterest", "reddit", "facebook", "email"]
diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md
index b29f23b9..dcf2b123 100644
--- a/exampleSite/content/docs/configuration/index.md
+++ b/exampleSite/content/docs/configuration/index.md
@@ -141,6 +141,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
|`homepage.showMoreLinkDest`|'/posts'|The destination of the show more button.|
|`article.showDate`|`true`|Whether or not article dates are displayed.|
|`article.showViews`|`false`|Whether or not article views are displayed. This requires firebase integrations to be enabled, look below.|
+|`article.showLikes`|`false`|Whether or not article likes are displayed. This requires firebase integrations to be enabled, look below.|
|`article.showDateUpdated`|`false`|Whether or not the dates articles were updated are displayed.|
|`article.showAuthor`|`true`|Whether or not the author box is displayed in the article footer.|
|`article.showBreadcrumbs`|`false`|Whether or not breadcrumbs are displayed in the article header.|
diff --git a/exampleSite/content/docs/firebase-views/index.md b/exampleSite/content/docs/firebase-views/index.md
index ab273ad2..47c47ee5 100644
--- a/exampleSite/content/docs/firebase-views/index.md
+++ b/exampleSite/content/docs/firebase-views/index.md
@@ -1,10 +1,10 @@
---
-title: "Firebase & Views"
+title: "Firebase: Views & Likes"
date: 2020-08-03
draft: false
-description: "Learn how to integrate Firebase and get dynamic data like views."
+description: "Learn how to integrate Firebase and get dynamic data for views and likes."
slug: "firebase-views"
-tags: ["firebase", "views"]
+tags: ["firebase", "views", likes]
---
In order to be able to support dynamic data across your website we've added the support to integrate Firebase. This will allow you to use the views feature across lists and posts.
@@ -50,4 +50,4 @@ service cloud.firestore {
}
```
6. Enable anonymous authorization - Select Build and open Authentication. Select get started, click Anonymous and turn it on, save.
-7. Enjoy - you can now activate views on Blowfish for all (or specific) articles.
+7. Enjoy - you can now activate views and likes on Blowfish for all (or specific) articles.
diff --git a/exampleSite/content/docs/front-matter/index.md b/exampleSite/content/docs/front-matter/index.md
index 68d4e485..f07de750 100644
--- a/exampleSite/content/docs/front-matter/index.md
+++ b/exampleSite/content/docs/front-matter/index.md
@@ -38,6 +38,7 @@ Front matter parameter default values are inherited from the theme's [base confi
|`showComments`|`article.showComments`|Whether or not the [comments partial]({{< ref "partials#comments" >}}) is included after the article footer.|
|`showSummary`|`list.showSummary`|Whether or not the article summary should be displayed on list pages.|
|`showViews`|`article.showViews`|Whether or not the article views should be displayed in lists and detailed view. This requires a firebase integration. Check [this page]({{< ref "firebase-views" >}}) for a guide on how to integrate Firebase into Blowfish|
+|`showLikes`|`article.showLikes`|Whether or not the article likes should be displayed in lists and detailed view. This requires a firebase integration. Check [this page]({{< ref "firebase-views" >}}) for a guide on how to integrate Firebase into Blowfish|
|`summary`|Auto generated using `summaryLength` (see [site configuration]({{< ref "configuration#site-configuration" >}}))|When `showSummary` is enabled, this is the Markdown string to be used as the summary for this article.|
|`xml`|`true` unless excluded by `sitemap.excludedKinds`|Whether or not this article is included in the generated `/sitemap.xml` file.|
diff --git a/i18n/en.yaml b/i18n/en.yaml
index c21b684c..1c083cc6 100644
--- a/i18n/en.yaml
+++ b/i18n/en.yaml
@@ -15,6 +15,9 @@ article:
views:
one: "{{ .Count }} view"
other: "{{ .Count }} views"
+ likes:
+ one: "{{ .Count }} like"
+ other: "{{ .Count }} likes"
author:
byline_title: "Author"
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 6e3a5866..0236b27a 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -23,6 +23,9 @@
{{ .Content | emojify }}
diff --git a/layouts/partials/article-meta.html b/layouts/partials/article-meta.html
index 1190c4db..33aaf353 100644
--- a/layouts/partials/article-meta.html
+++ b/layouts/partials/article-meta.html
@@ -28,10 +28,18 @@
{{ $meta.Add "partials" (slice (partial "meta/reading-time.html" .)) }}
{{ end }}
- {{ if (.Params.showViews | default (.Site.Params.article.showViews | default true)) }}
+ {{ if (.Params.showViews | default (.Site.Params.article.showViews | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/views.html" .)) }}
{{ end }}
+ {{ if (.Params.showLikes | default (.Site.Params.article.showLikes | default false)) }}
+ {{ $meta.Add "partials" (slice (partial "meta/likes.html" .)) }}
+ {{ end }}
+
+ {{ if and (eq $scope "single") (.Params.showLikes | default (.Site.Params.article.showLikes | default false)) }}
+ {{ $meta.Add "partials" (slice (partial "meta/likes_button.html" .)) }}
+ {{ end }}
+
{{ if and (eq $scope "single") (.Params.showEdit | default (.Site.Params.article.showEdit | default false)) }}
{{ $meta.Add "partials" (slice (partial "meta/edit.html" .)) }}
{{ end }}
diff --git a/layouts/partials/meta/likes.html b/layouts/partials/meta/likes.html
new file mode 100644
index 00000000..fb1f5ec2
--- /dev/null
+++ b/layouts/partials/meta/likes.html
@@ -0,0 +1,4 @@
+
+ {{- i18n "article.likes" 0 | markdownify | emojify -}}
+
+{{- /* Trim EOF */ -}}
\ No newline at end of file
diff --git a/layouts/partials/meta/likes_button.html b/layouts/partials/meta/likes_button.html
new file mode 100644
index 00000000..28e6d82e
--- /dev/null
+++ b/layouts/partials/meta/likes_button.html
@@ -0,0 +1,6 @@
+
+
+
+{{- /* Trim EOF */ -}}
\ No newline at end of file