From 80bf2b451740d744bb0336e88f52db7797e12b59 Mon Sep 17 00:00:00 2001 From: "max.mehl" Date: Mon, 14 Oct 2019 12:31:44 +0200 Subject: [PATCH] better inclusion comments --- config.toml | 6 ++--- content/blog/test.md | 25 +++++++++++++++++++ themes/hugo-mastodon-comments/.gitignore | 1 + .../layouts/partials/comments.html | 14 +++++++++++ .../static/comments/getcomments.js | 6 ++--- .../hugo-sustain/layouts/_default/list.html | 2 +- .../hugo-sustain/layouts/_default/single.html | 1 + 7 files changed, 48 insertions(+), 7 deletions(-) create mode 100755 content/blog/test.md create mode 100644 themes/hugo-mastodon-comments/.gitignore create mode 100644 themes/hugo-mastodon-comments/layouts/partials/comments.html diff --git a/config.toml b/config.toml index 240f7a6..9cbbd3d 100755 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ baseurl = "https://mehl.mx/" languageCode = "en-GB" title = "Max Mehl" -theme = [ "hugo-sustain", "hugo-cloak-email" ] +theme = [ "hugo-sustain", "hugo-cloak-email", "hugo-mastodon-comments" ] [blackfriday] # preserves linebreaks, and transforms to
@@ -17,8 +17,8 @@ extensions = [ "hardLineBreak" ] keywords = "manager, free software, open source, project, campaign, konstanz, berlin, munster, communication, IT service, computer, politics, administration, FSFE, scouts, founder" # Custom assets can be linked with their paths relative to static/ - custom_css = ['css/custom.css'] - custom_js = [] + custom_css = ['css/custom.css', 'comments/mastodon-comments.css'] + custom_js = ['comments/getcomments.js'] [params.blog] headline = "Thoughts about tech, politics, and more" diff --git a/content/blog/test.md b/content/blog/test.md new file mode 100755 index 0000000..a82f308 --- /dev/null +++ b/content/blog/test.md @@ -0,0 +1,25 @@ ++++ +title = "TEST ARTICLE" +description = "" +tags = [ + "test" +] +date = "2018-04-02" +categories = [ + "Development", +] +highlight = "true" +draft = false +headerimage = "placeholder.jpg" +headercredits = "Unsplash, [Dlanor S](https://unsplash.com/photos/2xEQDxB0ss4)" ++++ + +LOREM IPSUM Hugo uses the excellent [go][] [html/template][gohtmltemplate] library for +its template engine. It is an extremely lightweight engine that provides a very +small amount of logic. In our experience that it is just the right amount of +logic to be able to create a good static website. If you have used other +template systems from different languages or frameworks you will find a lot of +similarities in go templates. + +This document is a brief primer on using go templates. The [go docs][gohtmltemplate] +provide more details. diff --git a/themes/hugo-mastodon-comments/.gitignore b/themes/hugo-mastodon-comments/.gitignore new file mode 100644 index 0000000..0ed663d --- /dev/null +++ b/themes/hugo-mastodon-comments/.gitignore @@ -0,0 +1 @@ +static/comments/config.php diff --git a/themes/hugo-mastodon-comments/layouts/partials/comments.html b/themes/hugo-mastodon-comments/layouts/partials/comments.html new file mode 100644 index 0000000..8d2ad9f --- /dev/null +++ b/themes/hugo-mastodon-comments/layouts/partials/comments.html @@ -0,0 +1,14 @@ +
+
Comments
+
+
+
+
+
+
+
+ +
+ + + diff --git a/themes/hugo-mastodon-comments/static/comments/getcomments.js b/themes/hugo-mastodon-comments/static/comments/getcomments.js index e23249d..a7d5576 100644 --- a/themes/hugo-mastodon-comments/static/comments/getcomments.js +++ b/themes/hugo-mastodon-comments/static/comments/getcomments.js @@ -1,14 +1,14 @@ $(document).ready(function() { - // check if we show a blog post or not - var isArticle = /\/?articles\/\d\d\d\d\/\d\d\/\d\d\/.+$/.test(RelPermalink); + // check if we show a blog post or not. You might have to adapt this + var isArticle = /\/?blog\/\d\d\d\d\/.+$/.test(RelPermalink); if (isArticle === false) { console.log("Not a blog post, no need to search for comments"); return; } $.ajax({ - url: "https://www.schiessle.org/mastodon.comments/getcomments.php", + url: "/comments/getcomments.php", type: "get", data: { search : RelPermalink diff --git a/themes/hugo-sustain/layouts/_default/list.html b/themes/hugo-sustain/layouts/_default/list.html index 00a98fd..70e2019 100644 --- a/themes/hugo-sustain/layouts/_default/list.html +++ b/themes/hugo-sustain/layouts/_default/list.html @@ -16,7 +16,7 @@

Subscribe to my Blog via Diaspora, Mastodon, Friendica or GNU Social. Never miss a article! Reshare, like and discuss it!

{{ end }}

- All + All {{ range $name, $taxonomy := .Site.Taxonomies.categories }} {{ humanize $name }} diff --git a/themes/hugo-sustain/layouts/_default/single.html b/themes/hugo-sustain/layouts/_default/single.html index 155ee9a..bf3be93 100644 --- a/themes/hugo-sustain/layouts/_default/single.html +++ b/themes/hugo-sustain/layouts/_default/single.html @@ -52,6 +52,7 @@


+ {{ partial "comments.html" . }} {{ partial "social" . }}