惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Blog — PlanetScale
Blog — PlanetScale
B
Blog
GbyAI
GbyAI
爱范儿
爱范儿
月光博客
月光博客
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
腾讯CDC
MyScale Blog
MyScale Blog
V
Visual Studio Blog
The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

粥里有勺糖

AI记账小程序上线 | 粥里有勺糖 视野修炼第132期 | 一些有趣的组件 | 粥里有勺糖 视野修炼第131期 | bun 与 pnpm Rust 化 视野修炼第130期 | 光影效果 | 粥里有勺糖 分享一下最近做的AI记账 App | 粥里有勺糖 Harness 学习笔记分享(Part 1) | 粥里有勺糖 润了 | 粥里有勺糖 分享一下最近 VibeCoding 的项目部署工具:Kite | 粥里有勺糖 个人作品 | 粥里有勺糖 分享一下笔者的 Mac 装机必备软件 | 粥里有勺糖 🚀 VitePress 插件开发计划 | 粥里有勺糖 视野修炼第129期 | 上一次古法编程是什么时候 | 粥里有勺糖 🧧 红包封面来了 | 粥里有勺糖 2025年度总结 | 粥里有勺糖 心得总结 | 粥里有勺糖 开发一个美观的 VitePress 图片预览插件 | 粥里有勺糖 心外“天花板”手术经历 | 粥里有勺糖 又双叒住院了 | 粥里有勺糖 视野修炼第128期 | Bun 被收购 | 粥里有勺糖 视野修炼第127期 | Valdi | 粥里有勺糖 视野修炼第126期 | TypeScript #1 | 粥里有勺糖 离开上海回家啦 | 粥里有勺糖 第三次到上海 | 粥里有勺糖 视野修炼第125期 | nano-banana | 粥里有勺糖 又生病住院了 | 粥里有勺糖 视野修炼第124期 | 终端艺术字 | 粥里有勺糖 视野修炼第123期 | 你在用Node几? | 粥里有勺糖 视野修炼第122期 | 发光图片制作 | 粥里有勺糖 用Trae做了个公众号小工具 | 粥里有勺糖 视野修炼第121期 | Rolldown-Vite | 粥里有勺糖
VitePress 产品卡片展示插件介绍 | 粥里有勺糖
粥里有勺糖 · 2026-07-29 · via 粥里有勺糖

笔者维护的 VitePress 博客主题 中包含一个「作品/产品卡片」的能力,可以在 markdown 里通过简单的 ::: card 容器语法快速展示项目。为便于在主题之外复用,将其抽离为独立插件 vitepress-plugin-product-card

如何使用 ​

3 步接入:

  1. 安装

bash

pnpm add vitepress-plugin-product-card
  1. .vitepress/config.ts 中注册 markdown 容器插件

ts

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

export default defineConfig({
  markdown: {
    config(md) {
      md.use(productCardMarkdownPlugin, {
        showCreated: true, // 默认 true
        showUpdated: true // 默认 true
      })
    }
  }
})
  1. .vitepress/theme/index.ts 中注册 Vue 组件

ts

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

export default {
  extends: DefaultTheme,
  enhanceApp({ app }) {
    registerProductCard(app)
  }
}

在 Markdown 中使用 ​

md

::: 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
:::
  • 顶部标题(::: card 我的产品)可选,不写则不渲染分组标题
  • 多张卡片之间使用 ---- 分隔
  • 每张卡片以 - title: xxx 开头

支持的字段 ​

字段类型说明
titlestring卡片标题(必填)
descstring卡片描述,支持行内 markdown
iconstring图标:URL / 相对路径 → 渲染 <img>;否则渲染为字符
iconColorstring字符 icon 的背景色
linkstring点击标题跳转的地址
githubstringGitHub 仓库地址,自动拉取创建/更新时间
tagsstring[]标签数组
showCreatedboolean覆盖全局,是否展示创建时间
showUpdatedboolean覆盖全局,是否展示最后更新时间

插件参数 ​

参数类型默认值说明
showCreatedbooleantrue全局默认,是否展示创建时间
showUpdatedbooleantrue全局默认,是否展示最后更新时间
componentNamestringProductCard输出 html_block 使用的组件名,与 registerProductCard(app, name) 配合使用

@sugarat/theme 中使用 ​

主题内置该插件,直接在文章里用 ::: card 即可。