Skip to content

Commit

Permalink
NAV主题 导航优化
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Jan 31, 2024
1 parent 80a1411 commit c0c18e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion themes/nav/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Footer = ({ siteInfo }) => {
© {`${copyrightDate}`}
</div>

<div className='text-xs font-serif py-1'>Powered By <a href='https://github.com/tangly1024/NotionNext' className='underline text-gray-500 dark:text-gray-300'>NotionNext</a></div>
<div className='text-xs font-serif py-1'>Powered By <a href='https://github.com/tangly1024/NotionNext' className='underline text-gray-500 dark:text-gray-300'>NotionNext {siteConfig('VERSION')}</a></div>

{siteConfig('BEI_AN') && <><i className='fas fa-shield-alt' /> <a href='https://beian.miit.gov.cn/' className='mr-2'>{siteConfig('BEI_AN')}</a><br /></>}

Expand Down
20 changes: 11 additions & 9 deletions themes/nav/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const MenuItem = ({ link }) => {
}

// #号加标题 快速跳转到指定锚点
const url = link?.to && link?.to !=='#' ? link.to : ('#' + link.name)
console.log(link,url , '#' + link.name)
const isAnchor = link?.to === '#'
const url = isAnchor ? ('#' + link.name) : link.to

return <>
{/* 菜单 */}
Expand All @@ -33,31 +33,33 @@ export const MenuItem = ({ link }) => {
{link?.subMenus
? (<>
<span className='dark:text-neutral-400 dark:hover:text-white font-bold w-full display-block'>
{link?.icon && <i className={`text-base ${link?.icon}`} />}{link?.title}
<i className={`text-base ${link?.icon ? link?.icon : (isAnchor ? 'fas fa-hashtag' : '')} mr-1`} />{link?.title}
</span>
<div className='inline-flex items-center select-none pointer-events-none '>
<i className={`${isOpen ? '-rotate-90' : ''} text-xs dark:text-neutral-500 text-gray-300 hover:text-black dark:hover:text-white-400 px-2 fas fa-chevron-left transition-all duration-200`}></i>
</div>
</>)
: (
<Link href={url} className='dark:text-neutral-400 dark:hover:text-white font-bold w-full display-block'>
{link?.icon && <i className={`text-base ${link?.icon}`} />}{link?.title}
<i className={`text-base ${link?.icon ? link?.icon : (isAnchor ? 'fas fa-hashtag' : '')} mr-1`} />{link?.title}
</Link>
)

}
</div>

{/* 菜单按钮 */}
{/* 子菜单按钮 */}
{link?.subMenus && (
<Collapse isOpen={isOpen} key='collapse'>
{
link?.subMenus?.map((sLink, index) => {
// #号加标题 快速跳转到指定锚点
const sUrl = sLink?.to && sLink?.to.length !=='#' ? sLink.to : ('#' + sLink.name)
return <div key={index} className='nav-submenu'>
// #号加标题 快速跳转到指定锚点
const sIsAnchor = sLink?.to === '#'
const sUrl = sIsAnchor ? sLink.to : ('#' + sLink.name)
return <div key={index} className='nav-submenu'>
<Link href={sUrl}>
<span className='dark:text-neutral-400 text-gray-500 hover:text-black dark:hover:text-white text-xs font-bold'><i className={`text-xs mr-1 ${sLink?.icon ? sLink?.icon : 'fas fa-hashtag'}`} />{sLink.title}</span>
<span className='dark:text-neutral-400 text-gray-500 hover:text-black dark:hover:text-white text-xs font-bold'>
<i className={`text-xs mr-1 ${sLink?.icon ? sLink?.icon : (sIsAnchor ? 'fas fa-hashtag' : '')}`} />{sLink.title}</span>
</Link>
</div>
})
Expand Down

0 comments on commit c0c18e3

Please sign in to comment.