mirror of
https://github.com/imfing/hextra.git
synced 2025-06-19 22:51:18 -04:00
fix: remove extra space for rendered link
chore: update theme info chore: use dataset chore: support editURL config option * add toc and search config option chore: update head template
This commit is contained in:
@ -79,7 +79,7 @@
|
||||
const result = resultsElement.querySelector('.active');
|
||||
if (!result) return { result: undefined, index: -1 };
|
||||
|
||||
const index = parseInt(result.getAttribute('data-index'));
|
||||
const index = parseInt(result.dataset.index, 10);
|
||||
return { result, index };
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@
|
||||
function getResultsLength() {
|
||||
const { resultsElement } = getActiveSearchElement();
|
||||
if (!resultsElement) return 0;
|
||||
return resultsElement.querySelectorAll('li').length;
|
||||
return resultsElement.dataset.count;
|
||||
}
|
||||
|
||||
// Finish the search by hiding the results and clearing the input.
|
||||
@ -304,6 +304,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Highlight the query in the result text.
|
||||
function highlightMatches(text, query) {
|
||||
const escapedQuery = query.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
const regex = new RegExp(escapedQuery, 'gi');
|
||||
@ -349,5 +350,6 @@
|
||||
fragment.appendChild(li);
|
||||
}
|
||||
resultsElement.appendChild(fragment);
|
||||
resultsElement.dataset.count = results.length;
|
||||
}
|
||||
})();
|
||||
|
@ -2,19 +2,19 @@ document.querySelectorAll('.tabs-toggle').forEach(function (button) {
|
||||
button.addEventListener('click', function (e) {
|
||||
// set parent tabs to unselected
|
||||
const tabs = Array.from(e.target.parentElement.querySelectorAll('.tabs-toggle'));
|
||||
tabs.map(tab => tab.setAttribute('data-state', ''));
|
||||
tabs.map(tab => tab.dataset.state = '');
|
||||
|
||||
// set current tab to selected
|
||||
e.target.setAttribute('data-state', 'selected');
|
||||
e.target.dataset.state = 'selected';
|
||||
|
||||
// set all panels to unselected
|
||||
const panelsContainer = e.target.parentElement.nextElementSibling;
|
||||
Array.from(panelsContainer.children).forEach(function (panel) {
|
||||
panel.setAttribute('data-state', '');
|
||||
panel.dataset.state = '';
|
||||
});
|
||||
|
||||
const panelId = e.target.getAttribute('aria-controls');
|
||||
const panel = panelsContainer.querySelector(`#${panelId}`);
|
||||
panel.setAttribute('data-state', 'selected');
|
||||
panel.dataset.state = 'selected';
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user