Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

4.0.0

Compare
Choose a tag to compare
@jescalan jescalan released this 26 Aug 16:40
18d1945

⚠️ Warning ⚠️ This is a major release that is guaranteed to break your code unless you make some changes

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/or getServerSideProps on your layout file, you can still do this but it requires adding the reExportDataFetching option to the configuration. Without this option set to true, 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