Comments (7)
Hey,
Sorry for the vague documentation. We are creating a new fresh documentation site.
About your problem, actually you need to do two steps:
- Link the microlink JavaScript script in your index.html before close body tag:
<script type="text/javascript" src="//unpkg.com/microlinkjs@latest/umd/microlink.min.js"></script>
This will add window.microlink
as a global object. Check if it exists!
- After this script, declare a script specifing what HTML tags you want to see as microlink cards:
<script>
// Replace links after DOMContentLoaded
document.addEventListener('DOMContentLoaded', function (event) {
microlink('a', { round: true })
})
</script>
from sdk.
Ok, the microlink JavaScript script can not be in the HEAD. Works fine inside the BODY.
Coming to the next problem, now ALL links have preview. I use Wordpress, so all HOME, MENU, THEME links are with 'preview'. Is there a way to just use preview on specific links?
from sdk.
You need to use a specific selector for that.
If you use a
selector, like
microlink('a', { round: true })
yeah, all links will be showed as card.
The approach for just select a set of selector is use a specific class name:
microlink('.link-preview', { round: true })
Then, add link-preview
class into your a
elements to show them as cards.
PS: Please, continue commenting. I need to debug the user board process and all of this feedback help us build better documentation site 🙏
from sdk.
Also on a sidenote @4044ever, we're working on a WP integration. So essentially you'd be able to include Microlink easily, and convert links to cards with simple [shortcodes /]
.
from sdk.
Here is what I tried now, and looks like it works perfectly:
<script type="text/javascript" src="//unpkg.com/microlinkjs@latest/umd/microlink.min.js"></script>
<script>
// Replace links after DOMContentLoaded
document.addEventListener('DOMContentLoaded', function (event) {
microlink('.mcl', { round: true })
})
</script>
<a class="mcl" href='https://nike.com'>NIKE</a>
Thanks for your help!
I saw the work on WP, but have to admit I found this method here beautifully liteweight.
Last (OT) question: What happens when the free link limit is exhausted? Just normal links are shown? Or some sort of error?
from sdk.
If you exceeded the daily quota, simply the links looks all time loading; also the dev tools console will be output an error saying you need to upgrade
from sdk.
new documentation site is live at http://docs.microlink.io 🎉
from sdk.
Related Issues (20)
- Ensure Microsoft Edge compatibility
- microlink.io is down? HOT 1
- Separate `fetch` from `setData`
- Make embeds clickable while loading HOT 1
- [vue] Can't perform a React state update on an unmounted component HOT 1
- [hover-react] testing snapshot fails
- A better way to customize basic style
- Add a way to pass iframe options HOT 2
- Links to documentation and storybook don't work
- Storybook link down HOT 1
- Styling of card loader HOT 8
- it fails for some websites that need to accept cookies HOT 5
- Microlink Hover improvements
- Is using raw `video` urls / mp4's legal in the preview? HOT 2
- apikey being passed to the Iframe wrapper component HOT 2
- Crashed with invalid link HOT 4
- Cors on any link HOT 1
- Running React v17 won't compile - @microlink/react gives an error about needing an additional loader in (MicrolinkError) HOT 2
- Upgrade microlink react SDK Styled-Component Package HOT 1
- FYI this isn't working very well with youtube at the moment HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.