SORT REFERENCES

The Sort Linked References extension adds an icon button to the user page that could be used to sort linked references.

Installation

You could use the Copy Extension button below to individually install this extension. To install, just paste anywhere in your Roam graph and click "Yes, I Know What I'm Doing".

Manual Installation

If the extension doesn't work after using the copy extension button above, try installing manually using the instructions below.

First create a block with the text {{[[roam/js]]}} on any page in your Roam DB. Then, create a single child of this block type three back ticks. A code block should appear. Copy this code and paste it into the child code block in your graph:

var existing = document.getElementById("roamjs-sort-references");
if (!existing) {
  var extension = document.createElement("script");
  extension.src = "https://roamjs.com/sort-references.js";
  extension.id = "roamjs-sort-references";
  extension.async = true;
  extension.type = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(extension);
}

Finally, click "Yes, I Know What I'm Doing".


Usage

The script supports the following configuration attributes, to be added in the [[roam/js/sort-references]] page:

  • Default Sort - (Optional) The default mode used to sort references on all pages. Valid values include all the options below, written without the 'Sort By' prefix. For example, Default Sort:: Page Title.
  • Daily Note Secondary - (Optional) The default sort to use on non-daily note pages when you sort by daily note. Valid values include Page Title and Page Title Descending.

Near the linked references, there will appear a sort icon next to the filter icon. Clicking on the sort icon will make a sort menu visible to the user with the following options:

  • Sort By Page Title - This will sort all the linked references in ascending alphabetical order of the page title.
  • Sort By Page Title Descending - This will sort all the linked references in descending alphabetical order of the page title.
  • Sort By Created Date - This will sort all the linked references in ascending order that the page was created.
  • Sort By Created Date Descending - This will sort all the linked references in descending order that the page was created.
  • Sort By Daily Note - This will sort all the linked references in ascending order by Daily Note, followed by created date of non-daily note pages.
  • Sort By Daily Note Descending - This will sort all the linked references in descending order by Daily Note, followed by created date of non-daily note pages.

You could also add a Default Sort attribute with a valid value on the page itself to have a specific sorting for just that page.

Demo


Contributors

This extension is brought to you by RoamJS! If you are facing any issues reach out to support@roamjs.com or click on the chat button on the bottom right.

If you get value from using this extension, consider sponsoring RoamJS by clicking on the button below!

Other Extensions