-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
This makes no sense when used directly in the template, like:
<Link @external="https://example.com" as |l|>
<a href={{l.url}} {{on "click" l.transitionTo}}>
Example
</a>
</Link>However, it becomes very useful when passing Links around, e.g. to build a navigation menu, because you can then easily use the same primitive in a common code path:
<NavigationMenu
@navItems={{array
(hash label="Top Sellers" link=(link "top"))
(hash label="Categories" link=(link "categories"))
(hash label="Shopping Cart" link=(link "cart"))
(hash label="Legal" link=(external-link "/legal"))
}}
/>{{#each @navItems as |item|}}
<a href={{item.link.url}} {{on "click" l.transitionTo}}>
{{item.label}}
</a>
{{/each}}I'm not sure about the exact API yet.
Another thing: Usually you'll want external links to open in a new tab. This should not need to be defined at the "call site" where the Link is used on an <a> element, but rather where the Link is defined.
Something like this maybe? #289
<NavigationMenu
@navItems={{array
(hash label="Top Sellers" link=(link "top"))
(hash label="Categories" link=(link "categories"))
(hash label="Shopping Cart" link=(link "cart"))
(hash label="Legal" link=(external-link "/legal" newTab=true))
}}
/>Metadata
Metadata
Assignees
Labels
No labels