sebastian-lenz / craft-linkfield

Link field for Craft 3
MIT License
122 stars 66 forks source link

Add URI link format for GraphQL #196

Closed ajoliveau closed 2 years ago

ajoliveau commented 2 years ago

I'll reopen #123 !

I'm working on a Nuxt website and the built-in component needs a uri for internal links.

But unlike saltymouse in #123 my website is multisite, so fetching the element.slug doesn't give me all the information because all my urls have the language at the root, like https://www.example.com/fr/contact and https://www.example.com/en/contact. element.slug gives me contact in both cases where what I would love is /fr/contact.

The best way to do it would be to return a uri graphql field that is like url with the current site domain removed.

I did a proof-of-concept of a new uri field that returns parse_url($this->getUrl(), PHP_URL_PATH) so I can try a PR if that's something you want to implement !