little fix

This commit is contained in:
tangly1024.com
2024-01-30 19:07:30 +08:00
parent e63e82cbba
commit 4996cfd002
4 changed files with 20 additions and 20 deletions

View File

@@ -15,8 +15,11 @@ const Utterances = ({ issueTerm, layout }) => {
const [isLoading, setLoading] = useState(true);
useEffect(() => {
const script = document.createElement('script');
const anchor = document.getElementById('comments');
if(!anchor){
return
}
const script = document.createElement('script');
script.onload = () => setLoading(false);
script.setAttribute('src', 'https://utteranc.es/client.js');
script.setAttribute('crossorigin', 'anonymous');
@@ -25,7 +28,7 @@ const Utterances = ({ issueTerm, layout }) => {
script.setAttribute('issue-term', 'title');
// 初始主题
script.setAttribute('theme', isDarkMode ? 'github-dark' : 'github-light');
anchor.appendChild(script);
anchor?.appendChild(script);
return () => {
// anchor.innerHTML = ''