@11ty/eleventy
Version:
A simpler static site generator.
18 lines (16 loc) • 354 B
JavaScript
// TODO locale-friendly, see GetLocaleCollectionItem.js)
export default function getCollectionItemIndex(collection, page) {
if (!page) {
page = this.page;
}
let j = 0;
for (let item of collection) {
if (
item.inputPath === page.inputPath &&
(item.outputPath === page.outputPath || item.url === page.url)
) {
return j;
}
j++;
}
}