[Beta] Refactor Layouts (#4975)

* [Beta] Refactor Layouts

* TypeScript

* oops

* Make it work for all pages
This commit is contained in:
dan
2022-09-04 23:18:03 +01:00
committed by GitHub
parent 23ae76f10a
commit ccf8576ab4
11 changed files with 41 additions and 390 deletions

View File

@@ -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);
};