Skip to content

Commit 1364115

Browse files
committed
feat: 🚀 新增部分 vp-plus 样式文件,permalink、mdh1 插件发版
1 parent a0d7673 commit 1364115

File tree

25 files changed

+617
-231
lines changed

25 files changed

+617
-231
lines changed

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pnpm install
2222
pnpm to:theme stub
2323
```
2424

25-
使用文档启动
25+
使用文档项目启动
2626

2727
```bash
2828
pnpm docs:dev
@@ -39,15 +39,21 @@ pnpm demo:locales dev
3939
pnpm demo:localesRoot dev
4040
```
4141

42+
如果启动项目失败,则执行如下命令:
43+
44+
```base
45+
pnpm plugin:build
46+
```
47+
4248
## 配置
4349

4450
主题提供了大量的配置,可以在 `src/config/types.ts` 文件阅读配置项。
4551

4652
## TODO
4753

54+
- 背景大图逻辑和 Banner 大图逻辑拆开
4855
- 主题使用文档编写
4956
- 部署测试、线上效果测试
5057
- 发布 NPM 库
5158
- 支持无障碍
5259
- 归档页添加 commit 图标风格,如:`http://niubin.site/archive.html`
53-
- mdH1、permalink 插件发布

demo/docs-base/.vitepress/theme/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import "vitepress-theme-teeker/vp-plus/sidebar.scss";
88
import "vitepress-theme-teeker/vp-plus/nav.scss";
99
import "vitepress-theme-teeker/vp-plus/aside.scss";
1010
import "vitepress-theme-teeker/vp-plus/doc-h1.scss";
11-
// import "vitepress-theme-teeker/vp-plus/container.scss";
11+
import "vitepress-theme-teeker/vp-plus/nav-blur.scss";
12+
import "vitepress-theme-teeker/vp-plus/container.scss";
13+
// import "vitepress-theme-teeker/vp-plus/container-flow.scss";
1214
// import "vitepress-theme-teeker/vp-plus/blockquote.scss";
1315
// import "vitepress-theme-teeker/vp-plus/rainbow.scss";
1416

demo/docs-base/02.MD 插件测试.md

+30
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,33 @@ data:
171171
```
172172
173173
:::
174+
175+
176+
::: info
177+
This is an info box.
178+
:::
179+
180+
::: tip
181+
This is a tip.
182+
:::
183+
184+
::: warning
185+
This is a warning.
186+
:::
187+
188+
::: danger
189+
This is a dangerous warning.
190+
:::
191+
192+
::: details
193+
This is a details block.
194+
:::
195+
196+
> [!IMPORTANT]
197+
> 对用户达成目标至关重要的信息。
198+
199+
> [!WARNING]
200+
> 因为可能存在风险,所以需要用户立即关注的关键内容。
201+
202+
> [!CAUTION]
203+
> 行为可能带来的负面影响。

plugins/vitepress-plugin-md-h1/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# vitepress-plugin-md-h1
22

3+
## 1.0.3
4+
5+
### Patch Changes
6+
7+
- 添加 ignoreList 配置项
8+
39
## 1.0.2
410

511
### Patch Changes

plugins/vitepress-plugin-md-h1/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vitepress-plugin-md-h1",
33
"type": "module",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"description": "添加一级标题到 markdown 文档",
66
"author": {
77
"name": "teeker",

plugins/vitepress-plugin-permalink/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# vitepress-plugin-permalink
22

3+
## 1.0.6
4+
5+
### Patch Changes
6+
7+
- 删除部分配置项,修复浏览器前进、后退 404 出现
8+
39
## 1.0.5
410

511
### Patch Changes

plugins/vitepress-plugin-permalink/README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,21 @@ const myFunction = () => {
106106
`.vitepress/theme/index.ts` 引入 `usePermalink` 函数来初始化 permalinks 功能:
107107

108108
```typescript
109-
import { h } from "vue";
109+
import { h, defineComponent } from "vue";
110110
import DefaultTheme from "vitepress/theme";
111111
import usePermalink from "vitepress-plugin-permalink/src/usePermalink";
112112

113113
export default {
114114
extends: DefaultTheme,
115-
Layout() {
116-
// 开启监听 permalink
117-
usePermalink().startWatch();
118-
119-
return h(DefaultTheme.Layout, null, {});
120-
},
115+
Layout: defineComponent({
116+
name: "LayoutProvider",
117+
setup() {
118+
// 开启监听 permalink
119+
usePermalink().startWatch();
120+
121+
return h(DefaultTheme.Layout, null, {});
122+
},
123+
}),
121124
};
122125
```
123126

plugins/vitepress-plugin-permalink/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vitepress-plugin-permalink",
33
"type": "module",
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"description": "扫描 markdown 文档,生成永久链接",
66
"author": {
77
"name": "teeker",

plugins/vitepress-plugin-permalink/src/index.ts

+19-8
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,30 @@ const getLocalePermalink = (localesKeys: string[] = [], path = "", permalink = "
108108
};
109109

110110
interface SetActiveMatchWhenUsePermalinkOption {
111-
nav: (DefaultTheme.NavItemWithLink & { items: any })[]; // 导航栏
112-
permalinkToPath: Record<string, string>; // permalink 和文件路径的映射关系
113-
rewrites?: Record<string, any>; // 如果设置了 rewrites,则取 rewrites 后的文件路径
114-
cleanUrls?: boolean; // vitepress 配置项,true 关闭 .html 后缀,false 开启 .html 后缀
111+
/**
112+
* 导航栏
113+
*/
114+
nav: (DefaultTheme.NavItemWithLink & { items: any })[];
115+
/**
116+
* permalink 和文件路径的映射关系
117+
*/
118+
permalinkToPath: Record<string, string>;
119+
/**
120+
* 如果设置了 rewrites,则取 rewrites 后的文件路径
121+
*/
122+
rewrites?: Record<string, any>;
123+
/**
124+
* vitepress 配置项,true 关闭 .html 后缀,false 开启 .html 后缀
125+
*/
126+
cleanUrls?: boolean;
115127
}
116128

117129
/**
118-
* 如果 nav 有 link 且 link 为 permalink,则添加 activeMatch 为 permalink 对应的文件路径
130+
* 如果 nav 有 link 且 link 为 permalink,则添加 activeMatch 为 permalink 对应的文件路径,如果没有 link,则代表是下拉组,activeMatch 为子级的上一层目录
119131
* 这里的处理是导航栏兼容 permalink 的高亮功能,默认访问 permalink 后,导航栏不会高亮,因为导航栏是根据实际的文件路径进行匹配
120132
*
121133
* @param option 配置项
134+
* @param parentNav 父级导航
122135
*/
123136
const setActiveMatchWhenUsePermalink = (
124137
option: SetActiveMatchWhenUsePermalinkOption,
@@ -182,9 +195,7 @@ export function VitePluginVitePressNotFoundDelayLoad(option: NotFoundOption = {}
182195
};
183196
},
184197
resolveId(id: string) {
185-
if (id === virtualModuleId) {
186-
return resolvedVirtualModuleId;
187-
}
198+
if (id === virtualModuleId) return resolvedVirtualModuleId;
188199
},
189200
load(id: string) {
190201
// 使用虚拟模块将 option 传入组件里

pnpm-lock.yaml

+27-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vitepress-theme-teeker/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# vitepress-theme-teeker
22

3+
## 1.0.5
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- Updated dependencies
9+
10+
11+
312
## 1.0.4
413

514
### Patch Changes

vitepress-theme-teeker/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "vitepress-theme-teeker",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"description": "vitepress-theme-teeker",
66
"type": "module",
77
"author": {
@@ -50,8 +50,8 @@
5050
"vitepress-plugin-catalogue": "latest",
5151
"vitepress-plugin-doc-analysis": "latest",
5252
"vitepress-plugin-file-content-loader": "latest",
53-
"vitepress-plugin-md-h1": "workspace:*",
54-
"vitepress-plugin-permalink": "workspace:*",
53+
"vitepress-plugin-md-h1": "latest",
54+
"vitepress-plugin-permalink": "latest",
5555
"vitepress-plugin-sidebar-resolve": "latest"
5656
},
5757
"devDependencies": {

vitepress-theme-teeker/src/components/HomeBanner/src/index.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ onUnmounted(() => {
180180
</p>
181181
</div>
182182

183-
<div v-if="features.length && !isBigImgBgStyle" :class="`${ns.e('feature')} flx-wrap-between`">
183+
<div
184+
v-if="features.length && !isBigImgBgStyle"
185+
:class="[ns.e('feature'), 'flx-wrap-between', ns.joinNamespace('wallpaper-outside')]"
186+
>
184187
<div :class="ns.e('feature__item')" v-for="(feature, index) in features" :key="index">
185188
<a v-if="feature.link" :href="withBase(feature.link)" class="flx-column-center">
186189
<img v-if="feature.imgUrl" class="feature-img" :src="withBase(feature.imgUrl)" :alt="feature.title" />

vitepress-theme-teeker/src/configProvider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { computed, defineComponent, h, InjectionKey, provide, Ref, unref, type Component } from "vue";
2-
import { useAnchorScroll, useViewTransition } from "./hooks";
3-
import type { Post } from "./post/types";
42
import { useData } from "vitepress";
53
import usePermalink from "vitepress-plugin-permalink/usePermalink";
4+
import { useAnchorScroll, useViewTransition } from "./hooks";
65
import { emptyPost } from "./post/helper";
6+
import type { Post } from "./post/types";
77

88
export const postsSymbol: InjectionKey<Post> = Symbol("posts");
99

vitepress-theme-teeker/src/helper/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* From vitepress
2+
* From Vitepress。Markdown 插件需要用到,因为 Vitepress 的 withBase 方法无法在 Markdown 插件使用
33
*/
44
export const withBase = (base: string, path?: string) => {
55
if (!path) return;

vitepress-theme-teeker/src/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export type { TkContentData, Post, GroupCardItem, FrontMatter } from "./post/typ
1515

1616
export type DefaultThemeType = typeof DefaultTheme;
1717

18+
export {
19+
createContainerThenUse,
20+
createContainerThenGet,
21+
createContainersThenUse,
22+
createContainersThenGet,
23+
} from "./markdown/plugins/container";
24+
1825
export default {
1926
extends: DefaultTheme,
2027
Layout: configProvider(Layout),

vitepress-theme-teeker/src/styles/components/bodyBgImage.scss

+7-8
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,9 @@
3131

3232
@media (min-width: 1280px) {
3333
/* 导航栏 */
34-
.VPNav {
35-
/* 如果导航栏要透明效果,打开 background-color,如果导航栏要透明磨砂效果,打开这两个样式 */
36-
.VPNavBar:not(.home) {
37-
background-color: getCssVar("bg-color-2") !important;
38-
backdrop-filter: saturate(200%) blur(20px);
39-
.content-body {
40-
background-color: transparent;
41-
}
34+
.VPNav .VPNavBar:not(.home) {
35+
.content-body {
36+
background-color: transparent;
4237
}
4338
}
4439
.VPSidebar {
@@ -49,5 +44,9 @@
4944
}
5045
}
5146
}
47+
48+
.VPNavBar.home .divider {
49+
display: none;
50+
}
5251
}
5352
}

0 commit comments

Comments
 (0)