Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 3x 3x 3x 3x 3x 3x 5x 5x 5x 5x 5x | import { useRouter } from 'next/router';
import React from 'react';
import { author as auth } from '@/constants/site';
import Head from 'next/head';
import {
alternateLinks,
articleTags,
blogTags,
imageTags,
ogLocaleTags,
resolveSeoUrls,
robotsTags,
staticHreflangTags,
type SeoMeta,
} from './tags';
type Props = {
isBlog?: boolean;
noimage?: boolean;
meta?: SeoMeta;
};
/**
* @example
* <SEO meta={meta} isBlog={true} />;
*
* @param {object} meta - The object containing the meta data for SEO
* @param {boolean} isBlog - Whether the page is a blog post the SEO changes
* @param {boolean} noimage - Whether to show the image in the SEO
* @returns {JSX.Element}
*/
const SEO = ({ meta, isBlog, noimage = true }: Props) => {
const { locale, pathname } = useRouter();
const urls = resolveSeoUrls({ meta, isBlog, locale, pathname });
const author = meta?.author || auth;
const description = meta?.description;
return (
<Head>
{isBlog ? blogTags({ meta, locale, author, urls }) : staticHreflangTags(urls.domain, urls.pagePath)}
<title>{meta?.title}</title>
{robotsTags(meta?.noindex)}
<meta name="author" content={author} />
<meta name="description" content={description} />
<meta property="og:description" content={description} />
<meta name="twitter:description" content={description} />
<meta property="og:title" content={meta?.title} />
<meta name="twitter:title" content={meta?.title} />
<meta property="og:type" content={isBlog ? 'article' : 'website'} />
{articleTags(isBlog, meta)}
{imageTags(noimage, urls.imageUrl, meta?.title)}
<meta property="og:url" content={urls.url} />
{ogLocaleTags(locale)}
<link rel="canonical" href={urls.url} title="Canonical url" />
{alternateLinks(meta, urls.domain, urls.category)}
</Head>
);
};
export default SEO;
|