Skip to content

Commit 56e23bc

Browse files
committed
#53 - Allow for different folder note naming scheme
- updated settings description for clarity - minor extension of the code to allow both _about_ and _about_.md in the settings - Version bump before release
1 parent 928e987 commit 56e23bc

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "custom-sort",
33
"name": "Custom File Explorer sorting",
4-
"version": "1.6.0",
4+
"version": "1.6.1",
55
"minAppVersion": "0.15.0",
66
"description": "Allows for manual and automatic, config-driven reordering and sorting of files and folders in File Explorer",
77
"author": "SebastianMC",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-custom-sort",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "Custom Sort plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {

src/main.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
normalizePath,
77
Plugin,
88
PluginSettingTab,
9+
sanitizeHTMLToDom,
910
setIcon,
1011
Setting,
1112
TAbstractFile,
@@ -86,12 +87,13 @@ export default class CustomSortPlugin extends Plugin {
8687
// - the file(s) explicitly configured by user in plugin settings
8788
// Be human-friendly and accept both .md and .md.md file extensions
8889
// (the latter representing a typical confusion between note name vs underlying file name)
89-
if (aFile.name === SORTSPEC_FILE_NAME ||
90-
aFile.name === `${SORTSPEC_FILE_NAME}.md` ||
91-
aFile.basename === parent.name ||
92-
aFile.basename === this.settings.additionalSortspecFile ||
93-
aFile.path === this.settings.additionalSortspecFile ||
94-
aFile.path === `${this.settings.additionalSortspecFile}.md`
90+
if (aFile.name === SORTSPEC_FILE_NAME || // file name == sortspec.md ?
91+
aFile.name === `${SORTSPEC_FILE_NAME}.md` || // file name == sortspec.md.md ?
92+
aFile.basename === parent.name || // Folder Note mode: inside folder, same name
93+
aFile.basename === this.settings.additionalSortspecFile || // when user configured _about_
94+
aFile.name === this.settings.additionalSortspecFile || // when user configured _about_.md
95+
aFile.path === this.settings.additionalSortspecFile || // when user configured Inbox/sort.md
96+
aFile.path === `${this.settings.additionalSortspecFile}.md` // when user configured Inbox/sort
9597
) {
9698
const sortingSpecTxt: string = mCache.getCache(aFile.path)?.frontmatter?.[SORTINGSPEC_YAML_KEY]
9799
if (sortingSpecTxt) {
@@ -390,11 +392,26 @@ class CustomSortSettingTab extends PluginSettingTab {
390392

391393
containerEl.createEl('h2', {text: 'Settings for Custom File Explorer Sorting Plugin'});
392394

395+
const additionalSortspecFileDescr: DocumentFragment = sanitizeHTMLToDom(
396+
'A note name or note path to scan (YAML frontmatter) for sorting specification in addition to the `sortspec` notes and Folder Notes<sup><b>*</b></sup>.'
397+
+ '<br>'
398+
+ ' The `.md` filename suffix is optional.'
399+
+ '<p><b>(*)</b>&nbsp;if you employ the <i>Index-File based</i> approach to folder notes (as documented in '
400+
+ '<a href="https://github.com/aidenlx/alx-folder-note/wiki/folder-note-pref"'
401+
+ '>Aidenlx Folder Note preferences</a>'
402+
+ ') you can enter here the index note name, e.g. <b>_about_</b>'
403+
+ '<br>'
404+
+ 'The <i>Inside Folder, with Same Name Recommended</i> mode of Folder Notes is handled automatically, no additional configuration needed.'
405+
+ '</p>'
406+
+ '<p>NOTE: After updating this setting remember to refresh the custom sorting via clicking on the ribbon icon or via the <b>sort-on</b> command'
407+
+ ' or by restarting Obsidian or reloading the vault</p>'
408+
)
409+
393410
new Setting(containerEl)
394-
.setName('Path to the designated note containing sorting specification')
395-
.setDesc('The YAML front matter of this note will be scanned for sorting specification, in addition to the `sortspec` notes and folder notes. The `.md` filename suffix is optional.')
411+
.setName('Path or name of additional note(s) containing sorting specification')
412+
.setDesc(additionalSortspecFileDescr)
396413
.addText(text => text
397-
.setPlaceholder('e.g. Inbox/sort')
414+
.setPlaceholder('e.g. _about_')
398415
.setValue(this.plugin.settings.additionalSortspecFile)
399416
.onChange(async (value) => {
400417
this.plugin.settings.additionalSortspecFile = value.trim() ? normalizePath(value) : '';

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"1.3.0": "0.15.0",
2222
"1.4.0": "0.15.0",
2323
"1.5.0": "0.15.0",
24-
"1.6.0": "0.15.0"
24+
"1.6.0": "0.15.0",
25+
"1.6.1": "0.15.0"
2526
}

0 commit comments

Comments
 (0)