From f4164bf85e8b512ab2a84e20ddd3c95964328b56 Mon Sep 17 00:00:00 2001 From: Domeniko Gentner Date: Sat, 7 Nov 2020 19:30:52 +0100 Subject: [PATCH] More README --- README.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/README.md b/README.md index c322716..b078d22 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,77 @@ user and no rights for the group. All files should have `chmod 400`. The script has the specialty that sends an email when something goes wrong, so I am notifed and can fix the issue. If you don't want that, simply open `mail/mail.py` and replace everyting in the init function with a simple `pass`. + +## How does it integrate into Hugo? + +It puts the full json reply from twitter into the data directory, if correctly configured. From there you can do two +things: + +* Automate the build (strongly recommended) +* Build a template that uses the json data to build a twitter card. + +I build the template using a [partial template](https://gohugo.io/templates/partials/#readout). It sits in the directory +`layouts/partials` and is called `latest_tweet.html`. The content is not very interesting: + +``` +
+
+ {{ with .Site.Data.latest_tweet }} +
+
+
+ +
+
+
+

+ + @{{ .user.name }} + +

+ +

+ {{ .full_text | safeHTML }} +

+ + +
+ + {{ slicestr .created_at 0 20 }} + + + via {{ .source | safeHTML }} + +
+ +
+ + + + + + + + + + + + + + + +
+ {{ end }} +
+
+``` + +The important bit is this go template instruction: + +``` +{{ with .Site.Data.latest_tweet }} +{{ end }} +``` + +Between these you can simple call the keys from the json, so `name` in dict `user` becomes simple `{{ .user.name }}`. +Neato, isn't it?