未验证 提交 22800319 编写于 作者: J John Doe 提交者: GitHub

Create _document.js to include current language in HTML tag (#16360)

* Create _document.js

 Includes the lang attribute with current language inside the <html> tag.

* Lint fix
Co-authored-by: NLuis Alvarez D <luis@vercel.com>
Co-authored-by: Nkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
上级 fa153bcf
import Document, { Html, Head, Main, NextScript } from 'next/document'
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps, lang: ctx.query.lng }
}
render() {
return (
<Html lang={this.props.lang}>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册