Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Oct 29, 2023
1 parent 7eba87f commit 8140b7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions packages/schema-org/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ export function SchemaOrgUnheadPlugin(config: MetaInput, meta: () => Record<stri
else if (tag.tag === 'link' && tag.props.rel === 'canonical') {
resolvedMeta.url = tag.props.href
if (resolvedMeta.url && !resolvedMeta.host)
// may be using template params that aren't resolved
// may be using template params that aren't resolved
{
try {
resolvedMeta.host = new URL(resolvedMeta.url).origin
} catch {}
}
catch {}
}
}
else if (tag.tag === 'meta' && tag.props.property === 'og:image') { resolvedMeta.image = tag.props.content }
// use template params
Expand Down
12 changes: 6 additions & 6 deletions packages/unhead/src/composables/useScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export function useScript<T>(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' })
}

Expand Down Expand Up @@ -115,9 +115,9 @@ export function useScript<T>(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<void>(resolve => requestIdleCallback(() => resolve()))
}
Expand Down
2 changes: 1 addition & 1 deletion test/schema.org/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe('schema.org e2e', () => {
useHead({
link: [
{ rel: 'canonical', href: `%siteUrl/some-path` },
]
],
})

useSchemaOrg([
Expand Down

0 comments on commit 8140b7b

Please sign in to comment.