hexo-tag-link-preview
Embed a link preview on your Hexo article.
Installation
npm install hexo-tag-link-preview
or
yarn add hexo-tag-link-preview
Usage
{% linkPreview url target rel %}
Example:
{% linkPreview https://www.amazon.com/ _blank nofollow %}
it generates HTML:
<a href="https://www.amazon.com" class="link-preview" target="_blank" rel="nofollow">
<div class="link-area">
<div class="og-image">
<img src="http://g-ec2.images-amazon.com/images/G/01/social/api-share/amazon_logo_500500._V323939215_.png">
</div>
<div class="descriptions">
<div class="og-title">Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more</div>
<div class="og-description">Online shopping from the earth's biggest selection of books, magazines, music, DVDs, videos, electronics, computers, software, apparel & accessories, shoes, jewelry, tools & hardware, housewares, furniture, sporting goods, beauty & personal care, broadband & dsl, gourmet food & just about anything else.</div>
</div>
</div>
</a>
Explantion of attributes
- url - An URL for the link. Required.
- target attribute - if you need to open link with another window, you must set here "_blank".
- rel attribute - if you need to link with rel="nofollow", set here "nofollow".
Target attribute and rel attribute can be abbreviated. But if only target attribute abbreviated, will not work correctly.
If you need to open same window and set rel="nofollow", please write down like below.
Example:
{% linkPreview https://www.amazon.com/ _self nofollow %}
Output:
<a href="https://www.amazon.com" class="link-preview" target="_self" rel="nofollow">
See also
Options
className
You can provide top-level class name of this preview link HTML.
(Default: link-preview
)
descriptionLength
You can provide number of character in og-description.
(Default: 140
)
Example
_config.yml:
linkPreview:
className: sample
descriptionLength: 6
it generates:
<a href="https://www.amazon.com" class="sample">
<div class="link-area">
<div class="og-image">
<img src="http://g-ec2.images-amazon.com/images/G/01/social/api-share/amazon_logo_500500._V323939215_.png">
</div>
<div class="descriptions">
<div class="og-title">Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more</div>
<div class="og-description">Online</div>
</div>
</div>
</a>
License
MIT