Add folder configuration options and update Font Awesome version

This commit is contained in:
2025-02-04 16:11:44 +11:00
parent 41298c9fa6
commit 6392cac91d
3 changed files with 47 additions and 8 deletions

View File

@@ -54,8 +54,11 @@ function createFileIndexItem(doc, container, level = 0) {
const folderHeader = document.createElement('div');
folderHeader.className = 'folder-header';
// Use custom icon if provided, otherwise use default folder icon
const iconClass = doc.icon || `fas fa-folder${doc.defaultOpen !== false ? '-open' : ''}`;
folderHeader.innerHTML = `
<i class="fas fa-folder${doc.defaultOpen !== false ? '-open' : ''} folder-icon"></i>
<i class="${iconClass} folder-icon"></i>
<span>${doc.title}</span>
`;
folderDiv.appendChild(folderHeader);
@@ -67,8 +70,10 @@ function createFileIndexItem(doc, container, level = 0) {
folderHeader.addEventListener('click', () => {
folderDiv.classList.toggle('open');
folderHeader.querySelector('.folder-icon').classList.toggle('fa-folder-closed');
folderHeader.querySelector('.folder-icon').classList.toggle('fa-folder-open');
if (!doc.icon) { // Only toggle folder icon if using default
folderHeader.querySelector('.folder-icon').classList.toggle('fa-folder-closed');
folderHeader.querySelector('.folder-icon').classList.toggle('fa-folder-open');
}
});
container.appendChild(folderDiv);
@@ -348,10 +353,20 @@ async function loadDocument(path) {
const svg = toggleBtn.querySelector('svg');
const isFolded = svg.style.transform === 'rotate(90deg)';
svg.style.transform = isFolded ? 'rotate(0deg)' : 'rotate(90deg)';
const currentLevel = parseInt(heading.tagName[1]);
let next = heading.nextElementSibling;
while (next && !/^H[1-6]$/.test(next.tagName)) {
next.style.display = isFolded ? 'none' : '';
next = next.nextElementSibling;
while (next) {
if (!/^H[1-6]$/.test(next.tagName)) {
next.style.display = isFolded ? 'none' : '';
next = next.nextElementSibling;
} else {
const nextLevel = parseInt(next.tagName[1]);
if (nextLevel <= currentLevel) {
break;
}
next.style.display = isFolded ? 'none' : '';
next = next.nextElementSibling;
}
}
});
});