mirror of
https://github.com/litruv/Docs-Viewer.git
synced 2026-07-24 02:36:07 +10:00
update plugin to work
This commit is contained in:
27
docs/.obsidian/plugins/docs-viewer/main.js
vendored
27
docs/.obsidian/plugins/docs-viewer/main.js
vendored
@@ -44,6 +44,10 @@ class TitleAppenderPlugin extends obsidian.Plugin {
|
|||||||
el.classList.remove('has-sort-value', 'has-title');
|
el.classList.remove('has-sort-value', 'has-title');
|
||||||
el.removeAttribute('data-sort-value');
|
el.removeAttribute('data-sort-value');
|
||||||
el.removeAttribute('data-title');
|
el.removeAttribute('data-title');
|
||||||
|
|
||||||
|
// Also remove any added elements
|
||||||
|
const sortSuffix = el.querySelector('.sort-suffix');
|
||||||
|
if (sortSuffix) sortSuffix.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply classes and attributes for each file with frontmatter
|
// Apply classes and attributes for each file with frontmatter
|
||||||
@@ -59,17 +63,28 @@ class TitleAppenderPlugin extends obsidian.Plugin {
|
|||||||
const fileElement = document.querySelector(`.nav-file-title[data-path="${escapedPath}"] .nav-file-title-content`);
|
const fileElement = document.querySelector(`.nav-file-title[data-path="${escapedPath}"] .nav-file-title-content`);
|
||||||
|
|
||||||
if (fileElement) {
|
if (fileElement) {
|
||||||
// Add sort value if available
|
|
||||||
if (sortValue !== undefined) {
|
|
||||||
fileElement.classList.add('has-sort-value');
|
|
||||||
fileElement.setAttribute('data-sort-value', `[${sortValue}] `);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add title if available
|
// Add title if available
|
||||||
if (title) {
|
if (title) {
|
||||||
fileElement.classList.add('has-title');
|
fileElement.classList.add('has-title');
|
||||||
fileElement.setAttribute('data-title', ` (${title})`);
|
fileElement.setAttribute('data-title', ` (${title})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add sort value if available
|
||||||
|
if (sortValue !== undefined) {
|
||||||
|
fileElement.classList.add('has-sort-value');
|
||||||
|
|
||||||
|
// If both title and sort exist, create a span for the sort value
|
||||||
|
if (title) {
|
||||||
|
// Create a span for the sort value to apply different color
|
||||||
|
const sortSpan = document.createElement('span');
|
||||||
|
sortSpan.className = 'sort-suffix';
|
||||||
|
sortSpan.textContent = `[${sortValue}]`;
|
||||||
|
fileElement.appendChild(sortSpan);
|
||||||
|
} else {
|
||||||
|
// If only sort exists, use the attribute
|
||||||
|
fileElement.setAttribute('data-sort-value', `[${sortValue}]`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
37
docs/.obsidian/plugins/docs-viewer/styles.css
vendored
37
docs/.obsidian/plugins/docs-viewer/styles.css
vendored
@@ -38,13 +38,6 @@
|
|||||||
max-width: calc(100% - 10px);
|
max-width: calc(100% - 10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort value styling */
|
|
||||||
.has-sort-value::before {
|
|
||||||
content: attr(data-sort-value);
|
|
||||||
color: var(--color-yellow);
|
|
||||||
margin-right: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Title styling */
|
/* Title styling */
|
||||||
.has-title::after {
|
.has-title::after {
|
||||||
content: attr(data-title);
|
content: attr(data-title);
|
||||||
@@ -52,3 +45,33 @@
|
|||||||
font-size: 0.85em;
|
font-size: 0.85em;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sort value styling - moved to appear last (after title) */
|
||||||
|
.has-sort-value::after {
|
||||||
|
content: attr(data-sort-value);
|
||||||
|
color: var(--color-yellow);
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle case when both title and sort are present - REPLACE THIS */
|
||||||
|
.has-title.has-sort-value::after {
|
||||||
|
content: none; /* Remove the combined content */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add separate pseudo-elements for title and sort when both exist */
|
||||||
|
.has-title.has-sort-value::after {
|
||||||
|
content: attr(data-title);
|
||||||
|
color: var(--color-orange);
|
||||||
|
font-size: 0.85em;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.has-title.has-sort-value::before {
|
||||||
|
content: none; /* Ensure no content shows before */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add sort value after the title with proper color */
|
||||||
|
.has-title.has-sort-value .sort-suffix {
|
||||||
|
color: var(--color-yellow);
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user