diff --git a/components/Utterances.js b/components/Utterances.js index 34c4f09c..15ceb97a 100644 --- a/components/Utterances.js +++ b/components/Utterances.js @@ -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 = '' diff --git a/themes/nav/components/BlogPostCard.js b/themes/nav/components/BlogPostCard.js index 73622062..e0040f7a 100755 --- a/themes/nav/components/BlogPostCard.js +++ b/themes/nav/components/BlogPostCard.js @@ -6,7 +6,8 @@ import { siteConfig } from '@/lib/config' const BlogPostCard = ({ post, className }) => { const router = useRouter() const currentSelected = router.asPath.split('?')[0] === '/' + post.slug - const pageIcon = post.pageIcon.indexOf('amazonaws.com') !== -1 ? post.pageIcon + '&width=88' : post.pageIcon + let pageIcon = post.pageIcon !== '' ? post.pageIcon : siteConfig('IMG_LAZY_LOAD_PLACEHOLDER') + pageIcon = post.pageIcon.indexOf('amazonaws.com') !== -1 ? post.pageIcon + '&width=88' : post.pageIcon return (