Linky is a jQuery plugin for linkifying URLs, mentions (for Twitter, Instagram or GitHub) and hashtags (for Twitter); that is, taking plain text references of URLs, mentions and hashtags and turning them to the appropriate links. Existing linkified URLs are kept untouched.
1. INCLUDE JS FILES
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.linky.js"></script>
2. HTML
<div class="url">
https://github.com/AnSavvides should turn into a link, while <a href="https://twitter.com/andreassavvides">this link should stay untouched</a>.
</div>
<div class="twitter-mentions">
@andreassavvides should get highlighted! Not an e-mail such as hello@example.com though.
</div>
<div class="instagram-mentions">
We do instagram too! Check out @instagram!
</div>
<div class="hashtags">
Need hashtags linkified? Don't worry - #wegotyoucovered!
</div>
<div class="github-mentions">
You can find @AnSavvides on GitHub!
</div>
3. JAVASCRIPT
$(".url").linky();
$(".twitter-mentions").linky(
mentions: true,
urls: false,
linkTo: "twitter"
);
$(".instagram-mentions").linky(
mentions: true,
urls: false,
linkTo: "instagram"
);
$(".hashtags").linky(
hashtags: true,
urls: false,
linkTo: "twitter"
);
$(".github-mentions").linky(
mentions: true,
linkTo: "github"
);
Linky - Linkify URLs, mentions & hashtags
No comments:
Post a Comment