New Tag tags: last used (date or number of days ago)
-
July 28, 2021 at 9:53 pm #6066[anonymous]
Hi.
It would be nice to know when a tag was last used. Then it would be possible to filter and only show the tags that are newly used.
Hope to see this feature in the future 🙂
Edit: number of days ago would be best, since I don’t know how easy it is to compare dates. Still a novice publii user 🙂
July 31, 2021 at 12:37 pm #6087[anonymous]Hi,
To be honest I did not saw such feature in other blogging platforms and I am not sure if there is a sense to implement it as a common future.
I think that if you really really want – it is possible to create a custom helper which will return last used tags, but it will be a quite complex helper 😉
August 1, 2021 at 8:15 am #6095[anonymous]Hi, thanks for the replay 🙂
I will take a look at the custom helper 🙂  and see what I can get to work.
Just a few words about the use case. So far no problem since just started on some blogs, but in the future, there could be. The focus now is to use many tags, and if continue there will over time be many of them that are not that relevant for the blog. For example, I make now a few posts that I will tag with “Adorno” because of a paper I am working on. Then sadly there did not come more posts about him. Over time that tag will most likely become less relevant. I see then a usage where I will filter away that tag from the tag list because it has not been used for x months and have fewer than y posts. Of course, those posts will still have the tag and you can get to the tag page through them.
I hope you see that there could be a use for it, or that you see a way to organize the blog when it has become overpopulated with tags.
August 1, 2021 at 5:47 pm #6096[anonymous]Hi again 🙂
I manage to make a helper that does what I want 😀 Or as you did say, a helper that returns a list of filtered tags.
// in index.hbs
{{#each (filteredTags @website.contentStructure.tags 200 3)}} // filter away tags with fewer then 3 post and older then 200 days. {{name}} {{/each}}// in helpers.js function newerPostThen(post, numberOfDays) { let dateToday = new Date(); let postDate = new Date(post.createdAt); let postDaysOld = (dateToday.getTime() - postDate.getTime()) / (1000 * 3600 * 24); return postDaysOld < numberOfDays; } let themeHelpers = { filteredTags: function(tags, numberOfDaysTreshold, numberOfPostTreshold) { var filteredTagsOutput = []; for (tagIndex in tags) { if (tags[tagIndex].postsNumber < numberOfPostTreshold && !newerPostThen(tags[tagIndex].posts[0], numberOfDaysTreshold)) { } else { filteredTagsOutput.push(tags[tagIndex]) } } return filteredTagsOutput; } }; module.exports = themeHelpers;But actually I did not just want that. I wanted to keep the out-filtered tags at the bottom of the list. Like this:// in index.hbs {{#each (filteredTags @website.contentStructure.tags 200 3)}}
{{#each this}} {{name}} {{/each}}{{/each}} // in helpers.js function newerPostThen(post, numberOfDays) { ... // No change } let themeHelpers = { filteredTags: function(tags, numberOfDaysTreshold, numberOfPostTreshold) { var filteredTagsOutput = [[],[]]; for (tagIndex in tags) { if (tags[tagIndex].postsNumber < numberOfPostTreshold && !newerPostThen(tags[tagIndex].posts[0], numberOfDaysTreshold)) { filteredTagsOutput[1].push(tags[tagIndex]) } else { filteredTagsOutput[0].push(tags[tagIndex]) } } return filteredTagsOutput; } }; module.exports = themeHelpers;August 1, 2021 at 6:28 pm #6097[anonymous]Edit to the previous post: That code works only when the post is in descending order and ordered by the creation or modified date.