diff --git a/packages/svead/src/lib/components/head.svelte b/packages/svead/src/lib/components/head.svelte index 8ca157dc..2d94d88f 100644 --- a/packages/svead/src/lib/components/head.svelte +++ b/packages/svead/src/lib/components/head.svelte @@ -1,7 +1,7 @@ - - {@html jsonLdScript} - + + {@html JSON.stringify(jsonLd)} + diff --git a/packages/svead/src/lib/types.ts b/packages/svead/src/lib/types.ts index ce3351a4..780524e9 100644 --- a/packages/svead/src/lib/types.ts +++ b/packages/svead/src/lib/types.ts @@ -13,19 +13,52 @@ interface CommonEntity { } export interface AuthorEntity { - type: AuthorType; + '@type': AuthorType; + type?: AuthorType; name: string; url: string; } export interface PublisherEntity { - type: 'Organization'; + '@type': 'Organization'; name: string; logo: string; + url?: string; +} + +export interface BreadcrumbItem { + name: string; + url: string; } export interface MainEntity extends CommonEntity { type: MainEntityType; author: AuthorEntity; publisher: PublisherEntity; + breadcrumb?: { + '@type': 'BreadcrumbList'; + itemListElement: { + '@type': 'ListItem'; + position: number; + item: BreadcrumbItem; + }[]; + }; +} + +export interface JsonLdMainEntity extends MainEntity { + '@context': string; + '@type': MainEntityType; + inLanguage?: string; + breadcrumb?: { + '@type': 'BreadcrumbList'; + itemListElement: { + '@type': 'ListItem'; + position: number; + item: BreadcrumbItem; + }[]; + }; + mainEntityOfPage?: { + '@type': string; + '@id': string; + }; } diff --git a/packages/svead/vitest.config.ts b/packages/svead/vitest.config.ts new file mode 100644 index 00000000..2c551199 --- /dev/null +++ b/packages/svead/vitest.config.ts @@ -0,0 +1,22 @@ +import { defineConfig, mergeConfig } from 'vitest/config'; +import viteConfig from './vite.config'; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ['src/**/*.test.{js,ts,svelte}'], + globals: true, + environment: 'jsdom', + coverage: { + all: false, + thresholds: { + statements: 75, + branches: 84, + functions: 68, + lines: 75, + }, + }, + }, + }), +);