Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

New Tag tags: last used (date or number of days ago)

  • #6066
    Avatar photo[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 🙂

    #6087
    Avatar photo[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 😉

    #6095
    Avatar photo[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.

    #6096
    Avatar photo[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;
    #6097
    Avatar photo[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.