parent
2cf22c1777
commit
159741f0af
8 changed files with 66 additions and 36 deletions
@ -1,16 +0,0 @@ |
|||||||
import FeaturedContent from 'components/featured-content/index'; |
|
||||||
import HeroSection from 'components/hero-section/index'; |
|
||||||
import PageFooter from 'components/page-footer/index'; |
|
||||||
import PageHeader from 'components/page-header/index'; |
|
||||||
import DefaultLayout from 'layouts/default/index'; |
|
||||||
|
|
||||||
const Home = (props) => ( |
|
||||||
<DefaultLayout> |
|
||||||
<PageHeader /> |
|
||||||
<HeroSection /> |
|
||||||
<FeaturedContent /> |
|
||||||
<PageFooter /> |
|
||||||
</DefaultLayout> |
|
||||||
); |
|
||||||
|
|
||||||
export default Home; |
|
@ -1,10 +1,16 @@ |
|||||||
import Home from './home'; |
import FeaturedContent from 'components/featured-content/index'; |
||||||
import DefaultLayout from 'layouts/default'; |
import HeroSection from 'components/hero-section/index'; |
||||||
|
import PageFooter from 'components/page-footer/index'; |
||||||
|
import PageHeader from 'components/page-header/index'; |
||||||
|
import DefaultLayout from 'layouts/default/index'; |
||||||
|
|
||||||
const Index = () => ( |
const Home = (props) => ( |
||||||
<DefaultLayout> |
<DefaultLayout> |
||||||
<Home /> |
<PageHeader /> |
||||||
|
<HeroSection /> |
||||||
|
<FeaturedContent /> |
||||||
|
<PageFooter /> |
||||||
</DefaultLayout> |
</DefaultLayout> |
||||||
); |
); |
||||||
|
|
||||||
export default Index; |
export default Home; |
||||||
|
@ -0,0 +1,35 @@ |
|||||||
|
const path = require('path'); |
||||||
|
const fs = require('fs'); |
||||||
|
const glob = require('glob'); |
||||||
|
|
||||||
|
const PAGES_PATH = path.join(__dirname, 'pages'); |
||||||
|
|
||||||
|
/** |
||||||
|
* Generate the page routes from the page files inside `/pages` |
||||||
|
* directory. Gives the format understood by next |
||||||
|
* { |
||||||
|
* '/slug': { page: '/path/to-file' } |
||||||
|
* } |
||||||
|
*/ |
||||||
|
const getPageRoutes = () => { |
||||||
|
const files = glob.sync(`${PAGES_PATH}/**/*.js`, { |
||||||
|
ignore: [ |
||||||
|
'**/_*.js', // private non-page files e.g. _document.js
|
||||||
|
'**/[[]*[]].js', // Ignore dynamic pages i.e. `page/[something].js` files
|
||||||
|
'**/[[]*[]]/*.js', // Ignore files inside dynamic pages i.e. `[something]/abc.js`
|
||||||
|
] |
||||||
|
}); |
||||||
|
|
||||||
|
const pageRoutes = {}; |
||||||
|
|
||||||
|
files.forEach(file => { |
||||||
|
const pageName = file.replace(PAGES_PATH, '').replace('.js', ''); |
||||||
|
const pagePath = pageName.replace('/index', '') || '/'; |
||||||
|
|
||||||
|
pageRoutes[pagePath] = { page: `${pageName}` } |
||||||
|
}); |
||||||
|
|
||||||
|
return pageRoutes; |
||||||
|
}; |
||||||
|
|
||||||
|
console.log(getPageRoutes()); |
Loading…
Reference in new issue