diff --git a/package.json b/package.json index bc373b0..8481b30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sanitypress", - "version": "4.7.2", + "version": "4.7.3", "description": "A Next.js + Sanity.io Starter Template", "author": "nuotsu (https://nuotsu.dev)", "license": "ISC", diff --git a/sanity/schemas/modules/breadcrumbs.ts b/sanity/schemas/modules/breadcrumbs.ts index cc2f744..7307a7c 100644 --- a/sanity/schemas/modules/breadcrumbs.ts +++ b/sanity/schemas/modules/breadcrumbs.ts @@ -14,6 +14,12 @@ export default defineType({ of: [{ type: 'link', initialValue: { type: 'internal' } }], description: 'Current page is automatically included', }), + defineField({ + name: 'hideCurrent', + title: 'Hide current page', + type: 'boolean', + initialValue: false, + }), ], preview: { select: { diff --git a/src/ui/modules/Breadcrumbs.tsx b/src/ui/modules/Breadcrumbs.tsx index cd233f1..c8be9ba 100644 --- a/src/ui/modules/Breadcrumbs.tsx +++ b/src/ui/modules/Breadcrumbs.tsx @@ -4,9 +4,11 @@ import { stegaClean } from '@sanity/client/stega' export default async function Breadcrumbs({ crumbs, + hideCurrent, currentPage, }: Partial<{ crumbs: Sanity.Link[] + hideCurrent?: boolean currentPage: Sanity.Page | Sanity.BlogPost }>) { return ( @@ -20,13 +22,15 @@ export default async function Breadcrumbs({ -
  • - / -
  • + {(key < crumbs.length - 1 || !hideCurrent) && ( +
  • + / +
  • + )}
    ))} - + @@ -38,13 +42,15 @@ function Crumb({ link, position, children, + hidden, }: { link?: Omit position: number + hide?: boolean } & React.ComponentProps<'li'>) { const content = ( <> - +