Your sites Log in Sign up Menu

How to sort tags alphabetically?

I'm using the Magazine template and would like to sort the tags in the sidebar alphabetically. Is that possible?


3 years ago, 1 replies   Improve this question

It's not yet possible to sort tags alphabetically using Blot's template engine. However, you can do this easily using some JavaScript.

You will need to fork an editable version of the Magazine template if you haven't done so already, then paste the following snippet into the script.js file, perhaps at the very end:

// Sort tags in the sidebar alphabetically
[...document.querySelector('.clip-tags').children]
  .sort((a,b)=>a.innerText>b.innerText?1:-1)
  .forEach(node=>list.appendChild(node));

Source: Easiest way to sort DOM nodes?

Answered 3 years ago · Improve this answer