盖茨比以编程方式更改布局

Gatsby changing layout programmatically

开始使用 Gatsby (v2),我想知道什么是处理 Behance 网站上可见场景的最佳方法,即以下场景:

有什么方法可以在运行时定义 Layout 吗? 2 场景带来完全相同的 URL.

感谢您的任何建议。

我认为这是您可以查看的完美示例: https://github.com/gatsbyjs/gatsby/tree/master/examples/gatsbygram

gatsby-browser.js 它设置了这个函数:

exports.onInitialClientRender = () => {
  window.___GATSBYGRAM_INITIAL_RENDER_COMPLETE = true
}

https://www.gatsbyjs.org/docs/browser-apis/#onInitialClientRender

然后根据您在问题中描述的内容在 src/templates/post-page.js 中设置 isModal