import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' import { useState } from 'react' import CONFIG_SIMPLE from '../config_simple' import { NavBarMenu } from './NavBarMenu' /** * 菜单导航 * @param {*} props * @returns */ export const NavBar = (props) => { const { customNav, customMenu } = props const { locale } = useGlobal() const [showSearchInput, changeShowSearchInput] = useState(false) const router = useRouter() const toggleShowSearchInput = () => { changeShowSearchInput(!showSearchInput) } const onKeyUp = (e) => { if (e.keyCode === 13) { const search = document.getElementById('theme-simple-search').value if (search) { router.push({ pathname: '/search/' + search }) } } } let links = [ { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG_SIMPLE.MENU_SEARCH }, { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG_SIMPLE.MENU_ARCHIVE }, { icon: 'fas fa-folder', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_SIMPLE.MENU_CATEGORY }, { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_SIMPLE.MENU_TAG } ] if (customNav) { links = links.concat(customNav) } if (BLOG.CUSTOM_MENU) { links = customMenu } if (!links || links.length === 0) { return null } return ( ) }