-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove layoutProps
from transpiled output
#742
Comments
I would love this! The |
For people who stumble upon this and are looking for a quick fix, I wrote a Babel plugin which removes these three functions from // https://nextjs.org/docs/basic-features/data-fetching
const DATA_FETCH_FNS = ['getStaticPaths', 'getStaticProps', 'getServerProps']
module.exports = () => {
return {
visitor: {
ObjectProperty(path) {
if (
DATA_FETCH_FNS.includes(path.node.value.name) &&
path.findParent(
(path) =>
path.isVariableDeclarator() &&
path.node.id.name === 'layoutProps',
)
) {
path.remove()
}
},
},
}
} Copy this into a file and add it to your Babel configuration: // babel.config.js
module.exports = {
presets: [
'next/babel',
],
plugins: [
'./etc/babel-plugin-nextjs-mdx-patch',
],
} |
I'm using mdx to define pages in Next.js, via its import Head from 'next/head';
const Wrapper = ({ children, title }) => (
<main>
<Head>
<title>{title}</title>
</Head>
{children}
</main>
); This works because the |
Closed by #1199 (v2 branch) |
Since these values are already available in scope since they're exports, we can avoid instantiating the object and passing to MDXLayout.
The text was updated successfully, but these errors were encountered: