valaxy-theme-yun 1.0.1 → 1.2.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.
@@ -48,7 +48,10 @@ onContentUpdated(() => {
48
48
  flex="~ col grow"
49
49
  p="lt-md:0"
50
50
  >
51
- <YunCard :cover="frontmatter.cover" m="0" v-bind="styles ? { style: styles } : {}">
51
+ <YunCard
52
+ :cover="frontmatter.cover" :cover-component="frontmatter.coverComponent" :cover-props="frontmatter.coverProps"
53
+ m="0" v-bind="styles ? { style: styles } : {}"
54
+ >
52
55
  <YunPostActions />
53
56
  <div class="mt-8 mb-4">
54
57
  <slot name="main-header">
@@ -91,9 +91,7 @@ function onKeydown(event: KeyboardEvent) {
91
91
  </template>
92
92
 
93
93
  <style lang="scss">
94
- @use 'sass:map';
95
94
  @use 'valaxy/client/styles/mixins/index.scss' as *;
96
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
97
95
 
98
96
  .yun-aside {
99
97
  // Below xl: fixed overlay panel, hidden by default
@@ -107,7 +105,7 @@ function onKeydown(event: KeyboardEvent) {
107
105
  max-height: 100dvh;
108
106
  visibility: hidden;
109
107
  transform: translateX(100%);
110
- transition: transform var(--va-transition-duration-fast) map.get($cubic-bezier, 'ease-in-out'), visibility 0s linear var(--va-transition-duration-fast);
108
+ transition: transform var(--va-transition-duration-fast) var(--yun-ease-in-out), visibility 0s linear var(--va-transition-duration-fast);
111
109
  border-radius: 16px 0 0 16px;
112
110
  box-shadow: -12px 0 40px rgb(0 0 0 / 0.12);
113
111
 
@@ -130,7 +128,7 @@ function onKeydown(event: KeyboardEvent) {
130
128
  &.open {
131
129
  visibility: visible;
132
130
  transform: translateX(0);
133
- transition: transform var(--va-transition-duration-fast) map.get($cubic-bezier, 'ease-in-out'), visibility 0s;
131
+ transition: transform var(--va-transition-duration-fast) var(--yun-ease-in-out), visibility 0s;
134
132
  }
135
133
  }
136
134
 
@@ -45,10 +45,15 @@ onMounted(async () => {
45
45
  // This is needed when navigating back from post to home (SPA navigation)
46
46
  yun.bannerAnimationDone = false
47
47
 
48
- await sleep(500)
48
+ // 减少动态效果时不再等待动画时序,直接进入终态
49
+ const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
50
+
51
+ if (!reducedMotion)
52
+ await sleep(500)
49
53
  lineStatus.value = 'active'
50
54
  if (yun.isNimbo) {
51
- await sleep(themeConfig.value.banner?.duration || 500)
55
+ if (!reducedMotion)
56
+ await sleep(themeConfig.value.banner?.duration || 500)
52
57
  lineStatus.value = 'exit'
53
58
 
54
59
  animationStatus.value = 'prologue'
@@ -94,23 +99,8 @@ onMounted(async () => {
94
99
  @use "../styles/widgets/banner.scss" as *;
95
100
  @use "../styles/modules/prologue.scss" as *;
96
101
 
102
+ // --banner-* color tokens live in styles/css-vars.scss
97
103
  #yun-banner {
98
104
  border-bottom-color: var(--yun-banner-divider-color, var(--banner-line-color));
99
105
  }
100
-
101
- :root {
102
- // banner
103
- --banner-line-color: black;
104
- --banner-char-color: black;
105
- --banner-char-bg-color: rgb(255 255 255 / 0.5);
106
- --banner-char-hover-color: white;
107
- }
108
-
109
- .dark {
110
- // banner
111
- --banner-line-color: white;
112
- --banner-char-color: white;
113
- --banner-char-bg-color: rgb(0 0 0 / 0.5);
114
- --banner-char-hover-color: black;
115
- }
116
106
  </style>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- defineProps<{ cover?: string }>()
2
+ defineProps<{ cover?: string, coverComponent?: string, coverProps?: Record<string, unknown> }>()
3
3
  </script>
4
4
 
5
5
  <template>
@@ -8,7 +8,7 @@ defineProps<{ cover?: string }>()
8
8
  min-h="100px"
9
9
  bg="$va-c-bg-light"
10
10
  >
11
- <YunCover :src="cover" />
11
+ <YunCover :src="cover" :component="coverComponent" :component-props="coverProps" />
12
12
 
13
13
  <div v-if="$slots.header" class="yun-card-header">
14
14
  <header>
@@ -1,16 +1,16 @@
1
- <script lang="ts" setup>
2
- defineProps<{
1
+ <script setup lang="ts">
2
+ withDefaults(defineProps<{
3
3
  src?: string
4
- }>()
4
+ component?: string
5
+ componentProps?: Record<string, unknown>
6
+ alt?: string
7
+ context?: 'card' | 'page'
8
+ }>(), { context: 'page' })
5
9
  </script>
6
10
 
7
11
  <template>
8
- <img
9
- v-if="src"
10
- width="640" height="360"
11
- class="yun-cover object-cover select-none" h="64 md:sm" w="full"
12
- :src="src"
13
- loading="lazy"
14
- alt=""
15
- >
12
+ <ValaxyCover
13
+ class="yun-cover" :class="context === 'page' && 'h-64 md:h-sm'"
14
+ :src="src" :component="component" :component-props="componentProps" :alt="alt" :context="context"
15
+ />
16
16
  </template>
@@ -35,16 +35,13 @@ const yunApp = useYunAppStore()
35
35
  </template>
36
36
 
37
37
  <style lang="scss">
38
- @use 'sass:map';
39
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
40
-
41
38
  .slide-left-enter-active,
42
39
  .slide-left-leave-active,
43
40
  .slide-down-enter-active,
44
41
  .slide-down-leave-active {
45
42
  opacity: 1;
46
- transition: transform var(--va-transition-duration) map.get($cubic-bezier, 'ease-in-out'),
47
- opacity var(--va-transition-duration-fast) map.get($cubic-bezier, 'ease-in-out');
43
+ transition: transform var(--va-transition-duration) var(--yun-ease-in-out),
44
+ opacity var(--va-transition-duration-fast) var(--yun-ease-in-out);
48
45
  transform: translateY(0);
49
46
  }
50
47
 
@@ -151,7 +151,7 @@ function excerpt(text: string = '') {
151
151
  text-align: center;
152
152
  margin: 0;
153
153
  z-index: var(--yun-z-search-popup);
154
- transition: var(--va-transition-duration-fast);
154
+ transition: opacity var(--va-transition-duration-fast);
155
155
  background-color: var(--va-c-bg-opacity);
156
156
  }
157
157
 
@@ -168,7 +168,7 @@ function excerpt(text: string = '') {
168
168
  font-family: var(--va-font-serif);
169
169
  font-weight: 900;
170
170
  text-align: center;
171
- transition: all var(--va-transition-duration-fast);
171
+ transition: border-color var(--va-transition-duration-fast);
172
172
 
173
173
  &:focus {
174
174
  border-color: var(--va-c-text);
@@ -12,6 +12,7 @@ const props = defineProps<{
12
12
  const themeConfig = useThemeConfig()
13
13
  const { t } = useI18n()
14
14
  const { $tO } = useValaxyI18n()
15
+ const hasCover = computed(() => Boolean(props.post.cover || props.post.coverComponent))
15
16
 
16
17
  const { icon, styles, color } = usePostProperty(props.post.type)
17
18
 
@@ -31,19 +32,20 @@ const postTitleClass = computed(() => {
31
32
  <YunCard
32
33
  class="post-card-wrapper w-full hover:scale-102 hover:z-1"
33
34
  mx="4"
34
- :class="post.cover ? 'post-card-image' : 'post-card'"
35
+ :class="hasCover ? 'post-card-image' : 'post-card'"
35
36
  overflow="hidden" v-bind="styles ? { style: styles } : {}"
36
37
  >
37
38
  <!-- Overlay link covers the entire card -->
38
39
  <AppLink class="post-card-overlay" :to="post.path || ''" :aria-label="$tO(post.title)" tabindex="0" />
39
40
 
40
41
  <div class="flex flex-1 of-hidden justify-start items-start post-card-info" w="full">
41
- <img
42
- v-if="post.cover" :src="post.cover" :alt="t('post.cover')" width="320" height="180"
43
- class="post-card-cover cover object-cover object-center md:shadow" loading="lazy"
44
- >
42
+ <YunCover
43
+ v-if="hasCover" :src="post.cover" :alt="t('post.cover')"
44
+ :component="post.coverComponent" :component-props="post.coverProps" context="card"
45
+ class="post-card-cover cover md:shadow"
46
+ />
45
47
 
46
- <div class="post-card-body flex flex-col items-center relative" :class="post.cover && 'post-card-body-with-cover'" w="full">
48
+ <div class="post-card-body flex flex-col items-center relative" :class="hasCover && 'post-card-body-with-cover'" w="full">
47
49
  <AppLink class="post-title-link" :to="post.path || ''" m="t-3" :class="postTitleClass" tabindex="-1">
48
50
  <div class="post-card-title flex-center title text-2xl" text="center" font="serif black">
49
51
  <div v-if="post.type" class="inline-flex" m="r-1" :class="icon" />
@@ -130,6 +132,11 @@ const postTitleClass = computed(() => {
130
132
  }
131
133
  }
132
134
 
135
+ // Component covers own their interactions; the rest of the card remains a link.
136
+ .post-card-cover .valaxy-cover-content {
137
+ z-index: 2;
138
+ }
139
+
133
140
  // Interactive elements float above the overlay while empty action-bar space
134
141
  // remains part of the card's main click target.
135
142
  .post-title-link,
@@ -58,9 +58,6 @@ const { $tO } = useValaxyI18n()
58
58
  </template>
59
59
 
60
60
  <style lang="scss">
61
- @use 'sass:map';
62
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
63
-
64
61
  .post-collapse {
65
62
  .post-header {
66
63
  &::before {
@@ -85,7 +82,7 @@ const { $tO } = useValaxyI18n()
85
82
  width: 0;
86
83
  height: 1px;
87
84
  background-color: rgb(var(--va-c-primary-rgb), 0.3);
88
- transition: width 800ms map.get($cubic-bezier, 'ease-in');
85
+ transition: width 800ms var(--yun-ease-in);
89
86
  }
90
87
 
91
88
  &.show {
@@ -128,7 +125,7 @@ const { $tO } = useValaxyI18n()
128
125
  width: 2px;
129
126
  height: 0;
130
127
  background: rgb(var(--va-c-primary-rgb), 0.3);
131
- transition: height 600ms map.get($cubic-bezier, 'ease-in');
128
+ transition: height 600ms var(--yun-ease-in);
132
129
  }
133
130
 
134
131
  &.show {
@@ -45,8 +45,6 @@ const sponsorBtnTitle = computed(() => {
45
45
  </template>
46
46
 
47
47
  <style lang="scss">
48
- @use 'sass:map';
49
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
50
48
  @use "valaxy/client/styles/mixins/index.scss" as *;
51
49
 
52
50
  .sponsor-button {
@@ -78,7 +76,8 @@ const sponsorBtnTitle = computed(() => {
78
76
  overflow: hidden;
79
77
  height: 0;
80
78
  opacity: 0;
81
- transition: all var(--va-transition-duration) map.get($cubic-bezier, 'ease-in-out');
79
+ transition: height var(--va-transition-duration) var(--yun-ease-in-out),
80
+ opacity var(--va-transition-duration) var(--yun-ease-in-out);
82
81
 
83
82
  &.show {
84
83
  height: var(--height);
@@ -20,16 +20,13 @@ const props = withDefaults(defineProps<{
20
20
  </template>
21
21
 
22
22
  <style lang="scss" scoped>
23
- @use 'sass:map';
24
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
25
-
26
23
  .line {
27
24
  position: absolute;
28
25
  height: 1px;
29
26
  width: 0%;
30
27
  left: 0;
31
28
  background-color: var(--yun-prologue-divider-color, var(--va-c-text));
32
- transition: width 1s map.get($cubic-bezier, 'ease-in');
29
+ transition: width 1s var(--yun-ease-in);
33
30
 
34
31
  &.enter {
35
32
  width: 100%;
@@ -21,9 +21,6 @@ defineProps<{
21
21
  </template>
22
22
 
23
23
  <style lang="scss">
24
- @use 'sass:map';
25
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
26
-
27
24
  .yun-project-link-item {
28
25
  position: relative;
29
26
  background-color: rgb(0 0 0 / 0.05);
@@ -33,7 +30,8 @@ defineProps<{
33
30
  content: '';
34
31
  position: absolute;
35
32
  background-color: var(--c-brand);
36
- transition: all var(--va-transition-duration) map.get($cubic-bezier, 'ease-in');
33
+ transition: height var(--va-transition-duration) var(--yun-ease-in),
34
+ opacity var(--va-transition-duration) var(--yun-ease-in);
37
35
  bottom: 0;
38
36
  left: 0;
39
37
  right: 0;
@@ -44,7 +42,7 @@ defineProps<{
44
42
  content: '';
45
43
  position: absolute;
46
44
  background-color: var(--c-brand);
47
- transition: all var(--va-transition-duration) map.get($cubic-bezier, 'ease-in');
45
+ transition: opacity var(--va-transition-duration) var(--yun-ease-in);
48
46
  inset: 0;
49
47
  opacity: 0.1;
50
48
  z-index: -1;
@@ -22,9 +22,7 @@ onMounted(() => {
22
22
  </template>
23
23
 
24
24
  <style lang="scss">
25
- @use 'sass:map';
26
25
  @use 'valaxy/client/styles/mixins/index.scss' as *;
27
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
28
26
 
29
27
  @include screen('md') {
30
28
  .yun-ae-frame {
@@ -98,7 +96,7 @@ onMounted(() => {
98
96
 
99
97
  .tl, .tr, .bl, .br {
100
98
  position: absolute;
101
- transition: transform var(--va-transition-duration-slow) map.get($cubic-bezier, 'ease-in');
99
+ transition: transform var(--va-transition-duration-slow) var(--yun-ease-in);
102
100
  }
103
101
 
104
102
  .tl {
@@ -106,8 +106,6 @@ const app = useAppStore()
106
106
  </template>
107
107
 
108
108
  <style lang="scss" scoped>
109
- @use 'sass:map';
110
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
111
109
  @use "valaxy/client/styles/mixins/index.scss" as *;
112
110
 
113
111
  .yun-nav-menu {
@@ -126,9 +124,9 @@ const app = useAppStore()
126
124
  align-items: center;
127
125
  justify-content: space-between;
128
126
  height: var(--yun-nav-height, 50px);
129
- transition: background-color var(--va-transition-duration-moderate) map.get($cubic-bezier, 'ease-in'),
130
- backdrop-filter var(--va-transition-duration-moderate) map.get($cubic-bezier, 'ease-in'),
131
- box-shadow var(--va-transition-duration-moderate) map.get($cubic-bezier, 'ease-in');
127
+ transition: background-color var(--va-transition-duration-moderate) var(--yun-ease-in),
128
+ backdrop-filter var(--va-transition-duration-moderate) var(--yun-ease-in),
129
+ box-shadow var(--va-transition-duration-moderate) var(--yun-ease-in);
132
130
 
133
131
  .vt-hamburger-top, .vt-hamburger-middle, .vt-hamburger-bottom {
134
132
  background-color: var(--va-c-text);
@@ -90,12 +90,8 @@ const isHomePage = computed(() => route.meta.layout === 'home')
90
90
  </template>
91
91
 
92
92
  <style lang="scss" scoped>
93
- @use 'sass:map';
94
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
95
-
93
+ // glass background and its transition live on ::before in styles/common/nav.scss
96
94
  .yun-nav-menu {
97
95
  height: var(--yun-nav-height, 50px);
98
- transition: all var(--va-transition-duration-moderate) map.get($cubic-bezier, 'ease-in');
99
-
100
96
  }
101
97
  </style>
@@ -58,9 +58,6 @@ const showOverview = ref(false)
58
58
  </template>
59
59
 
60
60
  <style lang="scss">
61
- @use 'sass:map';
62
- @use 'valaxy-theme-yun/styles/vars.scss' as *;
63
-
64
61
  #yun-left-sidebar {
65
62
  width: calc(100vw - 64px);
66
63
  max-width: var(--va-sidebar-width);
@@ -69,7 +66,7 @@ const showOverview = ref(false)
69
66
  transform: translateX(-100%);
70
67
  transition: box-shadow var(--va-transition-duration),
71
68
  background-color var(--va-transition-duration), opacity var(--va-transition-duration),
72
- transform var(--va-transition-duration) map.get($cubic-bezier, 'ease-in-out') !important;
69
+ transform var(--va-transition-duration) var(--yun-ease-in-out) !important;
73
70
 
74
71
  &.open {
75
72
  transform: translateX(0);
package/layouts/404.vue CHANGED
@@ -1,30 +1,245 @@
1
1
  <script setup lang="ts">
2
- import { useBack } from 'valaxy'
2
+ import { useBack, useFrontmatter } from 'valaxy'
3
+ import { computed, onMounted, ref } from 'vue'
3
4
  import { useI18n } from 'vue-i18n'
5
+ import { useRoute } from 'vue-router'
6
+ import { useThemeConfig } from '../composables'
4
7
 
5
8
  const { t } = useI18n()
6
9
  const { back } = useBack()
10
+ const route = useRoute()
11
+ const frontmatter = useFrontmatter()
12
+ const themeConfig = useThemeConfig()
13
+
14
+ const chars = ['4', '0', '4']
15
+ // 未知路径匹配不到 404.md,frontmatter 为空时用 locale 兜底
16
+ const title = computed(() => frontmatter.value.title || t('not_found.title'))
17
+
18
+ // 静态托管会把所有未知路径都回落到同一份 404.html,SSG 时的路径不可信,挂载后再读取
19
+ const mounted = ref(false)
20
+ onMounted(() => {
21
+ mounted.value = true
22
+ })
23
+ const path = computed(() => mounted.value ? route.fullPath : '')
24
+
25
+ // 预填当前路径,方便定位失效链接
26
+ const issueLink = computed(() => {
27
+ const link = themeConfig.value.notFound?.issueLink
28
+ if (!link || !path.value)
29
+ return ''
30
+ if (link.includes(':path'))
31
+ return link.replace(':path', encodeURIComponent(path.value))
32
+
33
+ const params = new URLSearchParams({
34
+ title: `404: ${path.value}`,
35
+ body: t('not_found.issue_body', { path: path.value }),
36
+ })
37
+ return `${link}${link.includes('?') ? '&' : '?'}${params}`
38
+ })
7
39
  </script>
8
40
 
9
41
  <template>
10
- <main class="va-main w-full h-screen" text="center" flex="~ col" justify="center" items="center">
11
- <div class="not-found" title="404" font="mono">
12
- 404
13
- </div>
42
+ <main class="yun-404 va-main w-full min-h-screen" text="center" flex="~ col" justify="center" items="center">
43
+ <div class="yun-404-line top" />
44
+
45
+ <h1 class="yun-404-code" aria-label="404">
46
+ <span
47
+ v-for="(char, i) in chars" :key="i"
48
+ class="yun-404-char" :style="{ '--char-index': i }"
49
+ aria-hidden="true"
50
+ >{{ char }}</span>
51
+ </h1>
14
52
 
15
- <!-- <RouterView /> -->
53
+ <div class="yun-404-line bottom" />
16
54
 
17
- <div>
18
- <button class="btn rounded-full" p="x-6 y-2" text="sm" m="3 t8" :title="t('button.back')" @click="back">
55
+ <p class="yun-404-title yun-404-fade">
56
+ {{ title }}
57
+ </p>
58
+ <code class="yun-404-path yun-404-fade">{{ path }}</code>
59
+
60
+ <div class="yun-404-actions yun-404-fade" flex="~ wrap" justify="center" items="center" gap="3">
61
+ <button class="btn rounded-full" p="x-6 y-2" text="sm" :title="t('button.back')" @click="back">
19
62
  {{ t('button.back') }}
20
63
  </button>
64
+ <!-- a 元素自带 text 属性,不能用 attributify 的 text="sm" -->
65
+ <a
66
+ v-if="issueLink"
67
+ class="yun-404-report inline-flex items-center gap-1 text-sm"
68
+ :href="issueLink" target="_blank" rel="noopener"
69
+ >
70
+ <div class="yun-404-report-icon" i-ri-github-line />
71
+ {{ t('not_found.report') }}
72
+ </a>
21
73
  </div>
22
74
  </main>
23
75
  </template>
24
76
 
25
77
  <style lang="scss" scoped>
26
- .not-found {
27
- font-size: 10rem;
28
- text-shadow: 0 5px 10px rgb(0 0 0 / .25), 0 20px 20px rgb(0 0 0 / .15);
78
+ @use 'sass:map';
79
+ @use 'valaxy-theme-yun/styles/vars.scss' as *;
80
+
81
+ $ease-in: map.get($cubic-bezier, 'ease-in');
82
+ $line-duration: 0.4s;
83
+ $char-duration: 0.4s;
84
+ $char-stagger: 0.08s;
85
+
86
+ // banner 的颜色变量只在 YunBanner 挂载时存在,这里单独定义
87
+ .yun-404 {
88
+ --yun-404-line-color: var(--va-c-text-3);
89
+ --yun-404-char-size: clamp(4rem, 18vw, 8rem);
90
+
91
+ padding: 2rem 1rem;
92
+ }
93
+
94
+ // 与首页 banner 一致:竖线先延伸,字块再浮现
95
+ .yun-404-line {
96
+ width: 1px;
97
+ height: 0;
98
+ background-color: var(--yun-404-line-color);
99
+ animation: yun-404-extend $line-duration $ease-in forwards;
100
+
101
+ &.top {
102
+ --yun-404-line-height: 12vh;
103
+ }
104
+
105
+ &.bottom {
106
+ --yun-404-line-height: 4vh;
107
+
108
+ animation-delay: calc($line-duration + $char-duration + 2 * $char-stagger);
109
+ }
110
+ }
111
+
112
+ .yun-404-code {
113
+ display: flex;
114
+ margin: 0;
115
+ font-family: var(--va-font-serif);
116
+ font-size: var(--yun-404-char-size);
117
+ font-weight: 900;
118
+ line-height: 1;
119
+ }
120
+
121
+ .yun-404-char {
122
+ padding: 0.08em 0.16em;
123
+ color: var(--va-c-text);
124
+ border: 1px solid var(--yun-404-line-color);
125
+ opacity: 0;
126
+ transition:
127
+ color var(--va-transition-duration) ease-in-out,
128
+ background-color var(--va-transition-duration) ease-in-out;
129
+ animation: yun-404-char-in $char-duration $ease-in forwards;
130
+ animation-delay: calc($line-duration + var(--char-index) * $char-stagger);
131
+
132
+ & + & {
133
+ margin-left: -1px;
134
+ }
135
+
136
+ &:hover {
137
+ color: var(--va-c-bg);
138
+ background-color: var(--va-c-text);
139
+ }
140
+ }
141
+
142
+ .yun-404-fade {
143
+ opacity: 0;
144
+ animation: yun-404-fade-in var(--va-transition-duration-moderate) ease-out forwards;
145
+ animation-delay: calc(2 * $line-duration + $char-duration + 2 * $char-stagger);
146
+ }
147
+
148
+ .yun-404-title {
149
+ margin: 1rem 0 0.25rem;
150
+ font-family: var(--va-font-serif);
151
+ font-size: 1.25rem;
152
+ font-weight: 700;
153
+ letter-spacing: 0.1em;
154
+ }
155
+
156
+ .yun-404-path {
157
+ max-width: 100%;
158
+ min-height: 1.5em;
159
+ overflow-wrap: anywhere;
160
+ font-size: 0.8rem;
161
+ color: var(--va-c-text-3);
162
+ background: none;
163
+ }
164
+
165
+ .yun-404-actions {
166
+ margin-top: 2rem;
167
+ }
168
+
169
+ .yun-404-report {
170
+ padding: 0.5rem 1.25rem;
171
+ color: var(--va-c-text-2);
172
+ border: 1px solid var(--yun-404-line-color);
173
+ border-radius: 9999px;
174
+ transition:
175
+ color var(--va-transition-duration),
176
+ border-color var(--va-transition-duration),
177
+ background-color var(--va-transition-duration);
178
+
179
+ // 胶囊形按钮不用 yun-title-effects,角标会落在圆角外
180
+ &:hover,
181
+ &:focus-visible {
182
+ color: var(--va-c-primary);
183
+ border-color: var(--va-c-primary);
184
+ background-color: rgb(var(--va-c-primary-rgb), 0.08);
185
+ }
186
+
187
+ &:focus-visible {
188
+ outline: 2px solid rgb(var(--va-c-primary-rgb), 0.4);
189
+ outline-offset: 2px;
190
+ }
191
+
192
+ &-icon {
193
+ transition: transform var(--va-transition-duration) $ease-in;
194
+ }
195
+
196
+ &:hover &-icon,
197
+ &:focus-visible &-icon {
198
+ transform: rotate(-12deg) scale(1.15);
199
+ }
200
+ }
201
+
202
+ @keyframes yun-404-extend {
203
+ to {
204
+ height: var(--yun-404-line-height);
205
+ }
206
+ }
207
+
208
+ @keyframes yun-404-char-in {
209
+ from {
210
+ opacity: 0;
211
+ transform: translateY(0.15em);
212
+ }
213
+
214
+ to {
215
+ opacity: 1;
216
+ transform: translateY(0);
217
+ }
218
+ }
219
+
220
+ @keyframes yun-404-fade-in {
221
+ from {
222
+ opacity: 0;
223
+ transform: translateY(0.5rem);
224
+ }
225
+
226
+ to {
227
+ opacity: 1;
228
+ transform: translateY(0);
229
+ }
230
+ }
231
+
232
+ @media (prefers-reduced-motion: reduce) {
233
+ .yun-404-line,
234
+ .yun-404-char,
235
+ .yun-404-fade {
236
+ animation: none;
237
+ opacity: 1;
238
+ }
239
+
240
+ .yun-404-line.top,
241
+ .yun-404-line.bottom {
242
+ height: var(--yun-404-line-height);
243
+ }
29
244
  }
30
245
  </style>
package/locales/en.yml CHANGED
@@ -12,3 +12,11 @@ theme:
12
12
  outlineTitle: On this page
13
13
  closeOutline: Close contents
14
14
  toggleSection: Toggle {title}
15
+
16
+ not_found:
17
+ title: Page not found
18
+ report: Broken link? Report it
19
+ issue_body: |-
20
+ Page not found: {path}
21
+
22
+ Where did you come from (optional):
package/locales/zh-CN.yml CHANGED
@@ -12,3 +12,11 @@ theme:
12
12
  outlineTitle: 本页
13
13
  closeOutline: 关闭目录
14
14
  toggleSection: 展开或收起{title}
15
+
16
+ not_found:
17
+ title: 页面不存在
18
+ report: 链接失效了?反馈一下
19
+ issue_body: |-
20
+ 页面不存在:{path}
21
+
22
+ 从哪里点进来的(可选):
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.2.0",
5
5
  "description": "Default theme (Yun) for Valaxy — a Vite & Vue powered static blog generator",
6
6
  "author": {
7
7
  "email": "me@yunyoujun.cn",
@@ -41,7 +41,7 @@
41
41
  "valaxy-addon-girls": "0.1.0"
42
42
  },
43
43
  "devDependencies": {
44
- "valaxy": "1.0.1",
44
+ "valaxy": "1.2.0",
45
45
  "valaxy-addon-waline": "0.2.1"
46
46
  },
47
47
  "scripts": {
@@ -1,20 +1,17 @@
1
- // cubic-bezier(0.18, 0.66, 0.05, 0.96)
2
- // cubic-bezier(0.77, 0, 0.17, 1.02)
3
-
4
- @use 'sass:map';
5
- @use '../vars.scss' as *;
1
+ // easing tokens --yun-ease-in / --yun-ease-in-out are generated in styles/css-vars.scss
2
+ // from the $cubic-bezier map in styles/vars.scss
6
3
 
7
4
  .transition-cubic-bezier-ease-in {
8
- transition-timing-function: map.get($cubic-bezier, 'ease-in');
5
+ transition-timing-function: var(--yun-ease-in);
9
6
  }
10
7
 
11
8
  .transition-cubic-bezier-ease-in-out {
12
- transition-timing-function: map.get($cubic-bezier, 'ease-in-out');
9
+ transition-timing-function: var(--yun-ease-in-out);
13
10
  }
14
11
 
15
12
  .v-enter-active,
16
13
  .v-leave-active {
17
- transition: opacity var(--va-transition-duration-fast) map.get($cubic-bezier, 'ease-in');
14
+ transition: opacity var(--va-transition-duration-fast) var(--yun-ease-in);
18
15
  }
19
16
 
20
17
  .v-enter-from,
@@ -44,6 +41,8 @@
44
41
  }
45
42
 
46
43
  // title-effects
44
+ // hover 时在左上 / 右下出现直角角标,按元素的矩形边界定位:用在圆角元素上角标会悬在圆角外,
45
+ // 此时再加 `.yun-title-effects-rounded`,让角标继承对应角的圆角(圆角半径 ≤ 角标边长 10px 时完全贴合)
47
46
  .yun-title-effects {
48
47
  position: relative;
49
48
 
@@ -55,7 +54,8 @@
55
54
  height: 10px;
56
55
  opacity: 0;
57
56
  border: 2px solid;
58
- transition: var(--va-transition-duration);
57
+ transition-property: opacity, transform;
58
+ transition-duration: var(--va-transition-duration);
59
59
  transition-timing-function: cubic-bezier(0.17, 0.67, 0.05, 1.29);
60
60
  }
61
61
 
@@ -79,3 +79,28 @@
79
79
  transform: translate3d(0, 0, 0);
80
80
  }
81
81
  }
82
+
83
+ .yun-title-effects-rounded {
84
+ &::before {
85
+ border-top-left-radius: inherit;
86
+ }
87
+
88
+ &::after {
89
+ border-bottom-right-radius: inherit;
90
+ }
91
+ }
92
+
93
+ // 系统开启「减少动态效果」时的全局兜底
94
+ // 清零时长而非 `animation: none`:forwards 动画(如 banner 字块从透明渐显)仍会停在终态,animationend 也照常触发
95
+ @media (prefers-reduced-motion: reduce) {
96
+ *,
97
+ *::before,
98
+ *::after {
99
+ animation-delay: 0s !important;
100
+ animation-duration: 0s !important;
101
+ animation-iteration-count: 1 !important;
102
+ transition-delay: 0s !important;
103
+ transition-duration: 0s !important;
104
+ scroll-behavior: auto !important;
105
+ }
106
+ }
@@ -46,12 +46,6 @@
46
46
  }
47
47
  }
48
48
 
49
- img {
50
- margin: 0.5rem auto;
51
- height: auto;
52
- max-width: min(92%, 800px);
53
- }
54
-
55
49
  p {
56
50
  overflow: unset;
57
51
  }
@@ -126,6 +120,14 @@
126
120
  }
127
121
  }
128
122
 
123
+ // 元素级特异性 (0,0,1),让 markdown 中图片上的工具类(如 `m-0`、`rounded-full`)可以覆盖
124
+ // uno.css 先于主题样式加载,同为 (0,0,1) 的 preflight `img {}` 仍会被这里覆盖
125
+ :where(.markdown-body) img {
126
+ margin: 0.5rem auto;
127
+ height: auto;
128
+ max-width: min(92%, 800px);
129
+ }
130
+
129
131
  @media (width <=767.9px) {
130
132
  .markdown-body {
131
133
  padding: 0.5rem;
@@ -24,12 +24,21 @@
24
24
  @include set-css-var-from-map($common);
25
25
  @include set-css-var-from-map($z-index, "z");
26
26
 
27
+ // easing: --yun-ease-in / --yun-ease-in-out, generated from the $cubic-bezier map
28
+ @include set-css-var-from-map($cubic-bezier);
29
+
27
30
  // z-index
28
31
  --va-z-overlay: var(--yun-z-backdrop);
29
32
  }
30
33
 
31
34
  :root {
32
35
  @include set-css-var-from-map($light);
36
+
37
+ // banner
38
+ --banner-line-color: black;
39
+ --banner-char-color: black;
40
+ --banner-char-bg-color: rgb(255 255 255 / 0.5);
41
+ --banner-char-hover-color: white;
33
42
  }
34
43
 
35
44
  html.dark {
@@ -46,6 +55,21 @@ html.dark {
46
55
  --yun-grid-highlight-color: color-mix(in srgb, var(--va-c-link) 45%, transparent);
47
56
  }
48
57
 
58
+ // banner tokens are global so pages without YunBanner (404, etc.) can use them;
59
+ // `.dark` keeps the same specificity they had in YunBanner.vue
60
+ .dark {
61
+ --banner-line-color: white;
62
+ --banner-char-color: white;
63
+ --banner-char-bg-color: rgb(0 0 0 / 0.5);
64
+ --banner-char-hover-color: black;
65
+
66
+ // soften horizontal dividers on dark backgrounds (values match www.yunyoujun.cn);
67
+ // the banner's opening lines stay white
68
+ --yun-prologue-divider-color: rgb(255 255 255 / 0.14);
69
+ --yun-banner-divider-color: rgb(255 255 255 / 0.09);
70
+ --yun-say-border-color: rgb(255 255 255 / 0.09);
71
+ }
72
+
49
73
  // animation
50
74
  @media screen and (width <= 768px) {
51
75
  :root {
@@ -1,6 +1,3 @@
1
- @use 'sass:map';
2
- @use '../vars.scss' as *;
3
-
4
1
  $banner-animation-duration: 1s;
5
2
  $char-animation-duration: 0.4s;
6
3
 
@@ -55,7 +52,7 @@ $char-animation-duration: 0.4s;
55
52
  animation-name: extend-line;
56
53
  animation-duration: var(--line-animation-duration);
57
54
  animation-fill-mode: forwards;
58
- animation-timing-function: map.get($cubic-bezier, "ease-in");
55
+ animation-timing-function: var(--yun-ease-in);
59
56
  animation-iteration-count: 1;
60
57
  }
61
58
 
@@ -71,7 +68,7 @@ $char-animation-duration: 0.4s;
71
68
 
72
69
  // reverse
73
70
  animation-direction: reverse;
74
- animation-timing-function: map.get($cubic-bezier, "ease-in-out");
71
+ animation-timing-function: var(--yun-ease-in-out);
75
72
  animation-iteration-count: 1;
76
73
  }
77
74
  }
@@ -92,7 +89,8 @@ $char-animation-duration: 0.4s;
92
89
  font-size: var(--banner-char-size, 1rem);
93
90
  background-color: var(--banner-char-bg-color);
94
91
  line-height: 1;
95
- transition: all var(--va-transition-duration) ease-in-out;
92
+ transition: color var(--va-transition-duration) ease-in-out,
93
+ background-color var(--va-transition-duration) ease-in-out;
96
94
  transition-delay: 0s;
97
95
 
98
96
  &:hover {
package/types/index.d.ts CHANGED
@@ -366,6 +366,24 @@ export interface ThemeConfig extends DefaultTheme.Config {
366
366
  * @zh 编辑链接配置,用于「在 GitHub 中打开」等功能
367
367
  */
368
368
  editLink?: EditLink
369
+
370
+ /**
371
+ * @en 404 page
372
+ * @zh 404 页面
373
+ */
374
+ notFound?: NotFound
375
+ }
376
+
377
+ export interface NotFound {
378
+ /**
379
+ * @en Issue link for reporting broken links. The report button is hidden when unset.
380
+ * Use `:path` as placeholder for the encoded missing path; otherwise GitHub-style
381
+ * `title` and `body` query params are appended.
382
+ * @zh 反馈失效链接的 issue 地址,未配置时不显示反馈按钮。
383
+ * 可使用 `:path` 作为(已编码的)当前路径占位符;否则会追加 GitHub 风格的 `title` 与 `body` 参数。
384
+ * @example 'https://github.com/user/repo/issues/new'
385
+ */
386
+ issueLink?: string
369
387
  }
370
388
 
371
389
  export type UserThemeConfig = Partial<ThemeConfig>
package/utils/sidebar.ts CHANGED
@@ -13,10 +13,10 @@ export function resolveYunDocsSidebar(
13
13
  if (!sidebar)
14
14
  return []
15
15
 
16
- const normalizedPath = ensureStartingSlash(path)
16
+ const normalizedPath = ensureStartingSlash(decodePath(path))
17
17
  const matchedPrefix = Object.keys(sidebar)
18
18
  .sort((a, b) => ensureStartingSlash(b).length - ensureStartingSlash(a).length)
19
- .find(prefix => normalizedPath.startsWith(ensureStartingSlash(prefix)))
19
+ .find(prefix => normalizedPath.startsWith(ensureStartingSlash(decodePath(prefix))))
20
20
 
21
21
  if (!matchedPrefix)
22
22
  return []
@@ -57,8 +57,18 @@ function ensureStartingSlash(path: string): string {
57
57
  return path.startsWith('/') ? path : `/${path}`
58
58
  }
59
59
 
60
+ function decodePath(path: string): string {
61
+ try {
62
+ return decodeURI(path)
63
+ }
64
+ catch {
65
+ return path
66
+ }
67
+ }
68
+
69
+ /** `route.path` is percent-encoded while config links are usually raw (`/指南/`). */
60
70
  function normalizePath(path: string): string {
61
- const normalized = ensureStartingSlash(path)
71
+ const normalized = ensureStartingSlash(decodePath(path))
62
72
  .replace(/#.*$/, '')
63
73
  .replace(/(?:index)?\.(?:md|html)$/, '')
64
74
  .replace(/\/+$/, '')
package/valaxy.config.ts CHANGED
@@ -29,7 +29,15 @@ function ThemeVitePlugin(options: ResolvedValaxyOptions<ThemeConfig>): Plugin {
29
29
  '@vueuse/motion',
30
30
  'reka-ui',
31
31
  ],
32
- exclude: ['@docsearch/js'],
32
+ // These optional imports resolve to Valaxy's empty addon module when
33
+ // disabled. Optimizing that fallback on the first post navigation
34
+ // reloads the page before the router can finish navigating.
35
+ exclude: [
36
+ '@docsearch/js',
37
+ 'valaxy-addon-artalk',
38
+ 'valaxy-addon-twikoo',
39
+ 'valaxy-addon-waline',
40
+ ],
33
41
  },
34
42
  }
35
43
  },