mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-29 16:05:47 +08:00
add an event listener to the docs site to listen everytime on load, then
expand the first expandable section ("flame") if the current page is
home page.
22 lines
722 B
JavaScript
22 lines
722 B
JavaScript
// Auto expand the first expandable node ("flame") when loaded.
|
|
window.addEventListener('load', (_event) => {
|
|
expandFirstOnHome();
|
|
});
|
|
|
|
/**
|
|
* This method expands the first expandable node on the home page.
|
|
*
|
|
* If the current page is not the home page, this method does nothing.
|
|
*/
|
|
// When the path name ends with index.html or an empty string, it is home page.
|
|
function expandFirstOnHome() {
|
|
const parts = location.pathname.split('/');
|
|
const lastPart = parts[parts.length - 1];
|
|
const isHomePage = (lastPart == '') || (lastPart == 'index.html');
|
|
|
|
if (isHomePage) {
|
|
// expand the first expandable node in the toctree
|
|
$('li.toctree-l1').has('ul').first().addClass('current');
|
|
}
|
|
}
|