File tree 2 files changed +18
-15
lines changed
2 files changed +18
-15
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
# @ceteio/next-layout-loader
2
2
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 3a7005b:
8
+ - Only require magic in ` pages/_app ` , not in every route file.
9
+ - Removed ` options.layoutsDir ` . ` _layout ` files must now always be in ` pages/ ` .
10
+
3
11
## 1.0.0
12
+
4
13
### Major Changes
5
14
6
15
- Initial release.
7
-
16
+
8
17
Add ` _layout.tsx ` files with default exports in your ` pages/ ` directory:
9
-
18
+
10
19
```
11
20
pages
12
21
├── dashboard
17
26
├── _layout.tsx
18
27
└── index.tsx
19
28
```
20
-
29
+
21
30
For example:
22
-
31
+
23
32
``` javascript
24
33
// pages/_layout.tsx
25
34
export default function Layout ({ children }) {
32
41
< / div>
33
42
);
34
43
}
35
-
44
+
36
45
// To hide this layout component from the router / build pipeline
37
46
export const getStaticProps = async () => ({ notFound: true });
38
47
```
39
-
48
+
40
49
Next, load the layout component with
41
50
[ ` preval ` ] ( https://github.com/kentcdodds/babel-plugin-preval ) &
42
51
[ ` codegen ` ] ( https://github.com/kentcdodds/babel-plugin-codegen ) :
43
-
52
+
44
53
``` javascript
45
54
// pages/dashboard/user/index.tsx
46
55
const filename = preval` module.exports = __filename` ;
47
56
const Layout = codegen .require (" @ceteio/next-layout-loader" , filename);
48
-
57
+
49
58
export default function User () {
50
59
return (
51
60
< Layout>
54
63
);
55
64
}
56
65
```
57
-
66
+
58
67
Now, ` <Layout> ` is a composition of all ` _layout.tsx ` files found in the
59
68
` pages/ ` directory from the current file, up to the root (ie;
60
69
` pages/dashboard/user/_layout.tsx ` , ` pages/dashboard/_layout.tsx ` , and
You can’t perform that action at this time.
0 commit comments