@dengzhibo/vitepress-example 0.0.1 → 0.0.2

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.
@@ -0,0 +1,3 @@
1
+ # 开发环境:图片基础路径,指向本地 E 盘素材目录
2
+ # 用正斜杠,Windows 同样兼容,且与 CDN URL 格式一致
3
+ IMAGES=E:/project_assets/images/docs/resources
@@ -0,0 +1,3 @@
1
+ # 生产环境:图片走 CDN / 对象存储
2
+ # 上线前改成你的真实 CDN 地址
3
+ IMAGES=https://cdn.example.com/images
@@ -0,0 +1,18 @@
1
+ import type { NavItem, Sidebar } from 'vitepress'
2
+
3
+ // 头部导航栏
4
+ export const nav: NavItem[] = [
5
+ { text: 'Home', link: '/api-examples' },
6
+ { text: 'Examples', link: '/markdown-examples' }
7
+ ];
8
+
9
+ // 侧边栏
10
+ export const sidebar: Sidebar = [
11
+ {
12
+ text: 'Examples',
13
+ items: [
14
+ { text: 'Markdown Examples', link: '/markdown-examples' },
15
+ { text: 'Runtime API Examples', link: '/api-examples' }
16
+ ]
17
+ }
18
+ ];
@@ -0,0 +1,65 @@
1
+ import type { DefaultTheme } from 'vitepress'
2
+
3
+ // 搜索框
4
+ export const searchOptions: DefaultTheme.AlgoliaSearchOptions = {
5
+ placeholder: '搜索文档',
6
+ translations: {
7
+ button: {
8
+ buttonText: '搜索文档',
9
+ buttonAriaLabel: '搜索文档',
10
+ },
11
+ modal: {
12
+ searchBox: {
13
+ resetButtonTitle: '清除查询条件',
14
+ resetButtonAriaLabel: '清除查询条件',
15
+ cancelButtonText: '取消',
16
+ cancelButtonAriaLabel: '取消',
17
+ },
18
+ startScreen: {
19
+ recentSearchesTitle: '搜索历史',
20
+ noRecentSearchesText: '没有搜索历史',
21
+ saveRecentSearchButtonTitle: '保存至搜索历史',
22
+ removeRecentSearchButtonTitle: '从搜索历史中移除',
23
+ favoriteSearchesTitle: '收藏',
24
+ removeFavoriteSearchButtonTitle: '从收藏中移除',
25
+ },
26
+ errorScreen: {
27
+ titleText: '无法获取结果',
28
+ helpText: '你可能需要检查你的网络连接',
29
+ },
30
+ footer: {
31
+ selectText: '选择',
32
+ navigateText: '切换',
33
+ closeText: '关闭',
34
+ searchByText: '搜索供应商',
35
+ },
36
+ noResultsScreen: {
37
+ noResultsText: '无法找到相关结果',
38
+ suggestedQueryText: '你可以尝试查询',
39
+ reportMissingResultsText: '你认为该查询应该有结果?',
40
+ reportMissingResultsLinkText: '点击反馈',
41
+ },
42
+ },
43
+ },
44
+ }
45
+
46
+ // 设置搜索框的样式(简易版)
47
+ export const search = {
48
+ provider: "local",
49
+ options: {
50
+ translations: {
51
+ button: {
52
+ buttonText: "搜索文档",
53
+ buttonAriaLabel: "搜索文档",
54
+ },
55
+ modal: {
56
+ noResultsText: "无法找到相关结果",
57
+ resetButtonTitle: "清除查询条件",
58
+ footer: {
59
+ selectText: "选择",
60
+ navigateText: "切换",
61
+ },
62
+ },
63
+ },
64
+ },
65
+ },
@@ -4,10 +4,14 @@ import { defineConfig } from 'vitepress'
4
4
  export default defineConfig({
5
5
  title: "My Awesome Project",
6
6
  description: "A VitePress Site",
7
+ // 源文件目录配置(读取index.md文件)
8
+ srcDir: "./src",
9
+
7
10
  themeConfig: {
8
11
  // https://vitepress.dev/reference/default-theme-config
9
12
  nav: [
10
13
  { text: 'Home', link: '/' },
14
+ { text: '动画效果', link: '/animations/gsap' },
11
15
  { text: 'Examples', link: '/markdown-examples' }
12
16
  ],
13
17
 
@@ -0,0 +1,30 @@
1
+ <script setup>
2
+ import { ref, reactive, watch } from 'vue'
3
+ import gsap from 'gsap'
4
+
5
+ const number = ref(0)
6
+ const tweened = reactive({
7
+ number: 0
8
+ })
9
+
10
+ watch(
11
+ number,
12
+ (n) => {
13
+ gsap.to(tweened, { duration: 0.5, number: Number(n) || 0 })
14
+ }
15
+ )
16
+ </script>
17
+
18
+ <template>
19
+ <div class="demo">
20
+ Type a number: <input v-model.number="number" />
21
+ <p class="big-number">{{ tweened.number.toFixed(0) }}</p>
22
+ </div>
23
+ </template>
24
+
25
+ <style>
26
+ .big-number {
27
+ font-weight: bold;
28
+ font-size: 2em;
29
+ }
30
+ </style>
@@ -0,0 +1,65 @@
1
+ <script setup>
2
+ import { ref } from 'vue'
3
+ import gsap from 'gsap'
4
+
5
+ const show = ref(true)
6
+
7
+ function onBeforeEnter(el) {
8
+ gsap.set(el, {
9
+ scaleX: 0.25,
10
+ scaleY: 0.25,
11
+ opacity: 1
12
+ })
13
+ }
14
+
15
+ function onEnter(el, done) {
16
+ gsap.to(el, {
17
+ duration: 1,
18
+ scaleX: 1,
19
+ scaleY: 1,
20
+ ease: 'elastic.inOut(2.5, 1)',
21
+ onComplete: done
22
+ })
23
+ }
24
+
25
+ function onLeave(el, done) {
26
+ gsap.to(el, {
27
+ duration: 0.7,
28
+ scaleX: 1,
29
+ scaleY: 1,
30
+ x: 300,
31
+ ease: 'elastic.inOut(2.5, 1)'
32
+ })
33
+ gsap.to(el, {
34
+ duration: 0.2,
35
+ delay: 0.5,
36
+ opacity: 0,
37
+ onComplete: done
38
+ })
39
+ }
40
+ </script>
41
+
42
+ <template>
43
+ <div class="demo">
44
+ <button @click="show = !show">Toggle</button>
45
+
46
+ <Transition
47
+ @before-enter="onBeforeEnter"
48
+ @enter="onEnter"
49
+ @leave="onLeave"
50
+ :css="false"
51
+ >
52
+ <div class="gsap-box" v-if="show"></div>
53
+ </Transition>
54
+ </div>
55
+ </template>
56
+
57
+ <style>
58
+ .gsap-box {
59
+ background: var(--vt-c-green);
60
+ margin-top: 20px;
61
+ width: 30px;
62
+ height: 30px;
63
+ border-radius: 50%;
64
+ }
65
+ </style>
@@ -0,0 +1,62 @@
1
+ <script setup>
2
+ import { ref, computed } from 'vue'
3
+ import gsap from 'gsap'
4
+
5
+ const list = [
6
+ { msg: 'Bruce Lee' },
7
+ { msg: 'Jackie Chan' },
8
+ { msg: 'Chuck Norris' },
9
+ { msg: 'Jet Li' },
10
+ { msg: 'Kung Fury' }
11
+ ]
12
+
13
+ const query = ref('')
14
+
15
+ const computedList = computed(() => {
16
+ return list.filter((item) => item.msg.toLowerCase().includes(query.value.toLowerCase()))
17
+ })
18
+
19
+ function onBeforeEnter(el) {
20
+ el.style.opacity = 0
21
+ el.style.height = 0
22
+ }
23
+
24
+ function onEnter(el, done) {
25
+ gsap.to(el, {
26
+ opacity: 1,
27
+ height: '1.6em',
28
+ delay: el.dataset.index * 0.15,
29
+ onComplete: done
30
+ })
31
+ }
32
+
33
+ function onLeave(el, done) {
34
+ gsap.to(el, {
35
+ opacity: 0,
36
+ height: 0,
37
+ delay: el.dataset.index * 0.15,
38
+ onComplete: done
39
+ })
40
+ }
41
+ </script>
42
+
43
+ <template>
44
+ <div class="demo" style="height: 265px">
45
+ <input v-model="query" style="margin-bottom: 20px" />
46
+ <TransitionGroup
47
+ tag="ul"
48
+ :css="false"
49
+ @before-enter="onBeforeEnter"
50
+ @enter="onEnter"
51
+ @leave="onLeave"
52
+ >
53
+ <li
54
+ v-for="(item, index) in computedList"
55
+ :key="item.msg"
56
+ :data-index="index"
57
+ >
58
+ {{ item.msg }}
59
+ </li>
60
+ </TransitionGroup>
61
+ </div>
62
+ </template>
@@ -2,7 +2,7 @@
2
2
  import { h } from 'vue'
3
3
  import type { Theme } from 'vitepress'
4
4
  import DefaultTheme from 'vitepress/theme'
5
- import './style.css'
5
+ import './styles/style.css'
6
6
 
7
7
  export default {
8
8
  extends: DefaultTheme,
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * The soft color must be semi transparent alpha channel. This is crucial
26
26
  * because it allows adding multiple "soft" colors on top of each other
27
- * to create an accent, such as when having inline code block inside
27
+ * to create a accent, such as when having inline code block inside
28
28
  * custom containers.
29
29
  *
30
30
  * - `default`: The color used purely for subtle indication without any
@@ -106,13 +106,13 @@
106
106
  --vp-home-hero-image-filter: blur(44px);
107
107
  }
108
108
 
109
- @media (min-width: 40rem) {
109
+ @media (min-width: 640px) {
110
110
  :root {
111
111
  --vp-home-hero-image-filter: blur(56px);
112
112
  }
113
113
  }
114
114
 
115
- @media (min-width: 60rem) {
115
+ @media (min-width: 960px) {
116
116
  :root {
117
117
  --vp-home-hero-image-filter: blur(68px);
118
118
  }
@@ -129,3 +129,11 @@
129
129
  --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft);
130
130
  }
131
131
 
132
+ /**
133
+ * Component: Algolia
134
+ * -------------------------------------------------------------------------- */
135
+
136
+ .DocSearch {
137
+ --docsearch-primary-color: var(--vp-c-brand-1) !important;
138
+ }
139
+
package/package.json CHANGED
@@ -1,11 +1,24 @@
1
1
  {
2
2
  "name": "@dengzhibo/vitepress-example",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "keywords": [],
7
7
  "author": "",
8
8
  "license": "ISC",
9
+ "dependencies": {
10
+ "@vue/repl": "^4.7.2",
11
+ "dynamics.js": "^1.1.5",
12
+ "gsap": "^3.15.0",
13
+ "vue": "^3.5.42"
14
+ },
15
+ "devDependencies": {
16
+ "@types/markdown-it": "^14.2.0",
17
+ "@types/node": "^22.20.2",
18
+ "typescript": "^6.0.3",
19
+ "vitepress": "2.0.0-alpha.20",
20
+ "vue-tsc": "^3.3.11"
21
+ },
9
22
  "devEngines": {
10
23
  "packageManager": {
11
24
  "name": "pnpm",
@@ -13,9 +26,6 @@
13
26
  "onFail": "download"
14
27
  }
15
28
  },
16
- "devDependencies": {
17
- "vitepress": "2.0.0-alpha.20"
18
- },
19
29
  "scripts": {
20
30
  "dev": "vitepress dev",
21
31
  "build": "vitepress build",
@@ -0,0 +1,18 @@
1
+ # gsap 动画演示
2
+
3
+ ```
4
+ <script setup>
5
+ import AnimateWatcher from '../.vitepress/theme/components/gsap/AnimateWatcher.vue'
6
+ import JsHooks from '../.vitepress/theme/components/gsap/JsHooks.vue'
7
+ import ListStagger from '../.vitepress/theme/components/gsap/ListStagger.vue'
8
+ </script>
9
+ ```
10
+
11
+ ### 示例1:AnimateWatcher
12
+ <AnimateWatcher />
13
+
14
+ ### 示例2:JsHooks
15
+ <JsHooks />
16
+
17
+ ### 示例3:ListStagger 交错动画
18
+ <ListStagger />
package/src/index.md ADDED
@@ -0,0 +1,25 @@
1
+ ---
2
+ # https://vitepress.dev/reference/default-theme-home-page
3
+ layout: home
4
+
5
+ hero:
6
+ name: "My Awesome Project"
7
+ text: "A VitePress Site"
8
+ tagline: My great project tagline
9
+ actions:
10
+ - theme: brand
11
+ text: Markdown Examples
12
+ link: /markdown-examples
13
+ - theme: alt
14
+ text: API Examples
15
+ link: /api-examples
16
+
17
+ features:
18
+ - title: Feature A
19
+ details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
20
+ - title: Feature B
21
+ details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
22
+ - title: Feature C
23
+ details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
24
+ ---
25
+
@@ -1,32 +0,0 @@
1
- {
2
- "hash": "348f1bd3",
3
- "configHash": "6ce5dbd8",
4
- "lockfileHash": "895fc289",
5
- "browserHash": "ea08553c",
6
- "optimized": {
7
- "vitepress > @vue/devtools-api": {
8
- "src": "../../../node_modules/.pnpm/@vue+devtools-api@8.2.1/node_modules/@vue/devtools-api/dist/index.js",
9
- "file": "vitepress_n_@vue_devtools-api.js",
10
- "fileHash": "114dcc10",
11
- "needsInterop": false
12
- },
13
- "vitepress > @vueuse/core": {
14
- "src": "../../../node_modules/.pnpm/@vueuse+core@14.4.0_vue@3.5.42/node_modules/@vueuse/core/dist/index.js",
15
- "file": "vitepress_n_@vueuse_core.js",
16
- "fileHash": "ac4427d6",
17
- "needsInterop": false
18
- },
19
- "vue": {
20
- "src": "../../../node_modules/.pnpm/vue@3.5.42/node_modules/vue/dist/vue.runtime.esm-bundler.js",
21
- "file": "vue.js",
22
- "fileHash": "6ece4373",
23
- "needsInterop": false
24
- }
25
- },
26
- "chunks": {
27
- "vue.runtime.esm-bundler-D-XhGYqL": {
28
- "file": "vue.runtime.esm-bundler-D-XhGYqL.js",
29
- "isDynamicEntry": false
30
- }
31
- }
32
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }