react-static
Version:
A progressive static site generator for React
49 lines (46 loc) • 1.04 kB
JavaScript
import { reloadRoutes } from 'react-static/node'
import jdown from 'jdown'
import chokidar from 'chokidar'
chokidar.watch('content').on('all', () => reloadRoutes())
export default {
getSiteData: () => ({
title: 'React Static',
}),
getRoutes: async () => {
const { posts, home, about } = await jdown('content')
return [
{
path: '/',
component: 'src/containers/Home',
getData: () => ({
...home,
}),
},
{
path: '/about',
component: 'src/containers/About',
getData: () => ({
about,
}),
},
{
path: '/blog',
component: 'src/containers/Blog',
getData: () => ({
posts,
}),
children: posts.map(post => ({
path: `/post/${post.slug}`,
component: 'src/containers/Post',
getData: () => ({
post,
}),
})),
},
{
is404: true,
component: 'src/containers/404',
},
]
},
}