mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-22 23:30:35 +08:00
Setup website with docusaurus (#11)
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
This commit is contained in:
committed by
Facebook Github Bot
parent
e290f87ca9
commit
15d3a4557e
88
website/core/TutorialSidebar.js
Normal file
88
website/core/TutorialSidebar.js
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* 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;
|
||||
Reference in New Issue
Block a user