@fuxishi/vitepress-theme 2.0.0-alpha.2 → 2.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,140 +1,140 @@
1
- # @fuxishi/vitepress-theme
2
-
3
- 精美的 VitePress 文档站主题扩展,毛玻璃质感,紫蓝渐变,动效丰富,开箱即用。
4
-
5
- [English](./README_EN.md)
6
-
7
- ## 特性
8
-
9
- - 🎵 **悬浮音乐球** — 毛玻璃质感的浮动播放器,支持单曲/列表模式,紫蓝渐变进度环与四重播放动效
10
- - 🎊 **点击彩纸** — 全局点击彩纸特效,支持金色星星、彩色纸片和自定义 Emoji
11
- - 🎨 **Hero 图片取色** — 自动提取首页 hero 图片颜色,动态应用到背景光晕、标题渐变、代码块光束和音乐球
12
- - ✨ **Feature 光效** — 首页 Feature 卡片鼠标追踪光晕效果
13
- - ✨ **光束边框** — 暗色模式下代码块、代码组和导航 hover 时展示紫青品牌色光束旋转边框
14
- - 🔄 **主题切换动画** — View Transition API 实现亮暗模式圆形扩散动画
15
- - 📜 **平滑滚动** — 右侧大纲导航点击时平滑滚动,指示条丝滑过渡
16
- - 🎨 **标题装饰** — h1-h4 各有不同颜色的下划线装饰
17
- - 📦 **代码块折叠** — 超过指定行数的代码块自动折叠,底部毛玻璃模糊遮罩,可配置折叠行数阈值
18
- - ⚙️ **类型安全** — 完整的 TypeScript 类型定义,IDE 友好
19
-
20
- > **注意:** 本版本(v2.x)基于 VitePress `2.0` 开发,不向下兼容 VitePress 1.x
21
-
22
- ## 安装
23
-
24
- ```bash
25
- npm install @fuxishi/vitepress-theme
26
- ```
27
-
28
- 需要安装以下 peerDependencies:
29
-
30
- ```bash
31
- npm install vitepress
32
- ```
33
-
34
- ## 使用
35
-
36
- ### 1. 注册主题
37
-
38
- 创建 `.vitepress/theme/index.ts`:
39
-
40
- ```ts
41
- import FxTheme from "@fuxishi/vitepress-theme"
42
- import "@fuxishi/vitepress-theme/style.css"
43
-
44
- export default FxTheme
45
- ```
46
-
47
- ### 2. 继承配置
48
-
49
- 创建 `.vitepress/config.mts`:
50
-
51
- ```ts
52
- import { defineConfig } from "vitepress"
53
- import type { DefaultTheme } from "vitepress"
54
- import fxConfig from "@fuxishi/vitepress-theme/config"
55
- import type { FxThemeCustomConfig } from "@fuxishi/vitepress-theme"
56
-
57
- type ThemeConfig = DefaultTheme.Config & FxThemeCustomConfig
58
-
59
- export default defineConfig<ThemeConfig>({
60
- extends: fxConfig,
61
- lang: "zh-CN",
62
- title: "我的文档站",
63
- themeConfig: {
64
- nav: [{ text: "指南", link: "/guide/" }],
65
- sidebar: {
66
- "/guide/": [{ text: "快速开始", link: "/guide/" }],
67
- },
68
- // 启用音乐球
69
- musicBall: {
70
- enable: true,
71
- autoplay: false,
72
- loop: true,
73
- src: "/music/my-song.mp3",
74
- },
75
- // 启用彩纸效果
76
- confetti: true,
77
- // 彩色纸片
78
- // confetti: { shape: "colored-paper" },
79
- // 自定义 Emoji
80
- // confetti: { shapes: ["🌸", "🎀"] },
81
- // 启用 hero 图片取色
82
- heroImageColor: true,
83
- // 启用平滑滚动
84
- smoothScroll: true,
85
- // 代码块折叠(默认启用,10 行折叠)
86
- codeBlockFold: true,
87
- // 自定义折叠行数
88
- // codeBlockFold: { lines: 20 },
89
- },
90
- })
91
- ```
92
-
93
- ### 3. 启动开发服务器
94
-
95
- ```bash
96
- npx vitepress dev
97
- ```
98
-
99
- ## 配置
100
-
101
- ### FxThemeCustomConfig
102
-
103
- 通过 `DefaultTheme.Config & FxThemeCustomConfig` 交叉类型扩展 VitePress 默认主题配置,新增以下字段:
104
-
105
- | 配置项 | 类型 | 默认值 | 说明 |
106
- | --------------------- | --------------------------- | -------- | ------------------------------------------------------ |
107
- | `musicBall.enable` | `boolean` | `true` | 是否启用音乐球 |
108
- | `musicBall.visible` | `boolean` | `true` | 是否可见 |
109
- | `musicBall.autoplay` | `boolean` | `false` | 自动播放 |
110
- | `musicBall.loop` | `boolean` | `true` | 循环播放(单曲模式) |
111
- | `musicBall.src` | `string` | `''` | 单首音乐地址 |
112
- | `musicBall.list` | `MusicItem[]` | — | 多首音乐列表 |
113
- | `confetti` | `boolean \| object` | `true` | 启用彩纸效果 |
114
- | `confetti.shape` | `'star' \| 'colored-paper'` | `'star'` | 预设形状 |
115
- | `confetti.shapes` | `string \| string[]` | — | 自定义 Emoji 形状 |
116
- | `confetti.secondary` | `boolean` | `true` | 是否添加二次散射粒子 |
117
- | `heroImageColor` | `boolean` | `false` | 自动提取 hero 图片颜色(影响光晕、标题、光束、音乐球) |
118
- | `smoothScroll` | `boolean` | `false` | 启用平滑滚动和大纲指示条过渡动画 |
119
- | `codeBlockFold` | `boolean \| object` | `true` | 代码块折叠,默认启用 |
120
- | `codeBlockFold.lines` | `number` | `10` | 超过多少行折叠 |
121
-
122
- ## 导出
123
-
124
- | 导出路径 | 说明 |
125
- | ------------------------------------ | ---------------------- |
126
- | `@fuxishi/vitepress-theme` | 主题(Layout + 样式) |
127
- | `@fuxishi/vitepress-theme/config` | VitePress 基础配置预设 |
128
- | `@fuxishi/vitepress-theme/style.css` | 独立样式文件 |
129
-
130
- ## 文档
131
-
132
- 完整文档请访问:
133
-
134
- [https://fuxishi-vitepress-theme.fuxizjxzy.cn](https://fuxishi-vitepress-theme.fuxizjxzy.cn)
135
-
136
- ## License
137
-
138
- [MIT](./LICENSE)
139
-
140
- > 后续将在 GitHub 开放源码。
1
+ # @fuxishi/vitepress-theme
2
+
3
+ 精美的 VitePress 文档站主题扩展,毛玻璃质感,紫蓝渐变,动效丰富,开箱即用。
4
+
5
+ [English](./README_EN.md)
6
+
7
+ ## 特性
8
+
9
+ - 🎵 **悬浮音乐球** — 毛玻璃质感的浮动播放器,支持单曲/列表模式,紫蓝渐变进度环与四重播放动效
10
+ - 🎊 **点击彩纸** — 全局点击彩纸特效,支持金色星星、彩色纸片和自定义 Emoji
11
+ - 🎨 **Hero 图片取色** — 自动提取首页 hero 图片颜色,动态应用到背景光晕、标题渐变、代码块光束和音乐球
12
+ - ✨ **Feature 光效** — 首页 Feature 卡片鼠标追踪光晕效果
13
+ - ✨ **光束边框** — 暗色模式下代码块、代码组和导航 hover 时展示紫青品牌色光束旋转边框
14
+ - 🔄 **主题切换动画** — View Transition API 实现亮暗模式圆形扩散动画
15
+ - 📜 **平滑滚动** — 右侧大纲导航点击时平滑滚动,指示条丝滑过渡
16
+ - 🎨 **标题装饰** — h1-h4 各有不同颜色的下划线装饰
17
+ - 📦 **代码块折叠** — 超过指定行数的代码块自动折叠,底部毛玻璃模糊遮罩,可配置折叠行数阈值
18
+ - ⚙️ **类型安全** — 完整的 TypeScript 类型定义,IDE 友好
19
+
20
+ > **注意:** 本版本(v2.x)基于 VitePress `2.0.0-alpha.20` 开发,不向下兼容 VitePress 1.x。需要 Node.js 22+(VitePress 2.0.0-alpha.18 起基于 Vite 8)。
21
+
22
+ ## 安装
23
+
24
+ ```bash
25
+ npm install @fuxishi/vitepress-theme
26
+ ```
27
+
28
+ 需要安装以下 peerDependencies:
29
+
30
+ ```bash
31
+ npm install vitepress
32
+ ```
33
+
34
+ ## 使用
35
+
36
+ ### 1. 注册主题
37
+
38
+ 创建 `.vitepress/theme/index.ts`:
39
+
40
+ ```ts
41
+ import FxTheme from "@fuxishi/vitepress-theme"
42
+ import "@fuxishi/vitepress-theme/style.css"
43
+
44
+ export default FxTheme
45
+ ```
46
+
47
+ ### 2. 继承配置
48
+
49
+ 创建 `.vitepress/config.mts`:
50
+
51
+ ```ts
52
+ import { defineConfig } from "vitepress"
53
+ import type { DefaultTheme } from "vitepress"
54
+ import fxConfig from "@fuxishi/vitepress-theme/config"
55
+ import type { FxThemeCustomConfig } from "@fuxishi/vitepress-theme"
56
+
57
+ type ThemeConfig = DefaultTheme.Config & FxThemeCustomConfig
58
+
59
+ export default defineConfig<ThemeConfig>({
60
+ extends: fxConfig,
61
+ lang: "zh-CN",
62
+ title: "我的文档站",
63
+ themeConfig: {
64
+ nav: [{ text: "指南", link: "/guide/" }],
65
+ sidebar: {
66
+ "/guide/": [{ text: "快速开始", link: "/guide/" }],
67
+ },
68
+ // 启用音乐球
69
+ musicBall: {
70
+ enable: true,
71
+ autoplay: false,
72
+ loop: true,
73
+ src: "/music/my-song.mp3",
74
+ },
75
+ // 启用彩纸效果
76
+ confetti: true,
77
+ // 彩色纸片
78
+ // confetti: { shape: "colored-paper" },
79
+ // 自定义 Emoji
80
+ // confetti: { shapes: ["🌸", "🎀"] },
81
+ // 启用 hero 图片取色
82
+ heroImageColor: true,
83
+ // 启用平滑滚动
84
+ smoothScroll: true,
85
+ // 代码块折叠(默认启用,10 行折叠)
86
+ codeBlockFold: true,
87
+ // 自定义折叠行数
88
+ // codeBlockFold: { lines: 20 },
89
+ },
90
+ })
91
+ ```
92
+
93
+ ### 3. 启动开发服务器
94
+
95
+ ```bash
96
+ npx vitepress dev
97
+ ```
98
+
99
+ ## 配置
100
+
101
+ ### FxThemeCustomConfig
102
+
103
+ 通过 `DefaultTheme.Config & FxThemeCustomConfig` 交叉类型扩展 VitePress 默认主题配置,新增以下字段:
104
+
105
+ | 配置项 | 类型 | 默认值 | 说明 |
106
+ | --------------------- | --------------------------- | -------- | ------------------------------------------------------ |
107
+ | `musicBall.enable` | `boolean` | `true` | 是否启用音乐球 |
108
+ | `musicBall.visible` | `boolean` | `true` | 是否可见 |
109
+ | `musicBall.autoplay` | `boolean` | `false` | 自动播放 |
110
+ | `musicBall.loop` | `boolean` | `true` | 循环播放(单曲模式) |
111
+ | `musicBall.src` | `string` | `''` | 单首音乐地址 |
112
+ | `musicBall.list` | `MusicItem[]` | — | 多首音乐列表 |
113
+ | `confetti` | `boolean \| object` | `true` | 启用彩纸效果 |
114
+ | `confetti.shape` | `'star' \| 'colored-paper'` | `'star'` | 预设形状 |
115
+ | `confetti.shapes` | `string \| string[]` | — | 自定义 Emoji 形状 |
116
+ | `confetti.secondary` | `boolean` | `true` | 是否添加二次散射粒子 |
117
+ | `heroImageColor` | `boolean` | `false` | 自动提取 hero 图片颜色(影响光晕、标题、光束、音乐球) |
118
+ | `smoothScroll` | `boolean` | `false` | 启用平滑滚动和大纲指示条过渡动画 |
119
+ | `codeBlockFold` | `boolean \| object` | `true` | 代码块折叠,默认启用 |
120
+ | `codeBlockFold.lines` | `number` | `10` | 超过多少行折叠 |
121
+
122
+ ## 导出
123
+
124
+ | 导出路径 | 说明 |
125
+ | ------------------------------------ | ---------------------- |
126
+ | `@fuxishi/vitepress-theme` | 主题(Layout + 样式) |
127
+ | `@fuxishi/vitepress-theme/config` | VitePress 基础配置预设 |
128
+ | `@fuxishi/vitepress-theme/style.css` | 独立样式文件 |
129
+
130
+ ## 文档
131
+
132
+ 完整文档请访问:
133
+
134
+ [https://fuxishi-vitepress-theme.fuxizjxzy.cn](https://fuxishi-vitepress-theme.fuxizjxzy.cn)
135
+
136
+ ## License
137
+
138
+ [MIT](./LICENSE)
139
+
140
+ > 后续将在 GitHub 开放源码。
package/README_EN.md ADDED
@@ -0,0 +1,140 @@
1
+ # @fuxishi/vitepress-theme
2
+
3
+ A beautiful VitePress theme extension with frosted glass effects, purple-blue gradients, rich animations, and ready to use.
4
+
5
+ [中文](./README.md)
6
+
7
+ ## Features
8
+
9
+ - 🎵 **Floating Music Ball** — Frosted glass floating player with single/playlist mode, purple-blue gradient progress ring and four playback animations
10
+ - 🎊 **Click Confetti** — Global click confetti effect with gold stars, colored paper pieces, and custom Emoji
11
+ - 🎨 **Hero Image Color** — Auto-extract colors from hero image for background glow, title gradient, code block beams, and music ball
12
+ - ✨ **Feature Glow** — Mouse-tracking glow effect on homepage Feature cards
13
+ - ✨ **Beam Border** — Purple-cyan brand color beam border on code blocks, code groups, and navigation in dark mode on hover
14
+ - 🔄 **Theme Switch Animation** — Circular spread animation for light/dark mode switching using View Transition API
15
+ - 📜 **Smooth Scroll** — Smooth scrolling when clicking outline navigation with silky marker transition
16
+ - 🎨 **Heading Decorations** — Different colored underlines for h1-h4 headings
17
+ - 📦 **Code Block Fold** — Auto-fold code blocks exceeding a line threshold with frosted glass blur overlay, configurable fold line count
18
+ - ⚙️ **Type-safe** — Complete TypeScript type definitions, IDE friendly
19
+
20
+ > **Note:** This version (v2.x) is built on VitePress `2.0.0-alpha.20` and is not backward compatible with VitePress 1.x. Node.js 22+ is required (VitePress 2.0.0-alpha.18+ is built on Vite 8).
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @fuxishi/vitepress-theme
26
+ ```
27
+
28
+ Install peerDependencies:
29
+
30
+ ```bash
31
+ npm install vitepress
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ### 1. Register Theme
37
+
38
+ Create `.vitepress/theme/index.ts`:
39
+
40
+ ```ts
41
+ import FxTheme from "@fuxishi/vitepress-theme"
42
+ import "@fuxishi/vitepress-theme/style.css"
43
+
44
+ export default FxTheme
45
+ ```
46
+
47
+ ### 2. Extend Configuration
48
+
49
+ Create `.vitepress/config.mts`:
50
+
51
+ ```ts
52
+ import { defineConfig } from "vitepress"
53
+ import type { DefaultTheme } from "vitepress"
54
+ import fxConfig from "@fuxishi/vitepress-theme/config"
55
+ import type { FxThemeCustomConfig } from "@fuxishi/vitepress-theme"
56
+
57
+ type ThemeConfig = DefaultTheme.Config & FxThemeCustomConfig
58
+
59
+ export default defineConfig<ThemeConfig>({
60
+ extends: fxConfig,
61
+ lang: "en",
62
+ title: "My Docs",
63
+ themeConfig: {
64
+ nav: [{ text: "Guide", link: "/guide/" }],
65
+ sidebar: {
66
+ "/guide/": [{ text: "Getting Started", link: "/guide/" }],
67
+ },
68
+ // Enable music ball
69
+ musicBall: {
70
+ enable: true,
71
+ autoplay: false,
72
+ loop: true,
73
+ src: "/music/my-song.mp3",
74
+ },
75
+ // Enable confetti
76
+ confetti: true,
77
+ // Colored paper pieces
78
+ // confetti: { shape: "colored-paper" },
79
+ // Custom Emoji
80
+ // confetti: { shapes: ["🌸", "🎀"] },
81
+ // Enable hero image color extraction
82
+ heroImageColor: true,
83
+ // Enable smooth scroll
84
+ smoothScroll: true,
85
+ // Code block fold (enabled by default, 10 lines threshold)
86
+ codeBlockFold: true,
87
+ // Custom fold line threshold
88
+ // codeBlockFold: { lines: 20 },
89
+ },
90
+ })
91
+ ```
92
+
93
+ ### 3. Start Dev Server
94
+
95
+ ```bash
96
+ npx vitepress dev
97
+ ```
98
+
99
+ ## Configuration
100
+
101
+ ### FxThemeCustomConfig
102
+
103
+ Extends VitePress `DefaultTheme.Config` via intersection type `DefaultTheme.Config & FxThemeCustomConfig`, adding the following fields:
104
+
105
+ | Option | Type | Default | Description |
106
+ | --------------------- | --------------------------- | -------- | ----------------------------------------------------------------- |
107
+ | `musicBall.enable` | `boolean` | `true` | Enable music ball |
108
+ | `musicBall.visible` | `boolean` | `true` | Visibility |
109
+ | `musicBall.autoplay` | `boolean` | `false` | Autoplay |
110
+ | `musicBall.loop` | `boolean` | `true` | Loop playback (single mode) |
111
+ | `musicBall.src` | `string` | `''` | Single music URL |
112
+ | `musicBall.list` | `MusicItem[]` | — | Multi-song playlist |
113
+ | `confetti` | `boolean \| object` | `true` | Enable confetti |
114
+ | `confetti.shape` | `'star' \| 'colored-paper'` | `'star'` | Preset shape |
115
+ | `confetti.shapes` | `string \| string[]` | — | Custom Emoji shapes |
116
+ | `confetti.secondary` | `boolean` | `true` | Whether to add secondary particles |
117
+ | `heroImageColor` | `boolean` | `false` | Auto-extract hero image colors (affects glow, title, beams, ball) |
118
+ | `smoothScroll` | `boolean` | `false` | Enable smooth scrolling and outline marker transition |
119
+ | `codeBlockFold` | `boolean \| object` | `true` | Enable code block folding |
120
+ | `codeBlockFold.lines` | `number` | `10` | Line count threshold for folding |
121
+
122
+ ## Exports
123
+
124
+ | Export Path | Description |
125
+ | ------------------------------------ | ---------------------------- |
126
+ | `@fuxishi/vitepress-theme` | Theme (Layout + Styles) |
127
+ | `@fuxishi/vitepress-theme/config` | VitePress base config preset |
128
+ | `@fuxishi/vitepress-theme/style.css` | Standalone style file |
129
+
130
+ ## Documentation
131
+
132
+ Full documentation:
133
+
134
+ [https://fuxishi-vitepress-theme.fuxizjxzy.cn](https://fuxishi-vitepress-theme.fuxizjxzy.cn)
135
+
136
+ ## License
137
+
138
+ [MIT](./LICENSE)
139
+
140
+ > Will be open-sourced on GitHub in the future.
@@ -1,4 +1,4 @@
1
- import { t as e } from "./icons-DtAsNqxj.js";
1
+ import { t as e } from "./icons-CH79L9OV.js";
2
2
  import { defineComponent as t, nextTick as n, onBeforeUnmount as r, onMounted as i, watch as a } from "vue";
3
3
  import { useRoute as o } from "vitepress";
4
4
  //#region .vitepress/components/FxCodeBlockFold.ts
@@ -6,10 +6,10 @@ var i = /* @__PURE__ */ e({
6
6
  __name: "FxConfetti",
7
7
  props: { confetti: { type: [Boolean, Object] } },
8
8
  setup(e) {
9
- let i = e, a = typeof i.confetti == "object" ? i.confetti : {}, o = a.shape || "star", s = a.secondary !== !1, c = a.shapes ? Array.isArray(a.shapes) ? a.shapes : [a.shapes] : null, l = [], u = [];
9
+ let i = e, a = typeof i.confetti == "object" ? i.confetti : {}, o = a.shape || "star", s = a.secondary !== !1, c = a.shapes ? Array.isArray(a.shapes) ? a.shapes : [a.shapes] : null, l = [], u = !1;
10
10
  function d(e, t, n, i = "circle") {
11
11
  let a = () => {
12
- r({
12
+ u || (r({
13
13
  ...n,
14
14
  particleCount: 10,
15
15
  scalar: 1.2
@@ -18,9 +18,9 @@ var i = /* @__PURE__ */ e({
18
18
  particleCount: 10,
19
19
  scalar: .75,
20
20
  ...s ? { shapes: [i] } : {}
21
- });
21
+ }));
22
22
  };
23
- u.push(setTimeout(a, 0)), u.push(setTimeout(a, 50)), u.push(setTimeout(a, 100));
23
+ setTimeout(a, 0), setTimeout(a, 50), setTimeout(a, 100);
24
24
  }
25
25
  let f = (e, t) => d(e, t, {
26
26
  spread: 360,
@@ -79,7 +79,7 @@ var i = /* @__PURE__ */ e({
79
79
  scalar: 2
80
80
  }))), window.addEventListener("click", h);
81
81
  }), t(() => {
82
- window.removeEventListener("click", h), u.forEach(clearTimeout);
82
+ u = !0, window.removeEventListener("click", h);
83
83
  }), (e, t) => null;
84
84
  }
85
85
  });