'x'
This commit is contained in:
17
app/components/SetLangAttr.tsx
Normal file
17
app/components/SetLangAttr.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useLocale } from "@/i18n/navigation";
|
||||
|
||||
/**
|
||||
* 根据当前 locale 设置 document.documentElement.lang,以支持无障碍与 SEO
|
||||
*/
|
||||
export default function SetLangAttr() {
|
||||
const locale = useLocale();
|
||||
|
||||
useEffect(() => {
|
||||
document.documentElement.lang = locale === "zh" ? "zh-CN" : "en";
|
||||
}, [locale]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user