Tag your Polar articles 🏷️
eval
I've been using Polar.sh now for over a month and I really like it so far.
As I expect to be publishing many more articles on a wide variety of topics, I'd thought it would be handy to tag them and allow readers to find articles on related topics. And so the idea of tagging articles with custom html-comments was born.
This article explains how to tag articles yourself and get a nice tag overview page like this one.
It's just 3 straightforward steps. Let's go 🚀.
Tags: #Polar, #GitHub Actions, #eval/actions
step 1: collect
First of all we need to create an overview page where the tag-links point to. To do this: create an article (e.g. named 'Articles by tag' or anything really), and include the following snippet:
<!-- POLAR-TAGS-LIST -->
Which will be expanded to something like:
<!-- POLAR-TAGS-LIST -->
## #Tag1
* [Title of article](https://polar.sh/user/posts/title-of-article)
## #Tag2
...
<!-- POLAR-TAGS-LIST-END -->
📌 Pinning this article will give visitors of your profile a nice overview of your articles.
step 2: tag
To tag an article include the following snippet:
<!-- POLAR-TAGS tags="Tag1, some other tag" -->
Which will be expanded by the CLI to the following markdown:
<!-- POLAR-TAGS tags="Tag1, some other tag" -->
**Tags:** [#Tag1](https://polar.sh/user/posts/articles-by-tag#tag1), [#some other tag](https://polar.sh/user/posts/articles-by-tag#some-other-tag)
<!-- POLAR-TAGS-END -->
Include the expanded snippet above to see how it looks (the CLI will eventually replace* anything in between the HTML comments).
*) If you want to see an example of a lexer (which I wrote about in this article), then head over to the CLI-code (thelex-
functions at the bottom of the highlighted block contain the meat). Determining whether or not the tag-snippets appear in a code block or not is straightforward this way (as opposed to using regexes).step 3: action
To run the CLI-script that will replace the snippets it's easiest to schedule it using GitHub Actions.
Head over to GitHub and create a repository containing a workflow for GitHub actions like this one.
Important ingredient for this workflow to work is a Polar token which you can get here and which should be available as a repository secret named POLAR_API_TOKEN
(instructions here).
Testdrive it by manually kicking off the workflow.
That's it! Happy tagging 🏷️
Find all code here. Start a discussion topic or open an issue if you need help 🛟.Related repository: eval/actions
To send visitors of a project-page like https://polar.sh/eval/actions to relevant articles do the following:
Include a repository tag in relevant articles, e.g.
<!-- POLAR-TAGS tags="user/project, some other tag" -->
Then include a link on the project-page linking to all articles, e.g. https://polar.sh/eval/posts/articles-by-tag#evalactions (note the absence of the slash in the anchor).
Tags: #Polar, #GitHub Actions, #eval/actions