Skip to content

Commit 4f21ede

Browse files
committed
update plugin to work
1 parent d919db8 commit 4f21ede

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

docs/.obsidian/plugins/docs-viewer/main.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

docs/.obsidian/plugins/docs-viewer/styles.css

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,40 @@
3838
max-width: calc(100% - 10px);
3939
}
4040

41-
/* Sort value styling */
42-
.has-sort-value::before {
41+
/* Title styling */
42+
.has-title::after {
43+
content: attr(data-title);
44+
color: var(--color-orange);
45+
font-size: 0.85em;
46+
opacity: 0.8;
47+
}
48+
49+
/* Sort value styling - moved to appear last (after title) */
50+
.has-sort-value::after {
4351
content: attr(data-sort-value);
4452
color: var(--color-yellow);
45-
margin-right: 2px;
53+
margin-left: 4px;
4654
}
4755

48-
/* Title styling */
49-
.has-title::after {
56+
/* Handle case when both title and sort are present - REPLACE THIS */
57+
.has-title.has-sort-value::after {
58+
content: none; /* Remove the combined content */
59+
}
60+
61+
/* Add separate pseudo-elements for title and sort when both exist */
62+
.has-title.has-sort-value::after {
5063
content: attr(data-title);
5164
color: var(--color-orange);
5265
font-size: 0.85em;
5366
opacity: 0.8;
5467
}
68+
69+
.has-title.has-sort-value::before {
70+
content: none; /* Ensure no content shows before */
71+
}
72+
73+
/* Add sort value after the title with proper color */
74+
.has-title.has-sort-value .sort-suffix {
75+
color: var(--color-yellow);
76+
margin-left: 4px;
77+
}

0 commit comments

Comments
 (0)