next-seo#BreadcrumbJsonLd TypeScript Examples

The following examples show how to use next-seo#BreadcrumbJsonLd. 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: App.tsx    From NextJS-NestJS-GraphQL-Starter with MIT License 5 votes vote down vote up
RenderBreadcrumbs = ({ breadcrumbs, asPath }) => {
  if (!breadcrumbs.length) {
    return null;
  }

  return (
    <>
      <BreadcrumbJsonLd
        itemListElements={[
          {
            label: 'Home',
            as: '/'
          },
          ...breadcrumbs
        ].map((bc, i) => {
          return {
            position: i + 1,
            name: bc.label,
            item: `${CLIENT_DOMAIN}${bc.as ? bc.as : asPath}`
          };
        })}
      />
      <Breadcrumb padding={pagePadding}>
        <Breadcrumb.Item>
          <Link href="/" as="/" passHref>
            <Breadcrumb.Link>Home</Breadcrumb.Link>
          </Link>
        </Breadcrumb.Item>
        {(breadcrumbs || []).map((bc: BreadcrumbItem, index) => {
          return (
            <Breadcrumb.Item
              key={`breadcrumb_${bc.label}_${bc.as}`}
              isCurrent={breadcrumbs.length - 1 === index}
            >
              {bc.href && bc.as ? (
                <Link href={bc.href} as={bc.as} passHref>
                  <Breadcrumb.Link>{bc.label}</Breadcrumb.Link>
                </Link>
              ) : (
                bc.label
              )}
            </Breadcrumb.Item>
          );
        })}
      </Breadcrumb>
    </>
  );
}