gpt4 book ai didi

html - NextJS html [lang] 默认缺失

转载 作者:行者123 更新时间:2023-12-04 03:31:37 25 4
gpt4 key购买 nike

在我的 NextJS 投资组合网站上运行一些性能检查后,我注意到主要的 index.html 缺少一个 lang 属性 - 它作为可访问性分数的扣除而返回。
我可以使用 i18n 设置将语言环境添加到 next.config.js ,但这些功能与 next export 不兼容 - 该站点是静态生成的。

Error: i18n support is not compatible with next export. See here for more info on deploying: https://nextjs.org/docs/deployment
有没有其他方法可以添加 [lang] 属性。

最佳答案

您可以将 lang 属性添加到自定义 <Html> 中的 _document 标记。

import Document, { Html, Head, Main, NextScript } from 'next/document'

class MyDocument extends Document {
render() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}

export default MyDocument

关于html - NextJS html [lang] 默认缺失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66710971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com