feat(PageTags): Set the language attribute for the document

This commit is contained in:
haitaoo 2023-05-18 11:52:10 +08:00
parent cf10ebef86
commit e1e6627357
1 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { FC, useEffect, useLayoutEffect } from 'react';
import { Helmet } from 'react-helmet-async';
import { brandingStore, pageTagStore, siteInfoStore } from '@/stores';
import { getCurrentLang } from '@/utils/localize';
const doInsertCustomCSS = !document.querySelector('link[href*="custom.css"]');
@ -32,7 +33,19 @@ const Index: FC = () => {
// eslint-disable-next-line no-empty
} catch (ex) {}
};
const currentLang = getCurrentLang();
const setDocLang = () => {
if (currentLang) {
document.documentElement.setAttribute(
'lang',
currentLang.replace('_', '-'),
);
}
};
useEffect(() => {
setDocLang();
}, [currentLang]);
useEffect(() => {
setAppGenerator();
}, [appVersion]);