verbb / hyper

A Craft CMS plugin for managing links, focusing on user experience.
Other
24 stars 15 forks source link

Provide `item.uri` for Element links #171

Closed proimage closed 2 months ago

proimage commented 5 months ago

What are you trying to do?

Sometimes, I need to get the URI of an entry, i.e. the URL minus the siteUrl variable: URL: https://www.example.com/path/to/my-entry URI: /path/to/my-entry

This is useful when sharing a local DDEV site via ddev share; the site gets served at something like a https://[mini-UID].ngrok-free.app domain. When URLs on the site have https://my-site.ddev.site prepended to them, then no links will work on the NGROK domain.

What's your proposed solution?

Along with the existing variables for links, provide a uri variable, which will not include the site domain, only a root-relative (/something) path.

Additional context

No response

engram-design commented 5 months ago

We can't use uri because that's being used by the Element class that Links inherit from, but linkUri is an option.

Added for the next release. To get this early, run composer require verbb/hyper:"dev-craft-4 as 1.1.32" or composer require verbb/hyper:"dev-craft-5 as 2.0.2".

engram-design commented 4 months ago

Updated in 1.2.0 and 2.0.3

stereomyth commented 3 months ago

Could this also be added to the GraphQL interface?

engram-design commented 3 months ago

Added for the next release. To get this early, run composer require verbb/formie:"dev-craft-4 as 2.0.4".

mathg commented 2 months ago

It looks like it's been added to GQL in the 2.0.4 release, but for some reason it's not there when I install that version with composer. Do I need something else?

engram-design commented 2 months ago

This hasn't been tagged in a release yet, it's still on the dev-craft-4 and dev-craft-5 branches, which is the reason for the above command to alias those branches as the latest tagged version available. It doesn't mean this feature is on 2.0.4.

For reference:

{
  entries(id: 1234) {
    ... on myEntryType_Entry {
      hyperField {
        linkUri
      }
    }
  }
}
engram-design commented 2 months ago

Added in 2.0.5