in website/core/TutorialSidebar.js [30:105]
render() {
const {currentTutorialID} = this.props;
const current = {
id: currentTutorialID || OVERVIEW_ID,
};
const toc = [
{
type: 'CATEGORY',
title: 'Captum Tutorials',
children: [
{
type: 'LINK',
item: {
permalink: 'tutorials/',
id: OVERVIEW_ID,
title: 'Overview',
},
},
],
},
];
const jsonFile = join(CWD, 'tutorials.json');
const normJsonFile = path.normalize(jsonFile);
const json = JSON.parse(fs.readFileSync(normJsonFile, {encoding: 'utf8'}));
Object.keys(json).forEach(category => {
const categoryItems = json[category];
const items = categoryItems.map(item => {
if (item.id !== undefined) {
return {
type: 'LINK',
item: {
permalink: `tutorials/${item.id}`,
id: item.id,
title: item.title,
},
}
}
return {
type: 'SUBCATEGORY',
title: item.title,
children: item.children.map(iitem => {
return {
type: 'Link',
item: {
permalink: `tutorials/${iitem.id}`,
id: iitem.id,
title: iitem.title,
}
};
}),
}
});
toc.push({
type: 'CATEGORY',
title: category,
children: items,
});
});
return (
<Container className="docsNavContainer" id="docsNav" wrapper={false}>
<SideNav
language={'tutorials'}
root={'tutorials'}
title="Tutorials"
contents={toc}
current={current}
/>
</Container>
);
}