内置组件
大约 1 分钟
通过 vuepress-plugin-components,你可以在 Markdown 文件中导入并使用一些组件。
可用组件:
- Badge: 多彩的徽章组件
- CodePen: 嵌入 CodePen 演示
- Share: 通过社交媒体分享当前页面
- StackBlitz: 嵌入 StackBlitz 演示
- SiteInfo: 显示站点
- VPBanner: 一个横幅组件
- VPCard: 一个卡片组件
为了启用组件,你需要将 plugins.components.components 设置为一个组件名的数组。
提示
媒体组件由 @vuepress/plugin-media 提供,它们通过 plugins.media 启用。
注
<Badge /> 是默认可用的,以便与 @vuepress/theme-default 行为一致。
import { hopeTheme } from "vuepress-theme-hope";
export default hopeTheme({
plugins: {
components: {
// 你想使用的组件
components: [
"Badge",
"CodePen",
"Share",
"SiteInfo",
"StackBlitz",
"VPBanner",
"VPCard",
],
},
},
});杂项
Badge
支持自定义颜色的徽章。
- tip
- warning
- danger
- important
- info
- note
徽章类型
- <Badge text="tip" type="tip" vertical="middle" />
- <Badge text="warning" type="warning" vertical="middle" />
- <Badge text="danger" type="danger" vertical="middle" />
- <Badge text="important" type="important" vertical="middle" />
- <Badge text="info" type="info" vertical="middle" />
- <Badge text="note" type="note" vertical="middle" />有关可用属性,请参阅 Badge 页面。
SiteInfo
基础站点信息
<SiteInfo name="Mr.Hope's Blog" url="https://mister-hope.com" preview="https://theme-hope.vuejs.press/assets/image/mrhope.jpg" />有更多属性的站点信息
<SiteInfo
name="Mr.Hope's Blog"
desc="Where there is light, there is hope"
url="https://mister-hope.com"
logo="https://mister-hope.com/logo.svg"
repo="https://github.com/Mister-Hope/Mister-Hope.github.io"
preview="https://theme-hope.vuejs.press/assets/image/mrhope.jpg"
/>有关可用属性,请参阅 SiteInfo 页面。
Share
基础分享
<Share />自定义分享服务
<Share services="qq,weibo" />
<Share :services="['qq','weibo']" />彩色图标
<Share colorful />有关可用属性,请参阅 Share 页面。
代码相关
CodePen
一个允许你嵌入 CodePen 演示的组件。
See Solar System animation - Pure CSS by kowlor on CodePen.
一个使用用户和 Slug Hash 的案例
<CodePen
user="kowlor"
slug-hash="ZYYQoy"
title="Solar System animation - Pure CSS"
:default-tab="['css','result']"
:theme="$isDarkMode? 'dark': 'light'"
/>See Solar System animation - Pure CSS by kowlor on CodePen.
一个使用链接的案例
<CodePen
link="https://codepen.io/kowlor/pen/ZYYQoy"
title="Solar System animation - Pure CSS"
:default-tab="['css','result']"
:theme="$isDarkMode? 'dark': 'light'"
/>See Envelope w/ Hearts by kowlor on CodePen.
一个点击运行的案例
<CodePen
link="https://codepen.io/kowlor/pen/ZYYQoy"
title="Envelope w/ Hearts"
status="clicktorun"
:theme="$isDarkMode? 'dark': 'light'"
/>有关可用属性,请参阅 CodePen 页面。
StackBlitz
在 Markdown 文件中嵌入 StackBlitz 演示。
一个 StackBlitz 项目
<StackBlitz id="vuepress-theme-hope" />一个自定义设置的 StackBlitz 项目
<StackBlitz id="vuepress-theme-hope" hideExplorer hideNavigation hideDevtools />有关可用属性,请参阅 StackBlitz 页面。
更新日志
2026/9/28 12:45
查看所有更新日志
0c1aa-于4ea6d-于1bd5f-于5a8ce-于55e92-于ac7cf-于b1230-于66d77-于dd4a8-于16ba7-于96c95-于feeb4-于b41c0-于2f66e-于54c46-于497db-于5c0cb-于9b413-于1da28-于3f311-于0739c-于0f844-于792dc-于757fd-于43072-于e728e-于02c41-于d09ab-于5a136-于34452-于d3b16-于d82a8-于3d75e-于7e98c-于c887b-于7a540-于6136a-于8f6b0-于2a306-于4e5f7-于942fc-于e9ea0-于e08cc-于9b72f-于760c6-于737eb-于8174c-于9100f-于f5b66-于3cdac-于5412c-于93657-于c8d60-于b65b9-于90058-于d69e5-于ae2d2-于ab41c-于69cce-于6b8c4-于c0c7e-于58b12-于e835b-于1e7ba-于b8835-于c7061-于145a8-于8b5af-于84771-于0b6f3-于e2bb6-于2fa50-于22c53-于3c8d6-于57c57-于902fd-于f732e-于55cc9-于9856d-于aab9e-于c540c-于e0f17-于6c51a-于48bca-于008a9-于d6279-于d031d-于07909-于306d2-于f635d-于88e69-于db823-于1eb77-于ed3ab-于2d1be-于f6ff0-于3c199-于