npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-tag-ogp-link-preview

v1.1.1

Published

A Hexo tag plugin for embedding link preview by OpenGraph on article.

Downloads

109

Readme

hexo-tag-ogp-link-preview

A Hexo tag plugin for embedding link preview by OpenGraph on article.

MIT License Lint and Test Maintainability Test Coverage

Installation

npm install hexo-tag-ogp-link-preview

Usage

Write like below to your hexo article markdown file:

{% link_preview url [target] [rel] [loading] %}
[Content]
{% endlink_preview %}

or you are able to use "Named Parameter":

{% link_preview url [rel:{rel_value}] [target:{target_value}] [loading:{loading_value}] %}
[Content]
{% endlink_preview %}

Tag arguments

Notice: All optionally parameters (except for the required url parameter) are able to use "Named Parameter".

| Name | Required? | Default | Description | |-----------|-----------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | url | Yes | | This parameter is a target of the link preview. | | target | No | _blank | Specify a target attribute of the anchor element.One of _self, _blank, _parent, or _top. | | rel | No | nofollow | Specify a rel attribute of the anchor element.One of external, nofollow, noopener, noreferrer, or opener. | | loading | No | lazy | Specify a loading attribute of the image element.One of lazy, eager, or none.If specify a none, remove loading attribute from image element. |

Tag content

content is fallback text which use when failed to get OpenGraph data from url.

Configuration

You write like below to hexo configuration file _config.yml:

link_preview:
  class_name:
    anchor_link: link-preview
    image: not-gallery-item
  description_length: 140
  disguise_crawler: true

Setting values

Notice: All setting values are NOT required.

| Name | type | Default | Description | |----------------------------|----------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | class_name | string or object | link-preview | If you are specified string, set a class attribute of the anchor element only.If you are specified object, set each a class attribute of the anchor element and the image element. | | class_name.anchor_link | string | link-preview | Set a class attribute of the anchor element. | | class_name.image | string | | Set a class attribute of the image element.If you are not specify (empty string, etc.), nothing to set. | | description_length | number | 140 | It sliced to fit if a number of character of the og:Description exceeds the specified number value. | | disguise_crawler | boolean | true | If scraper for OpenGraph want to disguise to crawler, set true.Otherwise, set to false. |

Example

Write a following to your hexo article markdown file:

{% link_preview http://www.example.com/ loading:lazy %}
fallback Text
{% endlink_preview %}

When scraper get OpenGraph successfully, generated html like blow:

<a href="http://www.example.com/" target="_blank" rel="nofollow" class="link-preview">
    <div class="og-image">
        <img src="https://www.example.com/image.png" alt="example image" class="not-gallery-item" loading="lazy">
    </div>
    <div class="descriptions">
        <div class="og-title">title text</div>
        <div class="og-description">description text</div>
    </div>
</a>

When scraper fail to get OpenGraph, generated html like blow:

<a href="http://www.example.com/">fallback Text</a>