next-seo#LogoJsonLd TypeScript Examples
The following examples show how to use
next-seo#LogoJsonLd.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Header.tsx From frontend with Apache License 2.0 | 4 votes |
Header = () => {
const { t } = useTranslation();
const router = useRouter()
const [query, setQuery] = useState('')
const [isMenuOpen, setMenuOpen] = useState(false)
useEffect(() => {
const q = router.query.query as string
if (q) {
setQuery(q)
}
}, [router.query.query])
const mobileSize = 768
const [isMobile, setIsMobile] = useState(true)
useEffect(() => {
window.addEventListener(
'resize',
() => {
const ismobile = window.innerWidth < mobileSize
if (ismobile !== isMobile) setIsMobile(ismobile)
},
false
)
return () => {
window.removeEventListener('resize', () => { }, false)
}
}, [isMobile])
const onChange = (e: ChangeEvent<HTMLInputElement>) => {
e.preventDefault()
setQuery(e.target.value)
}
const onSubmit = (e: ChangeEvent<HTMLFormElement>) => {
e.preventDefault()
if (query !== '') {
router.push(`/apps/search/${query}`)
}
}
const toggleMenu = () => {
setMenuOpen(!isMenuOpen)
}
return (
<header className={styles.header}>
<nav className={styles.navHeader}>
<span className={styles.brandContainer}>
<LogoJsonLd
logo={`${env.NEXT_PUBLIC_BASE_URL}/img/logo/flathub-logo-toolbar.svg`}
url={`${env.NEXT_PUBLIC_BASE_URL}`}
/>
<Link href='/' passHref>
<a id={styles.brand} title={t('go-home')}></a>
</Link>
</span>
<div id={styles.search}>
<SiteLinksSearchBoxJsonLd
url={process.env.NEXT_PUBLIC_SITE_BASE_URI}
potentialActions={[
{
target: `${process.env.NEXT_PUBLIC_SITE_BASE_URI}/apps/search/{search_term_string}`,
queryInput: 'search_term_string',
},
]}
/>
<form onSubmit={onSubmit}>
<MdSearch className={styles.searchIcon} />
<input
type='search'
name='q'
placeholder={t('search-apps')}
onChange={onChange}
value={query}
aria-label={t('search-apps')}
/>
</form>
</div>
<span className={`${styles.navbarContainer}`}>
<div
id={styles.navbar}
className={`${isMenuOpen && isMobile ? styles.responsive : ''}`}
>
<div className={styles.navItem}>
<a
href='https://github.com/flathub/flathub/wiki/App-Submission'
target='_blank'
rel='noreferrer'
>
{t('publish')}
</a>
</div>
<div className={styles.navItem}>
<a
href='https://discourse.flathub.org/'
target='_blank'
rel='noreferrer'
>
{t('forum')}
</a>
</div>
<Link href='/about' passHref>
<a className={styles.navItem}>{t('about')}</a>
</Link>
</div>
<div className={styles.toggleContainer}>
<span className={`${styles.navbarToggle}`} onClick={toggleMenu}>
{isMenuOpen && isMobile ? <MdMenuOpen /> : <MdMenu />}
</span>
</div>
</span>
</nav>
</header>
)
}