Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
fix: rename type Breadcrumb to BreadcrumbList
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Aug 15, 2022
1 parent 50b45be commit 5bad91f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/nodes/Breadcrumb/index.test.ts
@@ -1,6 +1,6 @@
import { expect } from 'vitest'
import { injectSchemaOrg, useSchemaOrg, useSetup } from '../../../.test'
import type { Breadcrumb } from './index'
import type { BreadcrumbList } from './index'
import { PrimaryBreadcrumbId } from './index'
import { defineBreadcrumb } from '#provider'

Expand All @@ -19,7 +19,7 @@ describe('defineBreadcrumb', () => {

const { findNode } = injectSchemaOrg()

const breadcrumbs = findNode<Breadcrumb>(PrimaryBreadcrumbId)
const breadcrumbs = findNode<BreadcrumbList>(PrimaryBreadcrumbId)

expect(breadcrumbs).toMatchInlineSnapshot(`
{
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/Breadcrumb/index.ts
Expand Up @@ -35,14 +35,14 @@ export interface BreadcrumbLite extends Thing {
numberOfItems?: number
}

export interface Breadcrumb extends BreadcrumbLite {}
export interface BreadcrumbList extends BreadcrumbLite {}

export const PrimaryBreadcrumbId = '#breadcrumb'

/**
* Describes the hierarchical position a WebPage within a WebSite.
*/
export const breadcrumbResolver = defineSchemaOrgResolver<Breadcrumb>({
export const breadcrumbResolver = defineSchemaOrgResolver<BreadcrumbList>({
defaults: {
'@type': 'BreadcrumbList',
},
Expand Down
6 changes: 3 additions & 3 deletions src/nodes/WebPage/index.ts
Expand Up @@ -14,7 +14,7 @@ import type { WebSite } from '../WebSite'
import { PrimaryWebSiteId } from '../WebSite'
import type { Organization } from '../Organization'
import type { ImageObject } from '../Image'
import type { Breadcrumb } from '../Breadcrumb'
import type { BreadcrumbList } from '../Breadcrumb'
import type { VideoObject } from '../Video'
import { PrimaryBreadcrumbId } from '../Breadcrumb'
import { defineSchemaOrgResolver, resolveRelation } from '../../core'
Expand Down Expand Up @@ -75,7 +75,7 @@ export interface WebPageLite extends Thing {
/**
* A reference-by-ID to a node representing the page's breadrumb structure.
*/
breadcrumb?: NodeRelation<Breadcrumb>
breadcrumb?: NodeRelation<BreadcrumbList>
/**
* An array of all videos in the page content, referenced by ID.
*/
Expand Down Expand Up @@ -172,7 +172,7 @@ export const webPageResolver = defineSchemaOrgResolver<WebPage>({
setIfEmpty(webPage, 'isPartOf', idReference(webSite))

// it's possible that adding a new web page will revert the breadcrumb data
const breadcrumb = findNode<Breadcrumb>(PrimaryBreadcrumbId)
const breadcrumb = findNode<BreadcrumbList>(PrimaryBreadcrumbId)
if (breadcrumb)
setIfEmpty(webPage, 'breadcrumb', idReference(breadcrumb))

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/simple.ts → src/runtime/base.ts
@@ -1,7 +1,7 @@
import type {
AggregateOffer, AggregateRating,
Article,
Breadcrumb,
BreadcrumbList,
Comment,
Event,
HowTo,
Expand Down Expand Up @@ -57,7 +57,7 @@ export const defineAddress = <T extends PostalAddress>(input?: T) => provideReso
export const defineAggregateOffer = <T extends AggregateOffer>(input?: T) => provideResolver(input, aggregateOfferResolver as SchemaOrgNodeDefinition<T>)
export const defineAggregateRating = <T extends AggregateRating>(input?: T) => provideResolver(input, aggregateRatingResolver as SchemaOrgNodeDefinition<T>)
export const defineArticle = <T extends Article>(input?: T) => provideResolver(input, articleResolver as SchemaOrgNodeDefinition<T>)
export const defineBreadcrumb = <T extends Breadcrumb>(input?: T) => provideResolver(input, breadcrumbResolver as SchemaOrgNodeDefinition<T>)
export const defineBreadcrumb = <T extends BreadcrumbList>(input?: T) => provideResolver(input, breadcrumbResolver as SchemaOrgNodeDefinition<T>)
export const defineComment = <T extends Comment>(input?: T) => provideResolver(input, commentResolver as SchemaOrgNodeDefinition<T>)
export const defineEvent = <T extends Event>(input?: T) => provideResolver(input, eventResolver as SchemaOrgNodeDefinition<T>)
export const defineVirtualLocation = <T extends VirtualLocation>(input?: T) => provideResolver(input, virtualLocationResolver as SchemaOrgNodeDefinition<T>)
Expand Down

0 comments on commit 5bad91f

Please sign in to comment.