mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 00:27:21 +02:00
feat: prototype blog & docs generation on dev
This commit is contained in:
parent
187a46d9b6
commit
221023fd51
12 changed files with 181 additions and 37 deletions
|
@ -1,8 +1,19 @@
|
|||
import React from 'react';
|
||||
import {render} from 'react-dom';
|
||||
import {BrowserRouter, Route, Switch, Link} from 'react-router-dom';
|
||||
import blogDatas from '@generated/blogDatas';
|
||||
import BlogPost from './blogPost';
|
||||
import blogMetadata from '@generated/blogMetadata';
|
||||
import docsMetadata from '@generated/docsMetadata';
|
||||
import Blog from './blog';
|
||||
import Docs from './docs';
|
||||
|
||||
const renderBlog = props => {
|
||||
const metadata = blogMetadata.find(blog => blog.path === props.match.path);
|
||||
return <Blog content={metadata.content} {...props} />;
|
||||
};
|
||||
const renderDocs = props => {
|
||||
const metadata = docsMetadata.find(doc => doc.path === props.match.path);
|
||||
return <Docs content={metadata.content} {...props} />;
|
||||
};
|
||||
|
||||
class App extends React.Component {
|
||||
render() {
|
||||
|
@ -10,17 +21,13 @@ class App extends React.Component {
|
|||
<BrowserRouter>
|
||||
<div>
|
||||
<Switch>
|
||||
{blogDatas.map(({path}) => (
|
||||
<Route key={path} exact path={path} component={BlogPost} />
|
||||
{blogMetadata.map(({path, content}) => (
|
||||
<Route key={path} exact path={path} render={renderBlog} />
|
||||
))}
|
||||
{docsMetadata.map(({path}) => (
|
||||
<Route key={path} exact path={path} render={renderDocs} />
|
||||
))}
|
||||
</Switch>
|
||||
<div>
|
||||
{blogDatas.map(({path}) => (
|
||||
<div key={path}>
|
||||
<Link to={path}>{path}</Link>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue