valaxy-theme-yun 0.18.8 → 0.18.10

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.
@@ -1,10 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, nextTick } from 'vue'
3
3
  import type { PageData, Post } from 'valaxy'
4
- import { onContentUpdated, usePostTitle, useSiteConfig } from 'valaxy'
4
+ import { onClickHref, onContentUpdated, scrollTo, usePostTitle, useSiteConfig } from 'valaxy'
5
5
  import type { StyleValue } from 'vue'
6
6
  import { useRoute, useRouter } from 'vue-router'
7
- import { scrollTo } from '../utils'
8
7
  import { usePostProperty } from '../composables'
9
8
 
10
9
  const props = defineProps<{
@@ -25,48 +24,15 @@ const router = useRouter()
25
24
  nextTick(() => {
26
25
  if (route.hash) {
27
26
  setTimeout(() => {
28
- scrollTo(document.body, route.hash, true)
27
+ scrollTo(document.body, route.hash, {
28
+ smooth: true,
29
+ })
29
30
  }, 0)
30
31
  }
31
32
  })
32
33
 
33
34
  onContentUpdated(() => {
34
- // to extract
35
- // click title scroll
36
- window.addEventListener(
37
- 'click',
38
- async (e) => {
39
- const link = (e.target as Element).closest('a')
40
- if (link) {
41
- const { protocol, hostname, pathname, hash, target } = link
42
- const currentUrl = window.location
43
- const extMatch = pathname.match(/\.\w+$/)
44
- // only intercept inbound links
45
- if (
46
- !e.ctrlKey
47
- && !e.shiftKey
48
- && !e.altKey
49
- && !e.metaKey
50
- && target !== '_blank'
51
- && protocol === currentUrl.protocol
52
- && hostname === currentUrl.hostname
53
- && !(extMatch && extMatch[0] !== '.html')
54
- ) {
55
- if (pathname === currentUrl.pathname) {
56
- e.preventDefault()
57
- // scroll between hash anchors in the same page
58
- if (hash && hash !== currentUrl.hash) {
59
- await router.push({ hash: decodeURIComponent(hash) })
60
-
61
- // use smooth scroll when clicking on header anchor links
62
- scrollTo(link, hash, link.classList.contains('header-anchor'))
63
- }
64
- }
65
- }
66
- }
67
- },
68
- { capture: true },
69
- )
35
+ onClickHref(router)
70
36
  })
71
37
  </script>
72
38
 
@@ -80,8 +46,10 @@ onContentUpdated(() => {
80
46
  <YunPageHeader
81
47
  class="mb-2"
82
48
  :title="title"
83
- :icon="frontmatter.icon || icon" :color="frontmatter.color || color"
49
+ :icon="frontmatter.icon || icon"
50
+ :color="frontmatter.color || color"
84
51
  :cover="frontmatter.cover"
52
+ :page-title-class="frontmatter.pageTitleClass"
85
53
  />
86
54
  </slot>
87
55
  <slot name="main-header-after" />
@@ -1,5 +1,9 @@
1
1
  <script lang="ts" setup>
2
2
  defineProps<{
3
+ pageTitleClass?: string
4
+ /**
5
+ * @deprecated Use `pageTitleClass` instead
6
+ */
3
7
  color?: string
4
8
  icon?: string
5
9
  title?: string
@@ -10,7 +14,9 @@ defineProps<{
10
14
  <header class="post-header" m="t-16 sm:t-6">
11
15
  <h1
12
16
  class="post-title flex-center" p="2" text="2xl center"
13
- font="serif black" :style="`color:${color}`"
17
+ font="serif black"
18
+ :style="`color:${color}`"
19
+ :class="pageTitleClass"
14
20
  >
15
21
  <div v-if="icon" class="icon" m="r-1 t-1px" inline-flex :class="icon" />
16
22
  <span inline-flex class="leading-none">{{ title }}</span>
@@ -31,9 +31,11 @@ const { icon, styles } = usePostProperty(props.post.type)
31
31
  class="post-title-link cursor-pointer"
32
32
  :to="post.path || ''"
33
33
  m="t-3"
34
+ :class="post.postTitleClass"
34
35
  >
35
36
  <div class="flex-center title text-2xl" text="center" font="serif black">
36
- <div v-if="post.type" class="inline-flex" m="r-1" :class="icon" />{{ post.title }}
37
+ <div v-if="post.type" class="inline-flex" m="r-1" :class="icon" />
38
+ <span>{{ post.title }}</span>
37
39
  </div>
38
40
  </AppLink>
39
41
 
@@ -9,7 +9,8 @@ const themeConfig = useThemeConfig()
9
9
  <AppLink
10
10
  v-for="item, i in themeConfig.pages" :key="i"
11
11
  class="link-item yun-icon-btn" inline-flex
12
- :to="item.url" :title="item.name" :style="`color:${item.color}`"
12
+ :to="item.url" :title="item.name"
13
+ :style="`color:${item.color}`"
13
14
  >
14
15
  <div :class="item.icon" class="icon w-8 h-8" />
15
16
  </AppLink>
@@ -28,7 +28,12 @@ const albums = computed(() => frontmatter.value.albums || [])
28
28
  <RouterView v-slot="{ Component }">
29
29
  <component :is="Component">
30
30
  <template #main-header>
31
- <YunPageHeader :title="title || t('title.album')" :icon="frontmatter.icon || 'i-ri-gallery-line'" :color="frontmatter.color" />
31
+ <YunPageHeader
32
+ :title="title || t('title.album')"
33
+ :icon="frontmatter.icon || 'i-ri-gallery-line'"
34
+ :color="frontmatter.color"
35
+ :page-title-class="frontmatter.pageTitleClass"
36
+ />
32
37
  </template>
33
38
  <template #main-content>
34
39
  <div text="center" class="yun-text-light" p="2">
@@ -26,7 +26,12 @@ useSchemaOrg([
26
26
  <RouterView v-slot="{ Component }">
27
27
  <component :is="Component">
28
28
  <template #main-header>
29
- <YunPageHeader :title="title || t('menu.archives')" :icon="frontmatter.icon || 'i-ri-archive-line'" :color="frontmatter.color" />
29
+ <YunPageHeader
30
+ :title="title || t('menu.archives')"
31
+ :icon="frontmatter.icon || 'i-ri-archive-line'"
32
+ :color="frontmatter.color"
33
+ :page-title-class="frontmatter.pageTitleClass"
34
+ />
30
35
  </template>
31
36
  <template #main-content>
32
37
  <RouterView />
@@ -51,6 +51,7 @@ useSchemaOrg([
51
51
  :title="title || t('menu.categories')"
52
52
  :icon="frontmatter.icon || 'i-ri-folder-2-line'"
53
53
  :color="frontmatter.color"
54
+ :page-title-class="frontmatter.pageTitleClass"
54
55
  />
55
56
  </template>
56
57
  <template #main-content>
@@ -41,6 +41,7 @@ const YunGallery = runtimeConfig.value.addons['valaxy-addon-lightgallery']
41
41
  :title="title || t('title.gallery')"
42
42
  :icon="frontmatter.icon || 'i-ri-gallery-line'"
43
43
  :color="frontmatter.color"
44
+ :page-title-class="frontmatter.pageTitleClass"
44
45
  />
45
46
  </template>
46
47
  <template #main-content>
package/layouts/tags.vue CHANGED
@@ -70,6 +70,7 @@ const title = usePostTitle(frontmatter)
70
70
  :title="title || t('menu.tags')"
71
71
  :icon="frontmatter.icon || 'i-ri-tag-line'"
72
72
  :color="frontmatter.color"
73
+ :page-title-class="frontmatter.pageTitleClass"
73
74
  />
74
75
  </template>
75
76
  <template #main-content>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
- "version": "0.18.8",
3
+ "version": "0.18.10",
4
4
  "author": {
5
5
  "email": "me@yunyoujun.cn",
6
6
  "name": "YunYouJun",
@@ -20,12 +20,12 @@
20
20
  "dependencies": {
21
21
  "@explosions/fireworks": "^0.0.2",
22
22
  "@iconify-json/ant-design": "^1.1.16",
23
- "@iconify-json/simple-icons": "^1.1.105",
23
+ "@iconify-json/simple-icons": "^1.1.107",
24
24
  "animejs": "^3.2.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/animejs": "^3.1.12",
28
- "valaxy": "0.18.8",
29
- "valaxy-addon-waline": "0.1.4"
28
+ "valaxy-addon-waline": "0.1.4",
29
+ "valaxy": "0.18.10"
30
30
  }
31
31
  }
package/types/index.d.ts CHANGED
@@ -27,8 +27,21 @@ export namespace YunTheme {
27
27
 
28
28
  export interface Page {
29
29
  name: string
30
+ /**
31
+ * @description:en-US Page URL
32
+ * @description:zh-CN 页面链接
33
+ */
30
34
  url: string
35
+ /**
36
+ * @see https://valaxy.site/guide/features#icones
37
+ * @description:en-US Icon of page
38
+ * @description:zh-CN 页面图标
39
+ */
31
40
  icon: string
41
+ /**
42
+ * @description:en-US Color of icon
43
+ * @description:zh-CN 图标颜色
44
+ */
32
45
  color: string
33
46
  }
34
47
 
package/utils/index.ts CHANGED
@@ -9,35 +9,3 @@ export function onImgError(e: Event, defaultImg = noneImg) {
9
9
  targetEl.setAttribute('data-src', targetEl.src)
10
10
  targetEl.src = defaultImg
11
11
  }
12
-
13
- export function scrollTo(el: HTMLElement, hash: string, smooth = false) {
14
- let target: Element | null = null
15
- try {
16
- target = el.classList.contains('header-anchor')
17
- ? el
18
- : ((decodeURIComponent(hash) && document.querySelector(decodeURIComponent(hash))) || null)
19
- }
20
- catch (e) {
21
- console.warn(e)
22
- }
23
-
24
- if (target) {
25
- const targetPadding = -64
26
- const targetTop
27
- = window.scrollY
28
- + (target as HTMLElement).getBoundingClientRect().top
29
- + targetPadding
30
-
31
- // only smooth scroll if distance is smaller than screen height.
32
- if (!smooth || Math.abs(targetTop - window.scrollY) > window.innerHeight) {
33
- window.scrollTo(0, targetTop)
34
- }
35
- else {
36
- window.scrollTo({
37
- // left: 0,
38
- top: targetTop,
39
- behavior: 'smooth',
40
- })
41
- }
42
- }
43
- }