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 (
diff --git a/themes/nav/components/BlogPostItem.js b/themes/nav/components/BlogPostItem.js index 5d8c6406..98859178 100755 --- a/themes/nav/components/BlogPostItem.js +++ b/themes/nav/components/BlogPostItem.js @@ -10,10 +10,6 @@ import BlogPostCard from './BlogPostCard' */ const BlogPostItem = (props) => { const { group } = props - - console.log('####### group') - console.log(group) - if (group?.category) { return <>
diff --git a/themes/nav/components/MenuItem.js b/themes/nav/components/MenuItem.js index 84d2a42e..f1b1acc1 100644 --- a/themes/nav/components/MenuItem.js +++ b/themes/nav/components/MenuItem.js @@ -20,6 +20,10 @@ export const MenuItem = ({ link }) => { return null } + // #号加标题 快速跳转到指定锚点 + const url = link?.to && link?.to !=='#' ? link.to : ('#' + link.name) + console.log(link,url , '#' + link.name) + return <> {/* 菜单 */}
{
) : ( - + {link?.icon && }{link?.title} ) @@ -48,13 +52,15 @@ export const MenuItem = ({ link }) => { {link?.subMenus && ( { - link?.subMenus?.map((sLink, index) => ( -
- - {sLink.title} - -
- )) + link?.subMenus?.map((sLink, index) => { + // #号加标题 快速跳转到指定锚点 + const sUrl = sLink?.to && sLink?.to.length !=='#' ? sLink.to : ('#' + sLink.name) + return
+ + {sLink.title} + +
+ }) }
diff --git a/themes/nav/components/SearchInput.js b/themes/nav/components/SearchInput.js index 45dfc4e9..2e8b640e 100755 --- a/themes/nav/components/SearchInput.js +++ b/themes/nav/components/SearchInput.js @@ -40,7 +40,7 @@ const SearchInput = ({ currentSearch, cRef, className }) => { // } for (let i = filterAllNavPages.length - 1; i >= 0; i--) { const post = filterAllNavPages[i] - const articleInfo = post.title + '' + const articleInfo = post.title + ' ' + post.summary const hit = articleInfo.toLowerCase().indexOf(keyword.toLowerCase()) > -1 if (!hit) { // 删除 diff --git a/themes/nav/components/TopNavBar.js b/themes/nav/components/TopNavBar.js index fab5463c..cee758c6 100755 --- a/themes/nav/components/TopNavBar.js +++ b/themes/nav/components/TopNavBar.js @@ -52,7 +52,7 @@ export default function TopNavBar(props) { return (
{/* 图标Logo */} -
+
diff --git a/themes/nav/index.js b/themes/nav/index.js index bf6e4662..b09fe080 100755 --- a/themes/nav/index.js +++ b/themes/nav/index.js @@ -30,9 +30,10 @@ import BlogPostListAll from './components/BlogPostListAll' import BlogPostCard from './components/BlogPostCard' import Link from 'next/link' import dynamic from 'next/dynamic' - import { MenuItem } from './components/MenuItem' +import LogoBar from './components/LogoBar' import { siteConfig } from '@/lib/config' + const WWAds = dynamic(() => import('@/components/WWAds'), { ssr: false }) // 主题全局变量 @@ -75,7 +76,7 @@ const LayoutBase = (props) => {