diff --git a/packages/schema-org/src/plugin.ts b/packages/schema-org/src/plugin.ts index c41a7d77..486859d9 100644 --- a/packages/schema-org/src/plugin.ts +++ b/packages/schema-org/src/plugin.ts @@ -56,10 +56,13 @@ export function SchemaOrgUnheadPlugin(config: MetaInput, meta: () => Record(input: UseScriptInput, _options?: UseScriptOptions< function maybeHintEarlyConnection(rel: 'preconnect' | 'dns-prefetch') { if ( // opt-out - options.skipEarlyConnections || + options.skipEarlyConnections // must be a valid absolute url - !input.src.includes('//') || + || !input.src.includes('//') // must be server-side - !head!.ssr + || !head!.ssr ) return const key = `use-script.${id}.early-connection` head!.push({ - link: [{ key, rel, href: new URL(input.src).origin }] + link: [{ key, rel, href: new URL(input.src).origin }], }, { mode: 'server' }) } @@ -115,9 +115,9 @@ export function useScript(input: UseScriptInput, _options?: UseScriptOptions< const isIdle = trigger === 'idle' if (isIdle) { // we don't need idle trigger for server - if (head.ssr) { + if (head.ssr) trigger = 'manual' - } else + else // won't work in a SSR environment trigger = new Promise(resolve => requestIdleCallback(() => resolve())) } diff --git a/test/schema.org/e2e/basic.test.ts b/test/schema.org/e2e/basic.test.ts index 86bb2c0d..5f6ab39e 100644 --- a/test/schema.org/e2e/basic.test.ts +++ b/test/schema.org/e2e/basic.test.ts @@ -258,7 +258,7 @@ describe('schema.org e2e', () => { useHead({ link: [ { rel: 'canonical', href: `%siteUrl/some-path` }, - ] + ], }) useSchemaOrg([