valaxy-theme-yun 0.21.0 → 0.22.0

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/App.vue CHANGED
@@ -61,7 +61,7 @@ const isDev = import.meta.env.DEV
61
61
  <YunPageHeaderGradient />
62
62
  <YunNavMenu />
63
63
 
64
- <YunFullscreenMenu v-if="yun.isNimbo" />
64
+ <YunFullscreenMenu v-if="yun.isNimbo && !yun.size.isLg" />
65
65
  <YunStratoSidebar v-if="yun.isStrato" />
66
66
 
67
67
  <YunFireworks v-if="themeConfig.fireworks.enable" />
@@ -5,11 +5,15 @@ import { onClickHref, onContentUpdated, scrollTo, usePostTitle, useSiteConfig }
5
5
  import { computed, nextTick } from 'vue'
6
6
  import { useRoute, useRouter } from 'vue-router'
7
7
  import { usePostProperty } from '../composables'
8
+ import { useYunAppStore } from '../stores'
8
9
 
9
10
  const props = defineProps<{
10
11
  frontmatter: Post
11
12
  data?: PageData
12
13
  }>()
14
+
15
+ const yun = useYunAppStore()
16
+
13
17
  const siteConfig = useSiteConfig()
14
18
 
15
19
  const { styles, icon, color } = usePostProperty(props.frontmatter.type)
@@ -91,6 +95,8 @@ onContentUpdated(() => {
91
95
  <YunComment :class="frontmatter.nav === false ? 'mt-4' : 0" />
92
96
  </slot>
93
97
 
98
+ <YunAdBoard v-if="!yun.size.isLg" class="mt-4" />
99
+
94
100
  <slot name="main-footer-before" />
95
101
  <slot name="main-footer-after" />
96
102
  </div>
@@ -53,7 +53,7 @@ onMounted(async () => {
53
53
  </script>
54
54
 
55
55
  <template>
56
- <div id="yun-banner" :style="bannerStyles">
56
+ <div id="yun-banner" border="b-1px b-solid b-$banner-line-color" :style="bannerStyles">
57
57
  <div class="banner-line-container">
58
58
  <div
59
59
  class="banner-line vertical-line-top"
@@ -14,27 +14,26 @@ const app = useAppStore()
14
14
  <div
15
15
  v-if="yunApp.fullscreenMenu.isOpen"
16
16
  ref="fullscreenMenuRef"
17
- p="t-20 md:t-26"
18
- class="yun-fullscreen-menu fixed left-0 right-0 bottom-0 top-0 bg-$va-c-bg-soft z-$yun-z-fullscreen-menu overflow-auto"
17
+ p="t-12 md:t-20"
18
+ class="yun-fullscreen-menu fixed left-0 right-0 bottom-0 top-0 bg-$va-c-bg-soft z-$yun-z-fullscreen-menu overflow-auto max-w-md shadow-2xl"
19
19
  >
20
20
  <!-- <div v-if="app.isMobile" class="flex-center gap-2">
21
21
  <YunToggleDark transition />
22
22
  <YunToggleLocale v-if="app.showToggleLocale" />
23
23
  </div> -->
24
24
 
25
- <div v-if="!yunApp.size.isLg" class="my-4">
26
- <YunSiteInfo class="text-center" />
25
+ <!-- <YunFullscreenMenuList /> -->
26
+ <YunSiteInfo class="text-center" />
27
+ <YunGradientDivider class="my-2 op-20" />
28
+ <YunPostsInfo />
29
+ <YunGradientDivider class="my-2 op-20" />
30
+ <YunSocialLinks />
31
+ <YunGradientDivider class="my-2 op-20" />
32
+ <YunSidebarLinks />
27
33
 
28
- <YunGradientDivider class="my-2 op-20" />
29
-
30
- <YunPostsInfo />
31
- </div>
32
34
  <YunGradientDivider v-if="!yunApp.size.isLg" class="my-2 op-20" />
33
35
 
34
- <YunFullscreenMenuList />
35
-
36
- <YunGradientDivider v-if="!yunApp.size.isLg" class="my-2 op-20" />
37
- <div v-if="!yunApp.size.isLg" class="flex-center">
36
+ <div class="flex-center">
38
37
  <YunConfig />
39
38
  </div>
40
39
  </div>
@@ -50,7 +49,7 @@ const app = useAppStore()
50
49
  .slide-down-enter-active,
51
50
  .slide-down-leave-active {
52
51
  opacity: 1;
53
- transition: transform 0.4s map.get($cubic-bezier, 'ease-in-out'),
52
+ transition: transform 0.3s map.get($cubic-bezier, 'ease-in-out'),
54
53
  opacity 0.2s map.get($cubic-bezier, 'ease-in-out');
55
54
  transform: translateY(0);
56
55
  }
@@ -1,27 +1,35 @@
1
1
  <script lang="ts" setup>
2
- import { differenceInMilliseconds, formatDistanceToNow } from 'date-fns'
2
+ import dayjs from 'dayjs'
3
+
4
+ import relativeTime from 'dayjs/plugin/relativeTime'
3
5
  import { useFrontmatter } from 'valaxy'
4
6
 
5
- import { computed, ref, watch } from 'vue'
7
+ import { computed } from 'vue'
6
8
  import { useI18n } from 'vue-i18n'
7
9
 
10
+ dayjs.extend(relativeTime)
11
+
8
12
  const fm = useFrontmatter()
9
- const { t, locale } = useI18n()
13
+ const { t } = useI18n()
10
14
 
11
- const updated = computed(() => fm.value.updated || fm.value.date || new Date())
12
- const ago = ref('')
15
+ const updated = computed(() => {
16
+ return dayjs(fm.value.updated || fm.value.date)
17
+ })
13
18
 
14
- watch(locale, () => {
15
- const fromNow = formatDistanceToNow(updated.value, { addSuffix: true })
16
- ago.value = /^\d/.test(fromNow) ? ` ${fromNow}` : fromNow
17
- }, { immediate: true })
19
+ const ago = computed(() => {
20
+ const fromNow = updated.value.fromNow()
21
+ if (/^\d/.test(fromNow))
22
+ return ` ${fromNow}`
23
+ else
24
+ return fromNow
25
+ })
18
26
 
19
27
  /**
20
28
  * when the post is updated more than 180 days ago, show a warning
21
29
  * default 180 days, you can set `time_warning` in frontmatter to change it
22
30
  */
23
31
  const time_warning = computed(() => {
24
- const diff = differenceInMilliseconds(new Date(), updated.value)
32
+ const diff = dayjs().valueOf() - updated.value.valueOf()
25
33
  /**
26
34
  * if `time_warning` is a number, compare the time difference
27
35
  * if `time_warning` is a boolean, show warning by flag
@@ -1,5 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Post } from 'valaxy'
3
+ import { computed, ref } from 'vue'
3
4
  import { useI18n } from 'vue-i18n'
4
5
  import { usePostProperty } from '../composables'
5
6
 
@@ -9,7 +10,15 @@ const props = defineProps<{
9
10
 
10
11
  const { t } = useI18n()
11
12
 
12
- const { icon, styles } = usePostProperty(props.post.type)
13
+ const { icon, styles, color } = usePostProperty(props.post.type)
14
+
15
+ const gradientClasses = ref('bg-gradient-to-r gradient-text from-$va-c-primary to-$va-c-primary-lighter')
16
+ const postTitleClass = computed(() => {
17
+ if (color) {
18
+ return ''
19
+ }
20
+ return props.post.postTitleClass || gradientClasses.value
21
+ })
13
22
  </script>
14
23
 
15
24
  <template>
@@ -35,9 +44,12 @@ const { icon, styles } = usePostProperty(props.post.type)
35
44
  class="post-title-link cursor-pointer"
36
45
  :to="post.path || ''"
37
46
  m="t-3"
38
- :class="post.postTitleClass"
47
+ :class="postTitleClass"
39
48
  >
40
- <div class="flex-center title text-2xl" text="center" font="serif black">
49
+ <div
50
+ class="flex-center title text-2xl"
51
+ text="center" font="serif black"
52
+ >
41
53
  <div v-if="post.type" class="inline-flex" m="r-1" :class="icon" />
42
54
  <span>{{ post.title }}</span>
43
55
  </div>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Post } from 'valaxy'
3
- import { formatDate, sortByDate, useSiteConfig } from 'valaxy'
3
+ import { formatDate, sortByDate } from 'valaxy'
4
4
  import { computed, ref, watch } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
 
@@ -13,8 +13,6 @@ const { t } = useI18n()
13
13
  const years = ref<number[]>([])
14
14
  const postListByYear = ref<Record<string, Post[]>>({})
15
15
 
16
- const siteConfig = useSiteConfig()
17
-
18
16
  watch(() => props.posts, () => {
19
17
  postListByYear.value = {}
20
18
  years.value = []
@@ -22,7 +20,9 @@ watch(() => props.posts, () => {
22
20
  if (post.hide && post.hide !== 'index')
23
21
  return
24
22
  if (post.date) {
25
- const year = Number.parseInt(formatDate(post.date, 'yyyy', siteConfig.value.timezone))
23
+ const year = Number.parseInt(formatDate(post.date, {
24
+ template: 'YYYY',
25
+ }))
26
26
  if (postListByYear.value[year]) {
27
27
  postListByYear.value[year].push(post)
28
28
  }
@@ -41,7 +41,9 @@ useMotion(itemRef, {
41
41
  >
42
42
  <div class="post-meta">
43
43
  <time v-if="post.date" class="post-time" font="mono" opacity="80">{{
44
- formatDate(post.date, 'MM-dd') }}
44
+ formatDate(post.date, {
45
+ template: 'MM-DD',
46
+ }) }}
45
47
  </time>
46
48
  </div>
47
49
  <h2 class="post-title w-full" inline-flex items-center font="serif black">
@@ -1,22 +1,17 @@
1
1
  <script setup lang="ts">
2
- import { useRouter } from 'vue-router'
3
-
4
2
  defineProps<{
5
3
  icon: string
6
4
  to?: string
7
5
  }>()
8
-
9
- const router = useRouter()
10
6
  </script>
11
7
 
12
8
  <template>
13
- <div
14
- class="size-12 inline-flex-center cursor-pointer z-$yun-z-nav-menu"
15
- text="$va-c-text"
9
+ <AppLink
10
+ class="size-12 inline-flex-center cursor-pointer z-$yun-z-nav-menu text-$va-c-text"
16
11
  hover="bg-white/80 dark:bg-black/80 op-100"
17
12
  op-80
18
- @click="to && router.push(to)"
13
+ :to="to"
19
14
  >
20
15
  <div class="size-6" :class="icon" />
21
- </div>
16
+ </AppLink>
22
17
  </template>
@@ -6,7 +6,7 @@ import { useRouter } from 'vue-router'
6
6
  const router = useRouter()
7
7
  const siteConfig = useSiteConfig()
8
8
 
9
- const classes = ref('site-name clip text-lg leading-loose bg-gradient-to-r gradient-text from-#1e3c72 to-dark dark:(from-#66a6ff to-blue-500)')
9
+ const classes = ref('site-name text-lg leading-loose bg-gradient-to-r gradient-text from-#1e3c72 to-dark dark:(from-#66a6ff to-blue-500)')
10
10
  </script>
11
11
 
12
12
  <template>
@@ -48,7 +48,7 @@ const app = useAppStore()
48
48
  <!-- -->
49
49
  <div class="inline-flex justify-start items-center flex-1">
50
50
  <ValaxyHamburger
51
- v-if="!yunApp.size.isMd"
51
+ v-if="!yunApp.size.isLg"
52
52
  :active="yunApp.fullscreenMenu.isOpen"
53
53
  class="menu-btn sidebar-toggle leading-4 size-12"
54
54
  inline-flex cursor="pointer"
@@ -57,7 +57,7 @@ const app = useAppStore()
57
57
  @click="yunApp.fullscreenMenu.toggle()"
58
58
  />
59
59
  <YunNavMenuItem icon="i-ri-home-4-line" to="/" />
60
- <template v-if="yunApp.size.isMd">
60
+ <template v-if="yunApp.size.isLg">
61
61
  <YunNavMenuItem
62
62
  icon="i-ri-article-line" to="/posts/"
63
63
  title="博客文章"
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import { defineWebPage, useSchemaOrg } from '@unhead/schema-org'
3
- import { useFrontmatter, usePostTitle, useRuntimeConfig } from 'valaxy'
3
+ import { useEncryptedPhotos, useFrontmatter, usePostTitle, useRuntimeConfig } from 'valaxy'
4
4
  import { computed, defineAsyncComponent } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
  import { useRouter } from 'vue-router'
@@ -26,6 +26,8 @@ const runtimeConfig = useRuntimeConfig()
26
26
  const YunGallery = runtimeConfig.value.addons['valaxy-addon-lightgallery']
27
27
  ? defineAsyncComponent(() => import('../components/YunGallery.vue'))
28
28
  : () => null
29
+
30
+ const encryptedPhotos = useEncryptedPhotos()
29
31
  </script>
30
32
 
31
33
  <template>
@@ -51,7 +53,7 @@ const YunGallery = runtimeConfig.value.addons['valaxy-addon-lightgallery']
51
53
  <div i-ri-arrow-go-back-line />
52
54
  </a>
53
55
  </div>
54
- <ValaxyGalleryDecrypt v-if="frontmatter.encryptedPhotos" :encrypted-photos="frontmatter.encryptedPhotos" />
56
+ <ValaxyGalleryDecrypt v-if="encryptedPhotos" :encrypted-photos="encryptedPhotos" />
55
57
  <YunGallery v-else :photos="photos" />
56
58
  <RouterView />
57
59
  </template>
package/layouts/post.vue CHANGED
@@ -2,7 +2,7 @@
2
2
  import type { Article } from '@unhead/schema-org'
3
3
  import { defineArticle, useSchemaOrg } from '@unhead/schema-org'
4
4
 
5
- import { toDate } from 'date-fns'
5
+ import dayjs from 'dayjs'
6
6
  import { useFrontmatter, useFullUrl, useSiteConfig } from 'valaxy'
7
7
  import { computed } from 'vue'
8
8
 
@@ -27,8 +27,8 @@ const article: Article = {
27
27
  url: siteConfig.value.author.link,
28
28
  },
29
29
  ],
30
- 'datePublished': toDate(frontmatter.value.date || ''),
31
- 'dateModified': toDate(frontmatter.value.updated || ''),
30
+ 'datePublished': dayjs(frontmatter.value.date || '').toDate(),
31
+ 'dateModified': dayjs(frontmatter.value.updated || '').toDate(),
32
32
  }
33
33
 
34
34
  const image = frontmatter.value.image || frontmatter.value.cover
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
3
  "type": "module",
4
- "version": "0.21.0",
4
+ "version": "0.22.0",
5
5
  "author": {
6
6
  "email": "me@yunyoujun.cn",
7
7
  "name": "YunYouJun",
@@ -23,8 +23,8 @@
23
23
  "dependencies": {
24
24
  "@ctrl/tinycolor": "^4.1.0",
25
25
  "@explosions/fireworks": "^0.1.0",
26
- "@iconify-json/ant-design": "^1.2.3",
27
- "@iconify-json/simple-icons": "^1.2.15",
26
+ "@iconify-json/ant-design": "^1.2.5",
27
+ "@iconify-json/simple-icons": "^1.2.16",
28
28
  "@vueuse/motion": "^2.2.6",
29
29
  "animejs": "^3.2.2",
30
30
  "gsap": "^3.12.5",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/animejs": "^3.1.12",
35
- "valaxy-addon-waline": "0.2.0",
36
- "valaxy": "0.21.0"
35
+ "valaxy": "0.22.0",
36
+ "valaxy-addon-waline": "0.2.0"
37
37
  },
38
38
  "scripts": {
39
39
  "release": "bumpp && pnpm publish"
package/utils/index.ts CHANGED
@@ -14,9 +14,11 @@ export function onImgError(e: Event, defaultImg = noneImg) {
14
14
  }
15
15
 
16
16
  /**
17
- * date-fns format date with 'yyyy-MM-dd HH:mm:ss'
17
+ * date-fns format date with 'YYYY-MM-DD HH:mm:ss'
18
18
  * @param date
19
19
  */
20
20
  export function formatTimestamp(date: string | number | Date): string {
21
- return formatDate(date, 'yyyy-MM-dd HH:mm:ss')
21
+ return formatDate(date, {
22
+ template: 'YYYY-MM-DD HH:mm:ss',
23
+ })
22
24
  }