@@ -44,6 +44,10 @@ class TitleAppenderPlugin extends obsidian.Plugin {
4444 el . classList . remove ( 'has-sort-value' , 'has-title' ) ;
4545 el . removeAttribute ( 'data-sort-value' ) ;
4646 el . removeAttribute ( 'data-title' ) ;
47+
48+ // Also remove any added elements
49+ const sortSuffix = el . querySelector ( '.sort-suffix' ) ;
50+ if ( sortSuffix ) sortSuffix . remove ( ) ;
4751 } ) ;
4852
4953 // Apply classes and attributes for each file with frontmatter
@@ -59,17 +63,28 @@ class TitleAppenderPlugin extends obsidian.Plugin {
5963 const fileElement = document . querySelector ( `.nav-file-title[data-path="${ escapedPath } "] .nav-file-title-content` ) ;
6064
6165 if ( fileElement ) {
62- // Add sort value if available
63- if ( sortValue !== undefined ) {
64- fileElement . classList . add ( 'has-sort-value' ) ;
65- fileElement . setAttribute ( 'data-sort-value' , `[${ sortValue } ] ` ) ;
66- }
67-
6866 // Add title if available
6967 if ( title ) {
7068 fileElement . classList . add ( 'has-title' ) ;
7169 fileElement . setAttribute ( 'data-title' , ` (${ title } )` ) ;
7270 }
71+
72+ // Add sort value if available
73+ if ( sortValue !== undefined ) {
74+ fileElement . classList . add ( 'has-sort-value' ) ;
75+
76+ // If both title and sort exist, create a span for the sort value
77+ if ( title ) {
78+ // Create a span for the sort value to apply different color
79+ const sortSpan = document . createElement ( 'span' ) ;
80+ sortSpan . className = 'sort-suffix' ;
81+ sortSpan . textContent = `[${ sortValue } ]` ;
82+ fileElement . appendChild ( sortSpan ) ;
83+ } else {
84+ // If only sort exists, use the attribute
85+ fileElement . setAttribute ( 'data-sort-value' , `[${ sortValue } ]` ) ;
86+ }
87+ }
7388 }
7489 }
7590 } catch ( e ) {
0 commit comments