@sugarat/theme 0.5.11 → 0.5.12-beta.1

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.
Files changed (49) hide show
  1. package/node.d.ts +2 -4
  2. package/node.js +206 -156
  3. package/node.mjs +205 -154
  4. package/package.json +10 -15
  5. package/src/components/Alert.vue +269 -0
  6. package/src/components/Avatar.vue +65 -0
  7. package/src/components/BlogAlert.vue +8 -8
  8. package/src/components/BlogApp.vue +5 -8
  9. package/src/components/BlogArticleAnalyze.vue +99 -66
  10. package/src/components/BlogAuthor.vue +13 -15
  11. package/src/components/BlogBackToTop.vue +21 -24
  12. package/src/components/BlogButtonAfterArticle.vue +12 -15
  13. package/src/components/BlogCommentWrapper.vue +34 -41
  14. package/src/components/BlogDocCover.vue +1 -1
  15. package/src/components/BlogFooter.vue +26 -32
  16. package/src/components/BlogFriendLink.vue +91 -73
  17. package/src/components/BlogHomeBanner.vue +25 -31
  18. package/src/components/BlogHomeHeaderAvatar.vue +16 -23
  19. package/src/components/BlogHomeInfo.vue +2 -4
  20. package/src/components/BlogHomeOverview.vue +12 -15
  21. package/src/components/BlogHomeTags.vue +22 -31
  22. package/src/components/BlogHotArticle.vue +69 -80
  23. package/src/components/BlogImagePreview.vue +3 -3
  24. package/src/components/BlogItem.vue +14 -23
  25. package/src/components/BlogList.vue +15 -19
  26. package/src/components/BlogRecommendArticle.vue +56 -72
  27. package/src/components/BlogSidebar.vue +1 -1
  28. package/src/components/Button.vue +150 -0
  29. package/src/components/Carousel.vue +249 -0
  30. package/src/components/CarouselItem.vue +139 -0
  31. package/src/components/CommentArtalk.vue +1 -1
  32. package/src/components/Image.vue +33 -0
  33. package/src/components/ImageViewer.vue +407 -0
  34. package/src/components/Pagination.vue +369 -0
  35. package/src/components/Tag.vue +144 -0
  36. package/src/components/UserWorks.vue +132 -175
  37. package/src/composables/config/blog.ts +6 -1
  38. package/src/composables/config/index.ts +2 -2
  39. package/src/index.ts +12 -19
  40. package/src/node.ts +0 -3
  41. package/src/styles/el-base.css +340 -0
  42. package/src/styles/{index.scss → index.css} +56 -91
  43. package/src/utils/client/index.ts +17 -0
  44. package/src/utils/node/mdPlugins.ts +1 -1
  45. package/src/utils/node/theme.ts +5 -2
  46. package/src/utils/node/vitePlugins.ts +51 -18
  47. package/src/styles/scss/algolia.scss +0 -231
  48. package/src/styles/scss/global.scss +0 -156
  49. package/src/styles/scss/highlight.scss +0 -12
@@ -1,21 +1,19 @@
1
1
  <script lang="ts" setup>
2
- import { ElCarousel, ElCarouselItem, ElImage, ElMessage } from 'element-plus'
3
2
  import VPDocAsideOutline from 'vitepress/dist/client/theme-default/components/VPDocAsideOutline.vue'
4
3
  import { computed, reactive, ref, watch, watchEffect } from 'vue'
5
- import { slugify } from '@mdit-vue/shared'
6
4
  import { useWindowSize } from '@vueuse/core'
7
- import {
8
- formatDate,
9
- getGithubDirUpdateTime,
10
- getGithubUpdateTime
11
- } from '../utils/client'
5
+ import { formatDate, getGithubDirUpdateTime, getGithubUpdateTime, slugify } from '../utils/client'
12
6
  import {
13
7
  useActiveAnchor,
14
8
  useAutoUpdateAnchor,
15
- useUserWorks
9
+ useUserWorks,
16
10
  } from '../composables/config/blog'
17
11
  import type { Theme } from '../composables/config'
12
+ import Carousel from './Carousel.vue'
13
+ import CarouselItem from './CarouselItem.vue'
14
+ import Image from './Image.vue'
18
15
 
16
+ // TODO:作品集组件
19
17
  const currentAnchor = useAutoUpdateAnchor()
20
18
  // 更新锚点的时候更新 url 中的 hash
21
19
  watch(
@@ -165,10 +163,10 @@ watchEffect(() => {
165
163
  const { width } = useWindowSize()
166
164
  const isCardMode = computed(() => width.value > 768)
167
165
  function handleChooseTag(tag: string) {
168
- ElMessage({
169
- message: `点击了${tag}标签,标签过滤功能开发中ing...`,
170
- type: 'warning'
171
- })
166
+ // Message({
167
+ // message: `点击了${tag}标签,标签过滤功能开发中ing...`,
168
+ // type: 'warning',
169
+ // })
172
170
  }
173
171
  </script>
174
172
 
@@ -276,18 +274,17 @@ function handleChooseTag(tag: string) {
276
274
  <div v-if="work.covers?.length" class="images">
277
275
  <!-- swiper -->
278
276
  <div v-if="work.coverLayout === 'swiper'" class="swiper-mode">
279
- <ElCarousel autoplay height="260px" :type="isCardMode && work.covers.length >= 3 ? 'card' : ''">
280
- <ElCarouselItem v-for="(url, idx) in work.covers" :key="url" style="text-align: center">
281
- <ElImage
282
- :key="url" preview-teleported :src="url" loading="lazy" :preview-src-list="work.covers"
283
- :initial-index="idx" hide-on-click-modal :alt="`${work.title}-${idx}`"
277
+ <Carousel autoplay height="260px" :type="isCardMode && work.covers.length >= 3 ? 'card' : ''">
278
+ <CarouselItem v-for="(url) in work.covers" :key="url" style="text-align: center">
279
+ <Image
280
+ :src="url" loading="lazy"
284
281
  />
285
- </ElCarouselItem>
286
- </ElCarousel>
282
+ </CarouselItem>
283
+ </Carousel>
287
284
  </div>
288
285
  <!-- list -->
289
286
  <div v-if="work.coverLayout === 'list'" class="list-mode">
290
- <ElImage
287
+ <Image
291
288
  v-for="(url, idx) in work.covers" :key="url" :src="url" loading="lazy"
292
289
  :preview-src-list="work.covers" :initial-index="idx" hide-on-click-modal
293
290
  />
@@ -304,29 +301,27 @@ function handleChooseTag(tag: string) {
304
301
  </div>
305
302
  </template>
306
303
 
307
- <style lang="scss" scoped>
304
+ <style scoped>
305
+ @charset "UTF-8";
308
306
  .user-works-page {
309
307
  display: flex;
310
308
  justify-content: center;
311
309
  width: 100%;
312
310
  margin: 20px auto;
313
311
  padding: 16px;
314
-
315
- h1 {
316
- font-size: 32px;
317
- font-weight: bold;
318
- }
319
-
320
- .description {
321
- margin-top: 16px;
322
- color: #999;
323
- font-size: 16px;
324
- }
325
-
326
- a {
327
- font-weight: 500;
328
- color: var(--vp-c-brand-1);
329
- }
312
+ }
313
+ .user-works-page h1 {
314
+ font-size: 32px;
315
+ font-weight: bold;
316
+ }
317
+ .user-works-page .description {
318
+ margin-top: 16px;
319
+ color: #999;
320
+ font-size: 16px;
321
+ }
322
+ .user-works-page a {
323
+ font-weight: 500;
324
+ color: var(--vp-c-brand-1);
330
325
  }
331
326
 
332
327
  .works-container {
@@ -336,143 +331,113 @@ function handleChooseTag(tag: string) {
336
331
 
337
332
  .work {
338
333
  max-width: 900px;
339
-
340
- h2 {
341
- margin-top: 6px;
342
- padding-top: 18px;
343
- line-height: 32px;
344
- font-size: 24px;
345
- border-top: 1px solid var(--vp-c-divider);
346
-
347
- a {
348
- color: inherit;
349
- }
350
-
351
- &:hover {
352
- a {
353
- &::before {
354
- opacity: 1;
355
- }
356
- }
357
- }
358
-
359
- a {
360
- position: relative;
361
-
362
- &::before {
363
- position: absolute;
364
- left: -16px;
365
- opacity: 0;
366
- content: var(--vp-header-anchor-symbol);
367
- }
368
- }
369
- }
370
-
371
- h3 {
372
- margin: 32px 0 0;
373
- line-height: 28px;
374
- font-size: 20px;
375
- position: relative;
376
-
377
- &.title>a.pin {
378
- position: absolute;
379
- left: -16px;
380
-
381
- &::before {
382
- left: -16px;
383
- opacity: 0;
384
- content: var(--vp-header-anchor-symbol);
385
- }
386
- }
387
-
388
- &:hover>a.pin {
389
- &::before {
390
- opacity: 1;
391
- }
392
- }
393
- }
394
-
395
- .info {
396
- display: flex;
397
- font-size: 14px;
398
- margin-top: 10px;
399
- flex-wrap: wrap;
400
- }
401
-
402
- .links,
403
- .times,
404
- .tags {
405
- display: flex;
406
- align-items: center;
407
-
408
- .icon {
409
- color: var(--vp-c-text-1);
410
- display: block;
411
- width: 20px;
412
- height: 20px;
413
- margin-right: 6px;
414
- }
415
- }
416
-
417
- .times {
418
- margin-right: 18px;
419
- }
420
-
421
- .links {
422
- a {
423
- display: flex;
424
- align-items: center;
425
- }
426
-
427
- a.github-link {
428
- margin-right: 10px;
429
- }
430
-
431
- a.link {
432
- margin-right: 0;
433
-
434
- &::after {
435
- content: ',';
436
- color: var(--vp-c-text-1);
437
- margin-right: 6px;
438
- margin-left: 2px;
439
- }
440
-
441
- &:last-child::after {
442
- content: '';
443
- }
444
- }
445
- }
446
-
447
- .tags {
448
- span.tag {
449
- cursor: pointer;
450
- }
451
-
452
- span.tag:not(:last-child) {
453
- &::after {
454
- content: '·';
455
- display: inline-block;
456
- padding: 0 4px;
457
- }
458
- }
459
- }
460
334
  }
335
+ .work h2 {
336
+ margin-top: 6px;
337
+ padding-top: 18px;
338
+ line-height: 32px;
339
+ font-size: 24px;
340
+ border-top: 1px solid var(--vp-c-divider);
341
+ }
342
+ .work h2 a {
343
+ color: inherit;
344
+ }
345
+ .work h2:hover a::before {
346
+ opacity: 1;
347
+ }
348
+ .work h2 a {
349
+ position: relative;
350
+ }
351
+ .work h2 a::before {
352
+ position: absolute;
353
+ left: -16px;
354
+ opacity: 0;
355
+ content: var(--vp-header-anchor-symbol);
356
+ }
357
+ .work h3 {
358
+ margin: 32px 0 0;
359
+ line-height: 28px;
360
+ font-size: 20px;
361
+ position: relative;
362
+ }
363
+ .work h3.title > a.pin {
364
+ position: absolute;
365
+ left: -16px;
366
+ }
367
+ .work h3.title > a.pin::before {
368
+ left: -16px;
369
+ opacity: 0;
370
+ content: var(--vp-header-anchor-symbol);
371
+ }
372
+ .work h3:hover > a.pin::before {
373
+ opacity: 1;
374
+ }
375
+ .work .info {
376
+ display: flex;
377
+ font-size: 14px;
378
+ margin-top: 10px;
379
+ flex-wrap: wrap;
380
+ }
381
+ .work .links,
382
+ .work .times,
383
+ .work .tags {
384
+ display: flex;
385
+ align-items: center;
386
+ }
387
+ .work .links .icon,
388
+ .work .times .icon,
389
+ .work .tags .icon {
390
+ color: var(--vp-c-text-1);
391
+ display: block;
392
+ width: 20px;
393
+ height: 20px;
394
+ margin-right: 6px;
395
+ }
396
+ .work .times {
397
+ margin-right: 18px;
398
+ }
399
+ .work .links a {
400
+ display: flex;
401
+ align-items: center;
402
+ }
403
+ .work .links a.github-link {
404
+ margin-right: 10px;
405
+ }
406
+ .work .links a.link {
407
+ margin-right: 0;
408
+ }
409
+ .work .links a.link::after {
410
+ content: ",";
411
+ color: var(--vp-c-text-1);
412
+ margin-right: 6px;
413
+ margin-left: 2px;
414
+ }
415
+ .work .links a.link:last-child::after {
416
+ content: "";
417
+ }
418
+ .work .tags span.tag {
419
+ cursor: pointer;
420
+ }
421
+ .work .tags span.tag:not(:last-child)::after {
422
+ content: "·";
423
+ display: inline-block;
424
+ padding: 0 4px;
425
+ }
426
+
461
427
  .works {
462
428
  flex: 1;
463
429
  }
430
+
464
431
  @media (min-width: 1440px) {
465
432
  .works {
466
433
  max-width: 784px;
467
434
  }
468
435
  }
469
-
470
436
  @media (min-width: 960px) {
471
437
  .works {
472
438
  max-width: 752px;
473
439
  }
474
440
  }
475
-
476
441
  .aside-container {
477
442
  display: none;
478
443
  flex: 1;
@@ -486,7 +451,6 @@ function handleChooseTag(tag: string) {
486
451
  display: block;
487
452
  }
488
453
  }
489
-
490
454
  .aside-outline-container {
491
455
  position: sticky;
492
456
  top: calc(var(--vp-nav-height) + var(--vp-layout-top-height, 0px) + var(--vp-doc-top-height, 0px) + 32px);
@@ -503,24 +467,17 @@ function handleChooseTag(tag: string) {
503
467
  display: flex;
504
468
  flex-wrap: wrap;
505
469
  justify-content: center;
506
-
507
- .el-image {
508
- :deep(img) {
509
- object-fit: contain;
510
- // max-height: 360px;
511
- }
512
- }
470
+ }
471
+ .list-mode .sugar-image :deep(img) {
472
+ object-fit: contain;
513
473
  }
514
474
 
515
475
  .swiper-mode {
516
476
  margin-top: 16px;
517
-
518
- .el-image {
519
- :deep(img) {
520
- object-fit: contain;
521
- max-height: 260px;
522
- }
523
- }
477
+ }
478
+ .swiper-mode .sugar-image :deep(img) {
479
+ object-fit: contain;
480
+ max-height: 260px;
524
481
  }
525
482
 
526
483
  .split {
@@ -262,7 +262,12 @@ export function useActiveAnchor() {
262
262
  onMounted(() => {
263
263
  const { hash } = window.location
264
264
  if (hash) {
265
- el.value = document.querySelector(decodeURIComponent(hash)) as any
265
+ try {
266
+ el.value = document.querySelector(decodeURIComponent(hash)) as any
267
+ }
268
+ catch (error) {
269
+ console.warn('useActiveAnchor error', error)
270
+ }
266
271
  }
267
272
  })
268
273
  return el
@@ -272,7 +272,7 @@ export namespace Theme {
272
272
  tag?: string
273
273
  }
274
274
  export interface Alert {
275
- type: 'success' | 'warning' | 'info' | 'error'
275
+ type: 'success' | 'warning' | 'info' | 'error' | 'primary'
276
276
  /**
277
277
  * 细粒度的时间控制
278
278
  * 默认展示时间,-1 只展示1次,其它数字为每次都展示,一定时间后自动消失,0为不自动消失
@@ -424,7 +424,7 @@ export namespace Theme {
424
424
  authorList?: Omit<FriendLink, 'avatar'>[]
425
425
  /**
426
426
  * 启用 [vitepress-plugin-tabs](https://www.npmjs.com/package/vitepress-plugin-tabs)
427
- * @default false
427
+ * @default true
428
428
  */
429
429
  tabs?: boolean
430
430
  works?: UserWorks
package/src/index.ts CHANGED
@@ -1,27 +1,18 @@
1
1
  // @sugarat/theme index
2
2
  // override style
3
- import './styles/index.scss'
4
-
5
- // element-ui
6
- // import 'element-plus/dist/index.css'
7
- import 'element-plus/theme-chalk/base.css'
8
- import 'element-plus/theme-chalk/el-button.css'
9
- import 'element-plus/theme-chalk/el-tag.css'
10
- import 'element-plus/theme-chalk/el-icon.css'
11
- import 'element-plus/theme-chalk/el-avatar.css'
12
- import 'element-plus/theme-chalk/el-image.css'
13
- import 'element-plus/theme-chalk/el-image-viewer.css'
14
- import 'element-plus/theme-chalk/el-pagination.css'
15
- import 'element-plus/theme-chalk/el-carousel.css'
16
- import 'element-plus/theme-chalk/el-carousel-item.css'
17
- import 'element-plus/theme-chalk/el-alert.css'
18
- import 'element-plus/theme-chalk/dark/css-vars.css'
3
+ import './styles/index.css'
4
+
5
+ // element-ui-copy
6
+ import './styles/el-base.css'
19
7
 
20
8
  // 引入时间线组件样式
21
- import 'vitepress-markdown-timeline/dist/theme/index.css'
9
+ // replace-timeline-import-code
10
+ // import 'vitepress-markdown-timeline/dist/theme/index.css'
22
11
  import type { Theme } from 'vitepress'
23
12
  import DefaultTheme from 'vitepress/theme'
24
- import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
13
+
14
+ // replace-tabs-import-code
15
+ // import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
25
16
 
26
17
  // 图表渲染组件
27
18
  // replace-mermaid-import-code
@@ -36,13 +27,15 @@ import UserWorksPage from './components/UserWorks.vue'
36
27
  import './styles/theme/inline-theme.var.css'
37
28
 
38
29
  // 导入group icons,改由自定义插件导入
30
+ // replace-group-icon-import-code
39
31
  // import 'virtual:group-icons.css'
40
32
 
41
33
  export const BlogTheme: Theme = {
42
34
  ...DefaultTheme,
43
35
  Layout: withConfigProvider(BlogApp),
44
36
  enhanceApp(ctx) {
45
- enhanceAppWithTabs(ctx.app as any)
37
+ // replace-tabs-enhance-app-code
38
+ // enhanceAppWithTabs(ctx.app)
46
39
  DefaultTheme.enhanceApp(ctx)
47
40
  ctx.app.component('UserWorksPage', UserWorksPage as any)
48
41
  // replace-mermaid-mounted-code
package/src/node.ts CHANGED
@@ -80,9 +80,6 @@ export function defineLocaleConfig(cfg: Omit<Theme.BlogConfig, 'locales' | 'page
80
80
  return cfg
81
81
  }
82
82
 
83
- // 重新导包 tabsMarkdownPlugin 导出CJS格式支持
84
- export { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
85
-
86
83
  export function footerHTML(footerData: Theme.FooterItem | Theme.FooterItem[]) {
87
84
  const data = [footerData || []].flat()
88
85
  return data.map((d) => {