Code Monkey home page Code Monkey logo

Comments (7)

Kikobeats avatar Kikobeats commented on July 20, 2024

Hey,

Sorry for the vague documentation. We are creating a new fresh documentation site.

About your problem, actually you need to do two steps:

  1. 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!

  1. 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.

4044ever avatar 4044ever commented on July 20, 2024

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.

Kikobeats avatar Kikobeats commented on July 20, 2024

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.

breadadams avatar breadadams commented on July 20, 2024

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.

4044ever avatar 4044ever commented on July 20, 2024

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.

Kikobeats avatar Kikobeats commented on July 20, 2024

@4044ever

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.

Kikobeats avatar Kikobeats commented on July 20, 2024

new documentation site is live at http://docs.microlink.io 🎉

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.