mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
[Beta] Refactor Layouts (#4975)
* [Beta] Refactor Layouts * TypeScript * oops * Make it work for all pages
This commit is contained in:
@@ -20,19 +20,11 @@ module.exports = async function (src) {
|
||||
.dirname(path.relative('./src/pages', this.resourcePath))
|
||||
.split(path.sep)
|
||||
.shift();
|
||||
const layoutMap = {
|
||||
blog: 'Post',
|
||||
learn: 'Learn',
|
||||
apis: 'API',
|
||||
};
|
||||
const layout = layoutMap[pageParentDir] || 'Home';
|
||||
const code =
|
||||
`import withLayout from 'components/Layout/Layout${layout}';
|
||||
|
||||
export default withLayout(${JSON.stringify(data)})
|
||||
|
||||
|
||||
`export const layout = {
|
||||
section: '${pageParentDir}',
|
||||
meta: ${JSON.stringify(data)}
|
||||
};\n
|
||||
` + content;
|
||||
|
||||
return callback(null, code);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user