Layout
Add a new layout
Take a new layout named secondary as an example to make the route starting with secondary use this layout.
- Add related configuration in
src/utils/config.js. For details, please refer to layouts.
layouts: [
{
name: 'primary',
include: [/.*/],
exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/secondary\/(.*)/],
},
{
name: 'secondary',
include: [/(\/(en|zh))*\/secondary\/(.*)/],
},
],
- Add the
secondarylayout component to thesrc/layouts/BaseLayout.jsfile.
import SecondaryLayout from './SecondaryLayout'
const LayoutMap = {
primary: PrimaryLayout,
public: PublicLayout,
secondary: SecondaryLayout,
}
- Add the
SecondaryLayout.jsfile to thesrc/layouts/directory.
import React from 'react'
export default ({ children }) => {
return (
<div>
<h1>Secondary</h1>
{children}
</div>
)
}
- Add a
secondary/index.jsfile to thesrc/pages/directory.
import React from 'react'
export default ({ children }) => {
Return <div>Secondary page Content</div>
}
- Finally, start the development mode
npm run start, open http://localhost:7000/secondary/ and you will see the page for thesecondarylayout.