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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vitepress-plugin-product-card

v0.1.0

Published

VitePress plugin: markdown ::: card container + Vue product card component with GitHub time badges

Readme

vitepress-plugin-product-card

在 VitePress 站点里通过 ::: card markdown 容器语法快速渲染「产品/项目/作品」卡片,卡片可自动拉取 GitHub 仓库的创建时间与最后更新时间,并支持全局与单卡两级覆盖。

安装

pnpm add vitepress-plugin-product-card

使用

1. 注册 markdown 容器插件

.vitepress/config.ts

最简引入:

import { defineConfig } from 'vitepress'
import { productCardMarkdownPlugin } from 'vitepress-plugin-product-card'

export default defineConfig({
  markdown: {
    config(md) {
      md.use(productCardMarkdownPlugin)
    }
  }
})

带可选参数:

import { defineConfig } from 'vitepress'
import { productCardMarkdownPlugin } from 'vitepress-plugin-product-card'

export default defineConfig({
  markdown: {
    config(md) {
      md.use(productCardMarkdownPlugin, {
        // 可选:全局默认开关
        showCreated: true,
        showUpdated: true,
        // 可选:自定义组件名(默认 ProductCard)
        componentName: 'ProductCard'
      })
    }
  }
})

2. 注册 Vue 组件

.vitepress/theme/index.ts

import DefaultTheme from 'vitepress/theme'
import { registerProductCard } from 'vitepress-plugin-product-card/client'

export default {
  extends: DefaultTheme,
  enhanceApp({ app }) {
    registerProductCard(app)
    // 或自定义组件名:registerProductCard(app, 'MyCards')
  }
}

3. 在 markdown 中使用

::: card 我的产品
- title: sugar-blog
  desc: 简约风的 VitePress 博客主题
  icon: 📝
  iconColor: '#42b883'
  link: https://theme.sugarat.top
  github: https://github.com/ATQQ/sugar-blog
  tags: [VitePress, Vue3, TypeScript]
----
- title: 关闭时间展示的卡片
  desc: 单卡覆盖全局默认
  github: https://github.com/some/repo
  showCreated: false
  showUpdated: false
:::

字段说明

| 字段 | 类型 | 说明 | |---|---|---| | title | string | 卡片标题(必填) | | desc | string | 卡片描述,支持行内 markdown | | icon | string | 图标:URL / 相对路径 → 渲染 <img>;否则渲染为字符 | | iconColor | string | 字符 icon 的背景色(CSS 变量或 hex) | | link | string | 点击标题跳转的地址 | | github | string | GitHub 仓库地址,自动拉取创建/更新时间 | | tags | string[] | 标签数组(可用 ["a", "b"]a 单值) | | showCreated | boolean | 覆盖全局默认,是否展示创建时间 | | showUpdated | boolean | 覆盖全局默认,是否展示最后更新时间 |

多张卡片之间使用 ---- 分隔。开头的 - title: 表示新卡片起始。

插件参数

interface CardContainerDefaults {
  /** 是否展示 GitHub 仓库创建时间,默认 true */
  showCreated?: boolean
  /** 是否展示 GitHub 仓库最后更新时间,默认 true */
  showUpdated?: boolean
  /** 输出 html_block 使用的组件名,默认 ProductCard */
  componentName?: string
}

GitHub 图标行为

  • 已展示时间行:GitHub 图标前置在时间行左侧,时间行整体作为链接跳转 GitHub 仓库;
  • 未展示时间行(如 showCreated: falseshowUpdated: false,或 API 拉取失败):在标签行首自动追加一枚 GitHub 标签,点击跳转仓库。

关于 GitHub API 限流

组件通过匿名 fetch 访问 https://api.github.com/repos/{owner}/{repo},未鉴权时限流约 60 次/小时。超限时静默失败,卡片仍然渲染,只是不显示时间信息。

Peer Dependencies

  • vitepress: ^1.0.0-0 || ^2.0.0-0
  • vue: ^3.3.0

License

MIT