From b3a8f622db50d4c2bd4ef30eb6f73bfe80f393d7 Mon Sep 17 00:00:00 2001 From: Maurizio Paglia Date: Thu, 18 May 2023 07:53:32 +0200 Subject: [PATCH] Fixed code for hashtags --- pelican/plugins/share_post/share_post.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pelican/plugins/share_post/share_post.py b/pelican/plugins/share_post/share_post.py index ccb4286..9b9971a 100644 --- a/pelican/plugins/share_post/share_post.py +++ b/pelican/plugins/share_post/share_post.py @@ -59,16 +59,13 @@ def create_link_facebook(title, url, content): @create_link def create_link_mastodon(title, url, content): - if hasattr(content, "tags"): - taglist = content.tags - new_taglist = [] - for i in taglist: - new_taglist.append("%23" + str(i)) - hashtags = " ".join(str(x).replace(" ", "") for x in new_taglist) - else: - hashtags = "" + hashtags = "" - return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" + if hasattr(content, "tags"): + new_taglist = [f"%23{str(i).replace(' ', '')}" for i in content.tags] + hashtags = " ".join(new_taglist) + + return f"https://toot.kytta.dev/?text={title}{newline}{url}{newline}{hashtags}" @create_link