Skip to content

Commit

Permalink
fix: Roadiz entity utils regression
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelodelain committed Jun 11, 2024
1 parent 40e983f commit 61e8eca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
25 changes: 0 additions & 25 deletions utils/roadiz/app-entity.ts

This file was deleted.

22 changes: 22 additions & 0 deletions utils/roadiz/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,25 @@ export function isSchemaOrgType(entity: JsonLdObject, type: string): boolean {
const matches = entity['@type']?.match(regex)
return matches !== null && matches.length > 0
}

export function isNodeType(entity: unknown): entity is JsonLdObject {
return !!(entity && typeof entity === 'object' && '@id' in entity && '@type' in entity)
}

// NODE SOURCE
export function isPageEntity(entity: JsonLdObject): boolean {
return isEntityType(entity, 'Page')
}

export function isBlogPostEntity(entity: JsonLdObject): boolean {
return isEntityType(entity, 'BlogPost')
}

export function isBlogListingEntity(entity: JsonLdObject): boolean {
return isEntityType(entity, 'BlogPostContainer')
}

// BLOCKS
export function isContentBlock(entity: JsonLdObject): boolean {
return isEntityType(entity, 'ContentBlock')
}

0 comments on commit 61e8eca

Please sign in to comment.