mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-01 03:12:49 +08:00
Summary: Set up landing page, docs page, and html versions of the ipython notebook tutorials. Pull Request resolved: https://github.com/fairinternal/pytorch3d/pull/11 Reviewed By: gkioxari Differential Revision: D19730380 Pulled By: nikhilaravi fbshipit-source-id: 5df8d3f2ac2f8dce4d51f5d14fc336508c2fd0ea
89 lines
1.9 KiB
JavaScript
89 lines
1.9 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
* @format
|
|
*/
|
|
|
|
const React = require('react');
|
|
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
const join = path.join;
|
|
const CWD = process.cwd();
|
|
|
|
const CompLibrary = require(join(
|
|
CWD,
|
|
'/node_modules/docusaurus/lib/core/CompLibrary.js',
|
|
));
|
|
const SideNav = require(join(
|
|
CWD,
|
|
'/node_modules/docusaurus/lib/core/nav/SideNav.js',
|
|
));
|
|
|
|
const Container = CompLibrary.Container;
|
|
|
|
const OVERVIEW_ID = 'tutorial_overview';
|
|
|
|
class TutorialSidebar extends React.Component {
|
|
render() {
|
|
const {currentTutorialID} = this.props;
|
|
const current = {
|
|
id: currentTutorialID || OVERVIEW_ID,
|
|
};
|
|
|
|
const toc = [
|
|
{
|
|
type: 'CATEGORY',
|
|
title: '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 => {
|
|
items.push({
|
|
type: 'LINK',
|
|
item: {
|
|
permalink: `tutorials/${item.id}`,
|
|
id: item.id,
|
|
title: item.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>
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = TutorialSidebar;
|