Publish UI: Change sort order

Use case or problem

When scanning through files/folders in Publish window, there is no ability to change the sort order. This is a helpful feature in File Explorer.

Proposed solution

Add the same sort feature to the Obsidian Publish window, or at minimum, sort by file name.

  • File name (A to Z)
  • File name (Z to A)
  • β€”
  • Modified time (new to old)
  • Modified time (old to new)
  • β€”
  • Created time (new to old)
  • Created time (old to new)

Related feature requests (optional)

Publish UI: Collapse/expand folders

1 Like

I can’t remember where I found this or figured it out, but you can manually give a sort order of individual elements in a publish.js file.

My code looks like this:

var siteLeft = document.querySelector('.site-body-left-column');

let navOrderAsc = ["welcome.md", "start here.md"]; /* these go on top*/

let navOrderDsc = []; /* these go at the bottom */

/* items not mentioned go in between in alphabetical order */

var siteNav = siteLeft.querySelector('.nav-view-outer');

var navContainer = siteNav.querySelector('.tree-item').querySelector('.tree-item-children');

for (const item of navOrderAsc.reverse()){

    querytext = '[data-path="' + item + '"]';

    navItem = navContainer.querySelector(querytext);

    if (navItem == null) continue;

    moveItem = navItem.parentElement;

    navContainer.prepend(moveItem);

}

for (const item of navOrderDsc.reverse()){

    querytext = '[data-path="' + item + '"]';

    navItem = navContainer.querySelector(querytext);

    if (navItem == null) continue;

    moveItem = navItem.parentElement;

    navContainer.append(moveItem);

}
4 Likes