Files
upgrading-ethereum-book/src/components/Subsections.astro
2025-05-23 19:54:09 +01:00

28 lines
746 B
Plaintext

---
import PageList from './PageList.astro';
import '../css/subsections.css';
const { indexArray, pages } = Astro.props;
let index = indexArray;
// Only add the auto index for Parts, not any deeper structure
if (index === undefined || index === null || index.length > 1) return null;
// Special hacky handling for the the /contents page
if (index[0] === -1) {
index = [];
}
// Find pages that are subsections of the page we are on
const indexFilterString = index.length === 0 ? '' : index.join() + ',';
const filteredPages = pages.filter(p => p.data.index.join().startsWith(indexFilterString))
---
{filteredPages.length > 0
? <div class="subsection-list">
<PageList pages={filteredPages} depth={index.length} />
</div>
: null
}