vitepress-plugin-announcement 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  [English](https://github.com/ATQQ/sugar-blog/blob/master/packages/vitepress-plugin-announcement/README-en.md) | 简体中文
4
4
 
5
+ ![](https://cdn.upyun.sugarat.top/mdImg/sugar/7af94a65e3b4dd05e61e3411daba7fdd)
6
+
7
+ *介绍文章:[VitePress 公告插件开发实记](https://sugarat.top/technology/works/vitepress-plugin-announcement.html) · [archive](https://web.archive.org/web/20240921095008/https://sugarat.top/technology/works/vitepress-plugin-announcement.html) · [translated](https://sugarat-top.translate.goog/technology/works/vitepress-plugin-announcement.html?_x_tr_sl=zh-CN&_x_tr_tl=en&_x_tr_hl=zh-CN&_x_tr_pto=wapp)*
5
8
  ## 使用
6
9
  安装依赖 `pnpm/npm/yarn`
7
10
  ```sh
@@ -21,21 +24,35 @@ export default defineConfig({
21
24
  AnnouncementPlugin({
22
25
  title: '公告',
23
26
  body: [
24
- { type: 'text', content: '下方插入了二维码' },
27
+ { type: 'text', content: '👇公众号👇 ---👇 赞赏 👇' },
25
28
  {
26
29
  type: 'image',
27
- src: 'https://img.cdn.sugarat.top/mdImg/MTYxNTAxODc2NTIxMA==615018765210~fmt.webp'
30
+ src: 'https://cdn.upyun.sugarat.top/mdImg/sugar/85c9554d023be2fcc5aab94effeef033',
31
+ style: 'display: inline-block;width:46%;padding-right:6px'
32
+ },
33
+ {
34
+ type: 'image',
35
+ src: 'https://cdn.upyun.sugarat.top/mdImg/sugar/54eacf3e730af9c1e3542a4800a422ea',
36
+ style: 'display: inline-block;width:46%;padding-left:6px'
37
+ }
38
+ ],
39
+ footer: [
40
+ {
41
+ type: 'text',
42
+ content: 'footer content'
28
43
  },
29
44
  {
30
45
  type: 'button',
31
46
  content: '作者博客',
32
47
  link: 'https://sugarat.top'
33
48
  },
34
- ],
35
- footer: [
36
49
  {
37
- type: 'text',
38
- content: '底部内容'
50
+ type: 'button',
51
+ content: '博客主题',
52
+ link: 'https://theme.sugarat.top',
53
+ props: {
54
+ type: 'success'
55
+ }
39
56
  },
40
57
  ],
41
58
  })
@@ -69,6 +86,39 @@ AnnouncementPlugin({
69
86
  })
70
87
  ```
71
88
 
89
+ ### 按钮
90
+ ```js
91
+ AnnouncementPlugin({
92
+ title: '公告',
93
+ body: [
94
+ {
95
+ type: 'button',
96
+ content: '博客主题',
97
+ link: 'https://theme.sugarat.top',
98
+ props: {
99
+ type: 'success'
100
+ }
101
+ },
102
+ ],
103
+ })
104
+ ```
105
+
106
+ ### 修改样式
107
+ ```js
108
+ AnnouncementPlugin({
109
+ title: '公告',
110
+ body: [
111
+ {
112
+ type: '',
113
+ content: '',
114
+ // ↓↓↓↓↓
115
+ style: 'color: #000; font-size: 16px;'
116
+ // ↑↑↑↑↑
117
+ }
118
+ ]
119
+ })
120
+ ```
121
+
72
122
  ## 完整配置
73
123
  ```ts
74
124
  import type { Ref } from 'vue'
@@ -164,7 +214,9 @@ export declare namespace Announcement {
164
214
  link: string
165
215
  content: string
166
216
  style?: string
167
- props?: any
217
+ props?: {
218
+ type: 'primary' | 'success' | 'danger' | 'warning' | 'info' | 'text' | 'default'
219
+ }
168
220
  }
169
221
 
170
222
  export type Value = Title | Text | Image | Button
@@ -3,15 +3,13 @@ import { computed } from 'vue'
3
3
 
4
4
  const props = defineProps<{
5
5
  type: 'primary' | 'success' | 'danger' | 'warning' | 'info' | 'text' | 'default'
6
- onClick?: () => void
7
- style?: Record<string, any>
8
6
  }>()
9
7
 
10
8
  const type = computed(() => props.type ?? 'primary')
11
9
  </script>
12
10
 
13
11
  <template>
14
- <button class="announcement-button" :class="`announcement-button-${type}`" @click="props.onClick">
12
+ <button class="announcement-button" :class="`announcement-button-${type}`">
15
13
  <span>
16
14
  <slot />
17
15
  </span>
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directives.js","sourceRoot":"","sources":["../../src/components/directives.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,OAAO,EAAE,CAAC,EAAe,EAAE,OAAY,EAAE,EAAE;QACzC,EAAE,CAAC,SAAS,GAAG,OAAO,CAAC,KAAK,CAAA;IAC9B,CAAC;CACF,CAAA"}
@@ -1,3 +1,11 @@
1
+ html .theme-blog-popover {
2
+ --box-shadow: 0 1px 8px 0 rgba(0, 0, 0, 0.1);
3
+ }
4
+
5
+ html.dark .theme-blog-popover {
6
+ --box-shadow: 0 1px 8px 0 rgba(0, 0, 0, 0.6);
7
+ }
8
+
1
9
  .theme-blog-popover {
2
10
  width: 258px;
3
11
  position: fixed;
@@ -7,7 +15,7 @@
7
15
  box-sizing: border-box;
8
16
  border: 1px solid var(--vp-c-brand-3);
9
17
  border-radius: 6px;
10
- background-color: rgba(var(--bg-gradient-home));
18
+ background-color: var(--vp-c-bg);
11
19
  box-shadow: var(--box-shadow);
12
20
  }
13
21
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/components/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEjD,MAAM,eAAe,GAAG,eAAe,CAAA;AACvC,MAAM,mBAAmB,GAAG,SAAS,CAAA;AACrC,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAEvC,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,MAAM,GAAG,GAAoC,EAAE,CAAA;IAC/C,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1E,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;YAC3C,GAAG,CAAC,MAAM,GAAG,CAAC,IAA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mB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QAClD,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,UAAU,EAAE,CAAA;IACZ,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC1B,CAAC"}
package/dist/index.d.mts CHANGED
@@ -79,7 +79,9 @@ declare namespace Announcement {
79
79
  link: string;
80
80
  content: string;
81
81
  style?: string;
82
- props?: any;
82
+ props?: {
83
+ type: 'primary' | 'success' | 'danger' | 'warning' | 'info' | 'text' | 'default';
84
+ };
83
85
  }
84
86
  type Value = Title | Text | Image | Button;
85
87
  }
package/dist/index.d.ts CHANGED
@@ -79,7 +79,9 @@ declare namespace Announcement {
79
79
  link: string;
80
80
  content: string;
81
81
  style?: string;
82
- props?: any;
82
+ props?: {
83
+ type: 'primary' | 'success' | 'danger' | 'warning' | 'info' | 'text' | 'default';
84
+ };
83
85
  }
84
86
  type Value = Title | Text | Image | Button;
85
87
  }
package/dist/index.js CHANGED
@@ -89,7 +89,7 @@ import Announcement from './Announcement.vue'`);
89
89
  },
90
90
  load(id) {
91
91
  if (id === resolvedVirtualModuleId) {
92
- return `export default ${(0, import_javascript_stringify.stringify)(options)}`;
92
+ return `export default ${(0, import_javascript_stringify.stringify)(componentOptions)}`;
93
93
  }
94
94
  }
95
95
  };
package/dist/index.mjs CHANGED
@@ -54,7 +54,7 @@ import Announcement from './Announcement.vue'`);
54
54
  },
55
55
  load(id) {
56
56
  if (id === resolvedVirtualModuleId) {
57
- return `export default ${stringify(options)}`;
57
+ return `export default ${stringify(componentOptions)}`;
58
58
  }
59
59
  }
60
60
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitepress-plugin-announcement",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "vitepress plugin, Announcement, 公告窗口",
5
5
  "author": "sugar",
6
6
  "license": "MIT",