IndexExtractorclass
new IndexExtractor<I>(source: Extractor<I, TreeElement>, { index = DEFAULT_INDEX }: IndexExtractorOptions = {})| Param | Type | |
|---|---|---|
source | Extractor<I, TreeElement> | Upstream extractor that produces the tree-element tree to process. required |
options | IndexExtractorOptions | Options for an IndexExtractor. Defaults to {} |
.index | Matchables | Filename patterns treated as a parent's index. Matched case-insensitively against each child element's key.- Defaults to README and index files: ["readme.txt", "readme.md", "index.md", "index.ts", "index.tsx"]. readonly |
| Return | |
|---|---|
IndexExtractor<I> | Through extractor that absorbs each element's index child into the element itself. |
Through extractor that absorbs each element's index child into the element itself.
- For every element with children: finds the first child whose
keymatches anyindexpattern. - The matched child's
title,description,content, andchildrenare folded into the parent. - The matched child is removed from the parent's children list.
- Purely name-based: it doesn't care whether an element is a directory or a file — any element with children is processed, deepest level first.
Examples
const extractor = new IndexExtractor(new DirectoryExtractor());