Skip to content
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

Next #100

Open
xiaotiandada opened this issue Apr 22, 2022 · 0 comments
Open

Next #100

xiaotiandada opened this issue Apr 22, 2022 · 0 comments
Labels

Comments

@xiaotiandada
Copy link
Owner

xiaotiandada commented Apr 22, 2022

next/image

SEO

next-seo images 参数是一个数组,大部分情况都是使用最后一张作为封面。如果需要特定图片作为封面可只设置一张。

PWA

Tip: Put the viewport head meta tag into _app.js rather than in _document.js if you need it.

Layout

Vercel

λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
○ (Static) automatically rendered as static HTML (uses no initial props)
● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)

Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Create a team (Pro plan) to deploy more. Learn More: https://vercel.link/function-count-limit

https://cant-xt.vercel.app/docs/folder-structure/next 一些 serverless limit 规则

Header

SharedArrayBuffer

嵌入 iframe 需要支持 SharedArrayBuffer, 父级需要定义 header. 一些相关记录

#111
#112
#113

[
  {
    key: 'Cross-Origin-Embedder-Policy',
    value: 'require-corp',
  },
  {
    key: 'Cross-Origin-Opener-Policy',
    value: 'same-origin',
  },
]

iframe 源也开启了会被拒绝链接

image

页面

image

第一次进入页面会 SSG 渲染页面。但是只在 /game 页面下定义了 header 参数,故首页无参数。

[.   
    {
        source: '/game/:path*',
        headers: COEPHeaders,
      },
      {
        source: '/zh-CN/game/:path*',
        headers: COEPHeaders,
      }
]
  • 如果直接从 /game 路由下进入响应 header
  • 如果从首页/其他页面 进入 /game 路由则不会响应 header
  • 切换页面返回数据 应该是客户端渲染 CSR https://juejin.cn/post/6925308376976982029
    • /_next/static/chunks/pages/game/%5Bid%5D.js Content-Type: application/javascript; charset=UTF-8
    • /_next/data/development/en-US/game/177.json?id=177 Content-Type: application/json

image

image

image

getStaticProps

https://nextjs.org/docs/api-reference/data-fetching/get-static-props

getStaticProps context locale 参数,默认定义为 locale?: string。大概看了一下源码的定义

https://github.com/vercel/next.js/blob/39302141b5ea3a1e9a55af906129a44675337cf9/packages/next/export/index.ts#L375

locales: i18n?.locales,
locale: i18n?.defaultLocale,
defaultLocale: i18n?.defaultLocale,
domainLocales: i18n?.domains,

猜测应该是这里处理的。因为我们定义了 i18n config,locale 使用了 i18n?.defaultLocale 配置。然后会根据 cookie 或 url 路径处理好当前语言环境。

可能返回 en-US | zh-CN

可以修改类型消除错误 ...(await serverSideTranslations(ctx.locale as string, ['common'])),

webassembly

vercel/next.js#25852

Jest

Production Branch

切换生产分支

@xiaotiandada xiaotiandada added the Next Next label Apr 22, 2022
@xiaotiandada xiaotiandada changed the title Next.js 学习 Next 学习 Apr 22, 2022
@xiaotiandada xiaotiandada changed the title Next 学习 Next Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant