harlan-zw / nuxt-site-config

Unifying site config with powerful and flexible APIs, for module authors and users.
https://nuxtseo.com/site-config
MIT License
65 stars 6 forks source link

Site-Link props type #17

Closed damienroche closed 10 months ago

damienroche commented 10 months ago

Describe the bug

To be fully iso with Nuxt-Link, this prop should accept undefined value https://github.com/harlan-zw/nuxt-site-config/blob/6c312d3042c5cf5644a59d37ad6679e21faf4573/packages/module/src/runtime/nuxt/component/SiteLink.vue#L7

with Nuxt-Link :

Capture d’écran 2024-01-19 à 14 48 52

with Site-Link :

Capture d’écran 2024-01-19 à 14 48 42

Reproduction

No response

System / Nuxt Info

No response

harlan-zw commented 10 months ago

Thanks! Have pushed a fix for this, now we explicitly extend the NuxtLinkProps interface to avoid issues like this

baikov commented 10 months ago

Thanks! Have pushed a fix for this, now we explicitly extend the NuxtLinkProps interface to avoid issues like this

Getting error in typecheck after this fix:

Screenshot 2024-01-21 at 20 26 29

On 2.2.5 all ok )

damienroche commented 10 months ago

@harlan-zw thanks for the update. Maybe you have to be aware that to should can also be a RouteLocation object and in this case the path is located in the path object key.

<Site-Link :to="{ path: ... }" />
import { RouteLocation } from 'vue-router

const to = computed(() => {
  const _to = props.to as string | undefined | RouteLocation
  if (!_to || !_to?.path)
    return undefined
  return linkResolver(typeof _to === 'string' ? _to : _to.path)
})
harlan-zw commented 10 months ago

Thank you, sorry for the oversight. I've merged @damienroche's PR and released in 2.2.8

As a side note, please see https://github.com/harlan-zw/nuxt-site-config/issues/19