4.0.0
High Level Updates
- This plugin now works with
next@9.5.x
- sorry for the delay and thank you to everyone who helped get this update over the finish line! - There is now support for using a
src
folder with your next app - The way that layouts are structured is now significantly cleaner and a full closure can be removed
Migration Path
-
All layouts must remove their top level closure, frontmatter is now an argument passed directly to the inner layout function. For example, if you previously had the following layout:
export default (frontMatter) => { return function Layout({ children }) { return ( <> <h1>{frontMatter.title}</h1> {children} </> ) } }
...your code can now be simplified as such:
export default function Layout({ children, frontMatter }) { return ( <> <h1>{frontMatter.title}</h1> {children} </> ) }
It's also worth noting that you must use a named function as your layout name, or you will have issues with fast refresh in next.js. This is generally true of all next.js pages, and is not specific to this plugin. Use named functions.
-
If you were exporting
getStaticProps
,getStaticPaths
, and/orgetServerSideProps
on your layout file, you can still do this but it requires adding thereExportDataFetching
option to the configuration. Without this option set totrue
, data fetching method exports will not work.
Credits
I am beyond thrilled by the widespread community effort to get this release out. Huge thanks to @44px, @LoriKarikari, @Ekrekr, @jemjam, @johnforte, and @keyz for helping! 💖
Commit Log
- Update deps: 79969c1
- Fix small typo in README: #69
- Add missing curly brace to example in README: #70
- Add note in readme where hooks should go in layout: #71
- Add explicit re-exporting for data fetching functions from layouts: eed7835
- Misc fixes: #77
- Merge pull request #78 from hashicorp/je.re-export-data-fetching-fix: 3fe8a9d
- Feat: added usesSrc or auto detects src folder for pages: fe5a536
- Feat: added testing around new usessrc: 3769f13
- Feat: moved pages dir into plugin options at load time: 2132f47
- Fix: make sure docs page is pointing to src folder for pages.: c79d45e
- Ci: cleaned up test variable name to be more verbose: 5f42861
- Feat: added usesSrc to docs: 8421d21
- Update dependencies: 09de8e0
- Fix(next-compat): Update loader for Next 9.5.2: da9c967
- Fix(tests): Update tests to work with new layouts: a62474c
- Update example with named function: b9a9ad8
- Fix a test: 17c425d
- Update deps: 53db0ac