Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
fix(Offer): avoid setting url if none provided
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Aug 19, 2022
1 parent cb87bce commit 77a7860
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/nodes/Offer/index.ts
@@ -1,7 +1,7 @@
import { withBase } from 'ufo'
import type { OptionalSchemaOrgPrefix, ResolvableDate, Thing } from '../../types'
import {
resolvableDateToIso, setIfEmpty,
resolvableDateToIso, resolveWithBase, setIfEmpty,
} from '../../utils'
import { defineSchemaOrgResolver } from '../../core'

Expand Down Expand Up @@ -61,7 +61,8 @@ export const offerResolver = defineSchemaOrgResolver<Offer>({
resolve(node, ctx) {
setIfEmpty(node, 'priceCurrency', ctx.meta.currency)
setIfEmpty(node, 'priceValidUntil', new Date(Date.UTC(new Date().getFullYear() + 1, 12, -1, 0, 0, 0)))
setIfEmpty(node, 'url', ctx.meta.url)
if (node.url)
resolveWithBase(ctx.meta.host, node.url)

if (node.availability)
node.availability = withBase(node.availability, 'https://schema.org/') as ItemAvailability
Expand Down

0 comments on commit 77a7860

Please sign in to comment.