hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Provide `item.uri` for Element links

Open proimage opened this issue 1 year ago • 4 comments

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

proimage avatar Jun 16 '24 14:06 proimage

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 avatar Jun 16 '24 22:06 engram-design

Updated in 1.2.0 and 2.0.3

engram-design avatar Jul 21 '24 05:07 engram-design

Could this also be added to the GraphQL interface?

stereomyth avatar Aug 14 '24 15:08 stereomyth

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

engram-design avatar Aug 14 '24 22:08 engram-design

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?

mathg avatar Sep 04 '24 17:09 mathg

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 avatar Sep 05 '24 11:09 engram-design

Added in 2.0.5

engram-design avatar Sep 07 '24 10:09 engram-design