From 61e8eca394084a54c1bbe5473638526097d11eda Mon Sep 17 00:00:00 2001 From: Manuel Odelain Date: Tue, 11 Jun 2024 09:59:30 +0200 Subject: [PATCH] fix: Roadiz entity utils regression --- utils/roadiz/app-entity.ts | 25 ------------------------- utils/roadiz/entity.ts | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 25 deletions(-) delete mode 100644 utils/roadiz/app-entity.ts diff --git a/utils/roadiz/app-entity.ts b/utils/roadiz/app-entity.ts deleted file mode 100644 index 14e7081..0000000 --- a/utils/roadiz/app-entity.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { JsonLdObject } from '@roadiz/types' -import { isEntityType } from '~/utils/roadiz/entity' - -// TYPE GUARD -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') -} diff --git a/utils/roadiz/entity.ts b/utils/roadiz/entity.ts index b4da71f..8ff2a80 100644 --- a/utils/roadiz/entity.ts +++ b/utils/roadiz/entity.ts @@ -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') +}