-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for global api
attribute fallback
#3
Comments
This is a great point @fimion, and something that really bothered me during the development process. I think ideally I would've set up my own API endpoint using cloud functions to provide people with a nice default, however I don't quite have enough experience plus I'd be worried it would get hit so much I'd get hit with a big bill 😅. Not sure I like the idea of the meta tag, it's a good one but I don't like polluting the HTML anymore than I already am. I'd probably prefer people use something like the following to apply the same API to all instances: document.querySelectorAll("link-peek").forEach(peek => peek.setAttribute("api", "https://api.microlink.io/?url=${link}")); Threw a demo together to show it working: https://codepen.io/daviddarnes/pen/yLrZgmv?editors=1011 |
Is your feature request related to a problem? Please describe.
With the current implementation, a user is required to provide an
api
attribute on each instance oflink-peek
. If someone needed to change the api call to be a different endpoint across an entire site, this would be a rather labor intensive process to do a search and replace.Describe the solution you'd like
Add the ability to have a
<meta name="link-peek-api" content="https://example.com/?${link}" />
tag defined in the head to specify a fallback value if noapi
attribute was specified. This will allow eachlink-peek
instance to still call a separate api if needed, but we can also have a fallback defined globally.Describe alternatives you've considered
An alternative to this would be a static attribute on the
LinkPeek
class that could be used in the same way. However, the class is not currently exported, and so this would not be usable in a module based import.The text was updated successfully, but these errors were encountered: