diff --git a/packages/schema-org/src/core/util.ts b/packages/schema-org/src/core/util.ts index 51d5497e..37ba0da9 100644 --- a/packages/schema-org/src/core/util.ts +++ b/packages/schema-org/src/core/util.ts @@ -41,7 +41,7 @@ export function dedupeNodes(nodes: SchemaOrgNode[]) { for (const key of nodes.keys()) { const n = nodes[key] const nodeKey = resolveAsGraphKey(n['@id'] || hash(n)) as Id - if (dedupedNodes[nodeKey]) + if (dedupedNodes[nodeKey] && n._dedupeStrategy !== 'replace') dedupedNodes[nodeKey] = merge(nodes[key], dedupedNodes[nodeKey]) as SchemaOrgNode else dedupedNodes[nodeKey] = nodes[key] diff --git a/packages/schema-org/src/plugin.ts b/packages/schema-org/src/plugin.ts index 90e7fee3..e11e162a 100644 --- a/packages/schema-org/src/plugin.ts +++ b/packages/schema-org/src/plugin.ts @@ -44,6 +44,7 @@ export function SchemaOrgUnheadPlugin(config: MetaInput, meta: () => Partial>(input?: BookEdi export type UseSchemaOrgInput = Arrayable> -export function useSchemaOrg(input: UseSchemaOrgInput) { +export function useSchemaOrg(input: UseSchemaOrgInput, options?: Pick) { // lazy initialise the plugin const head = getActiveHead() if (!head) @@ -173,5 +174,5 @@ export function useSchemaOrg(input: UseSchemaOrgInput) { nodes: input, }, ], - }) + }, options) } diff --git a/packages/schema-org/src/types.ts b/packages/schema-org/src/types.ts index 10ec78c7..ebc0c2c3 100644 --- a/packages/schema-org/src/types.ts +++ b/packages/schema-org/src/types.ts @@ -112,6 +112,7 @@ export interface Thing { export interface SchemaOrgNode extends Thing { _resolver?: SchemaOrgNodeDefinition + _dedupeStrategy?: 'replace' | 'merge' } export type WithResolver = T & { diff --git a/packages/schema/src/head.ts b/packages/schema/src/head.ts index 4b148234..01121362 100644 --- a/packages/schema/src/head.ts +++ b/packages/schema/src/head.ts @@ -1,7 +1,7 @@ import type { Hookable, NestedHooks } from 'hookable' import type { HeadHooks } from './hooks' import type { Head } from './schema' -import type { HeadTag, ProcessesTemplateParams, TagPosition, TagPriority, TemplateParams } from './tags' +import type { HeadTag, ProcessesTemplateParams, ResolvesDuplicates, TagPosition, TagPriority, TemplateParams } from './tags' /** * Side effects are mapped with a key and their cleanup function. @@ -83,7 +83,7 @@ export interface CreateHeadOptions { hooks?: NestedHooks } -export interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams { +export interface HeadEntryOptions extends TagPosition, TagPriority, ProcessesTemplateParams, ResolvesDuplicates { mode?: RuntimeMode transform?: (input: unknown) => unknown head?: Unhead diff --git a/packages/unhead/src/plugins/dedupe.ts b/packages/unhead/src/plugins/dedupe.ts index 26d5a672..2c8df8b3 100644 --- a/packages/unhead/src/plugins/dedupe.ts +++ b/packages/unhead/src/plugins/dedupe.ts @@ -1,4 +1,4 @@ -import {defineHeadPlugin, HasElementTags, hashTag, tagDedupeKey, tagWeight} from '@unhead/shared' +import { defineHeadPlugin, HasElementTags, hashTag, tagDedupeKey, tagWeight } from '@unhead/shared' import type { HeadTag } from '@unhead/schema' const UsesMergeStrategy = new Set(['templateParams', 'htmlAttrs', 'bodyAttrs'])