You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I did it for myself just now and I really like it.
I added this bit to the main.js file in the updateIndexContent() function.
//CUSTOM SORT ORDER
if (sortOrder === SortOrder.CUST) {
indexContent.sort((a, b) => {
const aFlag = a.includes("_index_of_"); //This is my index prefix -- use yours here
const bFlag = b.includes("_index_of_"); //This is my index prefix -- use yours here
// If both are flagged, sort alphabetically
if (aFlag && bFlag) {
return a.localeCompare(b, undefined, { numeric: true });
}
// Flagged strings come first
else if (aFlag) {
return -1; // a comes before b
} else if (bFlag) {
return 1; // b comes before a
}
// Neither flagged, sort alphabetically
else {
return a.localeCompare(b, undefined, { numeric: true });
}
});
}
It's really nice to have all of the index files together, because in my mind they are very different from the other files. I don't like to have them all mixed in together. Might want to add this feature in, since it's really easy to implement. Otherwise, maybe this will be helpful to somebody!
new obsidian.Setting(containerEl)
.setName('Index links Order')
.setDesc('Select the order of the links to be sorted in the god damn index files.')
.addDropdown(async (dropdown) => {
dropdown.addOption(SortOrder.ASC, 'Ascending');
dropdown.addOption(SortOrder.DESC, 'Descending');
dropdown.addOption(SortOrder.CUST, 'Custom'); //AND ADD THIS
dropdown.setValue(this.plugin.settings.sortOrder);
dropdown.onChange(async (option) => {
this.plugin.settings.sortOrder = option;
await this.plugin.saveSettings();
});
});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I did it for myself just now and I really like it.
I added this bit to the main.js file in the updateIndexContent() function.
It's really nice to have all of the index files together, because in my mind they are very different from the other files. I don't like to have them all mixed in together. Might want to add this feature in, since it's really easy to implement. Otherwise, maybe this will be helpful to somebody!
Make sure to update the SortOrder enum:
...and to add the option in settings:
Beta Was this translation helpful? Give feedback.
All reactions