diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9a58047..b7f696b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Changelog .. this is in "release" (for Sphinx) format +- :feature:`7` Support hashtags, if given in frontend post metadata. - :release:`1.0.0 <2023-07-11>` - :support:`-` `seafoam `_ v2.9.0 is being release co-currently with this, and has support for microblog posts. diff --git a/README.rst b/README.rst index 2e49d48..a204e29 100644 --- a/README.rst +++ b/README.rst @@ -69,6 +69,23 @@ Or a post with an image: The image path is relative to your ``content`` folder. A URL of the photo is added to the end of the post as well. +Or with tags (or hashtags): + +.. code-block:: md + + + + date: 2023-07-13 14:56 -0600 + tags: Python, Pelican, Microblogging + + I'm now Microblogging with Pelican! + + +This will add links at the end of your post to the tags to the tag page for +your (Pelican) site. + +For now, it does not pull tags out of the body of your post. + Background Notes (on Micro Blogging) ------------------------------------ diff --git a/minchin/pelican/readers/microblog/generator.py b/minchin/pelican/readers/microblog/generator.py index 2b0c897..fe80e5e 100644 --- a/minchin/pelican/readers/microblog/generator.py +++ b/minchin/pelican/readers/microblog/generator.py @@ -71,6 +71,18 @@ def addMicroArticle(articleGenerator): content = content.removesuffix("

") + " " + image_link + "

" + if "tags" in metadata.keys(): + # new_article_metadata["tags"] = myBaseReader.process_metadata("tags", metadata["tags"]) + new_article_metadata["tags"] = metadata["tags"] + + # metadata["tags"] is already a list of `pelican.urlwrappers.Tag` + for tag in metadata["tags"]: + tag_url = settings["SITEURL"] + "/" + tag.url + + tag_link = f'#{tag.name}' + + content = content.removesuffix("

") + " " + tag_link + "

" + # warn if too long safe_content = Markup(content).striptags() post_len = len(safe_content) @@ -87,7 +99,7 @@ def addMicroArticle(articleGenerator): ) new_article_metadata["char_len"] = post_len - print(post_len) + # print(post_len) new_article = Article( content, diff --git a/test/content/micro/202307131456.md b/test/content/micro/202307131456.md new file mode 100644 index 0000000..d1792ec --- /dev/null +++ b/test/content/micro/202307131456.md @@ -0,0 +1,4 @@ +date: 2023-07-13 14:56 -0600 +tags: Python, Pelican, Microblogging + +I'm now Microblogging with Pelican!