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 🙏

© 2025 – Pkg Stats / Ryan Hefner

remark-link-card-plus

v0.7.2

Published

Remark plugin to convert text links to link cards

Readme

remark-link-card-plus

CI npm version

remark plugin to convert text links to link cards, building upon and improving remark-link-card.

You can see it in action on the demo page.

Features

remark-link-card-plus is a fork of the original remark-link-card with the following changes:

Differences from the original:

  • TypeScript support: Fully rewritten in TypeScript for improved type safety and developer experience.
  • Target blank: Links in link cards now open in a new tab using target="_blank".
  • No link cards in lists: Links inside list items (listItem) are not converted into link cards.
  • Thumbnail position customization: Select whether the thumbnail is displayed on the left or right of the card.
  • Optional image and favicon display: Added noThumbnail and noFavicon options to hide thumbnails and favicons from link cards.
  • OG data transformer: The ogTransformer option allows customization of Open Graph data such as the title, description, favicon, and image before rendering the link card.
  • Ignore by extension: The ignoreExtensions option allows you to skip link card conversion for URLs with specific file extensions (e.g., .mp4, .pdf).

Retained features:

  • Options support:
    • cache: Cache images for faster loading and local storage.
    • shortenUrl: Display only the hostname of URLs in link cards.
  • Customizable styling: Cards can be styled freely using provided class names (note that class names have been slightly updated).

Install

npm i remark-link-card-plus

Usage

Basic Example

import { remark } from "remark";
import remarkLinkCard from "remark-link-card-plus";

const exampleMarkdown = `
# Example Markdown

## Link Card Demo

Bare links like this:

https://github.com

will be converted into a link card.

Inline links like [GitHub](https://github.com) will **not** be converted.

Links to files like https://example.com/video.mp4 can be ignored using the `ignoreExtensions` option.
`;

(async () => {
  const result = await remark()
    .use(remarkLinkCard, { cache: true, shortenUrl: true, ignoreExtensions: ['.mp4', '.pdf'] })
    .process(exampleMarkdown);

  console.log(result.value);
})();

You can get converted result like this.

# Example Markdown

## Link Card Demo

Bare links like this:

<div class="remark-link-card-plus__container">
  <a href="https://github.com/" target="_blank" rel="noreferrer noopener" class="remark-link-card-plus__card">
    <div class="remark-link-card-plus__main">
      <div class="remark-link-card-plus__content">
        <div class="remark-link-card-plus__title">GitHub · Build and ship software on a single, collaborative platform</div>
        <div class="remark-link-card-plus__description">Join the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.</div>
      </div>
      <div class="remark-link-card-plus__meta">
        <img src="https://www.google.com/s2/favicons?domain=github.com" class="remark-link-card-plus__favicon" width="14" height="14" alt="">
        <span class="remark-link-card-plus__url">github.com</span>
      </div>
    </div>
    <div class="remark-link-card-plus__thumbnail">
      <img src="https://github.githubassets.com/assets/home24-5939032587c9.jpg" class="remark-link-card-plus__image" alt="">
    </div>
  </a>
</div>

will be converted into a link card.

Inline links like [GitHub](https://github.com) will **not** be converted.

Links to files like https://example.com/video.mp4 can be ignored using the `ignoreExtensions` option.

Astro Example

You can also use remark-link-card-plus in an Astro project. Below is an example astro.config.mjs configuration:

// astro.config.mjs
import { defineConfig } from 'astro/config';
import remarkLinkCard from 'remark-link-card-plus';

export default defineConfig({
  markdown: {
    remarkPlugins: [
      [
        remarkLinkCard, {
          cache: true,
          shortenUrl: true,
          thumbnailPosition: "right",
          noThumbnail: false,
          noFavicon: false,
          ignoreExtensions: ['.mp4', '.pdf'],
          ogTransformer: (og, url) => {
            if (url.hostname === 'github.com') {
              return { ...og, title: `GitHub: ${og.title}` };
            }
            if (og.title === og.description) {
              return { ...og, description: 'custom description' };
            }
            return og;
          }
        },
      ],
    ],
  },
});

// Here is minimal setup.
export default defineConfig({
  markdown: {
    remarkPlugins: [remarkLinkCard],
  },
});

Options

| Option | Type | Default | Description | |--------------|---------|---------|-----------------------------------------------------------------------------| | cache | boolean | false | Caches Open Graph images and favicons locally. Images are saved to process.cwd()/public/remark-link-card-plus/ and paths start with /remark-link-card-plus/. This reduces server load on the linked site and improves build performance by avoiding redundant network requests. | | shortenUrl | boolean | true | Displays only the hostname of the URL in the link card instead of the full URL. | | thumbnailPosition | string | right | Specifies the position of the thumbnail in the card. Accepts "left" or "right". | | noThumbnail | boolean | false | If true, does not display the Open Graph thumbnail image. The generated link card HTML will not contain an <img> tag for the thumbnail. | | noFavicon | boolean | false | If true, does not display the favicon in the link card. The generated link card HTML will not contain an <img> tag for the favicon. | | ogTransformer | (og: OgData, url: URL) => OgData | undefined | A callback to transform the Open Graph data before rendering. The function receives the original OG data and the URL being processed. OgData has the structure { title: string; description: string; faviconUrl?: string; imageUrl?: string }. | | ignoreExtensions | string[] | [] | Skips link card conversion for URLs with the specified file extensions (e.g., ['.mp4', '.pdf']). The original Markdown is left unchanged for these links. Matching is case-insensitive and only exact extension matches are ignored. |

Styling

Link cards can be styled using the following class names:

.remark-link-card-plus__container {}

.remark-link-card-plus__card {}

.remark-link-card-plus__main {}

.remark-link-card-plus__content {}

.remark-link-card-plus__title {}

.remark-link-card-plus__description {}

.remark-link-card-plus__meta {}

.remark-link-card-plus__favicon {}

.remark-link-card-plus__url {}

.remark-link-card-plus__thumbnail {}

.remark-link-card-plus__image {}

Feel free to customize these styles as needed.