valaxy-theme-lolimeow 1.2.0 → 1.2.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.
@@ -1,7 +1,9 @@
1
1
  <script setup lang="ts">
2
+ import { computed } from 'vue'
2
3
  import { useArticleHeaderMeta } from '../../features/article'
3
4
 
4
5
  const {
6
+ frontmatter,
5
7
  title,
6
8
  cover,
7
9
  categories,
@@ -9,14 +11,24 @@ const {
9
11
  publishedDate,
10
12
  infoItems,
11
13
  } = useArticleHeaderMeta()
14
+
15
+ const hasImageCover = computed(() => !!cover.value && !frontmatter.value.coverComponent)
12
16
  </script>
13
17
 
14
18
  <template>
15
19
  <header
16
20
  class="lm-article-header"
17
- :class="{ 'lm-article-header--plain': !cover }"
21
+ :class="{ 'lm-article-header--plain': !hasImageCover }"
18
22
  >
19
- <div v-if="cover" class="lm-article-header__cover">
23
+ <ValaxyCover
24
+ v-if="frontmatter.coverComponent"
25
+ class="lm-article-header__component-cover"
26
+ :src="cover"
27
+ :component="frontmatter.coverComponent"
28
+ :component-props="frontmatter.coverProps"
29
+ context="page"
30
+ />
31
+ <div v-else-if="cover" class="lm-article-header__cover">
20
32
  <LmImage
21
33
  :src="cover"
22
34
  alt=""
@@ -45,14 +57,14 @@ const {
45
57
 
46
58
  <div
47
59
  class="lm-article-header__content"
48
- :class="{ 'lm-article-header__content--plain': !cover }"
60
+ :class="{ 'lm-article-header__content--plain': !hasImageCover }"
49
61
  >
50
- <h1 v-if="!cover" class="lm-article-header__title">
62
+ <h1 v-if="!hasImageCover" class="lm-article-header__title">
51
63
  {{ title }}
52
64
  </h1>
53
65
 
54
66
  <LmArticleMeta
55
- v-if="!cover"
67
+ v-if="!hasImageCover"
56
68
  :published-date="publishedDate"
57
69
  :info-items="infoItems"
58
70
  :categories="categories"
@@ -71,6 +83,10 @@ const {
71
83
  @apply md:pt-24 pt-22;
72
84
  }
73
85
 
86
+ .lm-article-header__component-cover {
87
+ @apply mx-auto mb-6 max-w-3xl;
88
+ }
89
+
74
90
  .lm-article-header__cover {
75
91
  @apply relative overflow-hidden;
76
92
  min-height: 22rem;
@@ -19,6 +19,8 @@ const props = withDefaults(defineProps<{
19
19
  const {
20
20
  title,
21
21
  currentCover: cover,
22
+ coverComponent,
23
+ postCover,
22
24
  dateLabel,
23
25
  displayDate,
24
26
  excerpt,
@@ -36,7 +38,7 @@ const shouldReverse = computed(() => {
36
38
  return isReversed.value
37
39
  })
38
40
 
39
- // 封面统一由 LmImage 渲染;这里透过组件实例同步内部 img 元素引用,
41
+ // 普通图片封面由 LmImage 渲染;这里透过组件实例同步内部 img 元素引用,
40
42
  // 供 usePostCardMediaState 读取加载完成状态与观察视口邻近性。
41
43
  // 组件实例上暴露的 ref 会自动解包,因此 el 直接是元素或 null。
42
44
  const imageWrapper = useTemplateRef<InstanceType<typeof LmImage>>('imageWrapper')
@@ -52,7 +54,7 @@ const {
52
54
  handleImageError,
53
55
  handleImageLoad,
54
56
  } = usePostCardMediaState({
55
- hasMedia,
57
+ hasMedia: computed(() => !coverComponent.value && !!cover.value),
56
58
  cover,
57
59
  imageElement,
58
60
  onCoverFailure: handleCoverError,
@@ -60,8 +62,7 @@ const {
60
62
  </script>
61
63
 
62
64
  <template>
63
- <RouterLink
64
- :to="post.path || ''"
65
+ <article
65
66
  class="lm-post-card"
66
67
  :class="{
67
68
  'lm-post-card--reversed': shouldReverse,
@@ -70,6 +71,16 @@ const {
70
71
  >
71
72
  <div v-if="hasMedia" class="lm-post-card__media">
72
73
  <div class="lm-post-card__media-shape">
74
+ <ValaxyCover
75
+ v-if="coverComponent"
76
+ class="lm-post-card__component-cover"
77
+ :src="postCover"
78
+ :component="coverComponent"
79
+ :component-props="post.coverProps"
80
+ context="card"
81
+ inert
82
+ aria-hidden="true"
83
+ />
73
84
  <div
74
85
  v-if="showLoadingPlaceholder"
75
86
  class="lm-post-card__loading-placeholder"
@@ -77,7 +88,7 @@ const {
77
88
  />
78
89
 
79
90
  <LmImage
80
- v-if="cover"
91
+ v-if="!coverComponent && cover"
81
92
  :key="cover"
82
93
  ref="imageWrapper"
83
94
  :src="cover"
@@ -93,7 +104,9 @@ const {
93
104
  <div class="lm-post-card__content">
94
105
  <LmDate :date="displayDate" :label="dateLabel" />
95
106
  <h2 class="lm-post-card__title">
96
- {{ title }}
107
+ <RouterLink :to="post.path || ''" class="lm-post-card__link">
108
+ {{ title }}
109
+ </RouterLink>
97
110
  </h2>
98
111
 
99
112
  <div v-if="tags.length" class="lm-post-card__tags">
@@ -110,7 +123,7 @@ const {
110
123
  {{ excerpt }}
111
124
  </p>
112
125
  </div>
113
- </RouterLink>
126
+ </article>
114
127
  </template>
115
128
 
116
129
  <style lang="scss" scoped>
@@ -173,6 +186,32 @@ const {
173
186
  }
174
187
  }
175
188
 
189
+ .lm-post-card__link {
190
+ color: inherit;
191
+ text-decoration: none;
192
+
193
+ &::after {
194
+ content: '';
195
+ position: absolute;
196
+ inset: 0;
197
+ z-index: 1;
198
+ }
199
+
200
+ &:focus-visible {
201
+ outline: none;
202
+ }
203
+ }
204
+
205
+ .lm-post-card:has(.lm-post-card__link:focus-visible) {
206
+ outline: 2px solid var(--lm-c-primary-focus-ring);
207
+ outline-offset: 3px;
208
+ }
209
+
210
+ .lm-post-card__component-cover {
211
+ height: 100%;
212
+ aspect-ratio: auto;
213
+ }
214
+
176
215
  .lm-post-card--text-only {
177
216
  grid-template-columns: 1fr;
178
217
  min-height: auto;
@@ -1,15 +1,16 @@
1
1
  <script setup lang="ts">
2
2
  // cspell:ignore waline
3
- import type { WalineOptions } from 'valaxy-addon-waline/types/index.ts'
3
+ import type { LmWalineOptions } from '../../features/comment/waline-options'
4
4
  import { commentCount } from '@waline/client/comment'
5
5
  import { pageviewCount } from '@waline/client/pageview'
6
6
  import { useAddonConfig } from 'valaxy'
7
- import { computed, onBeforeUnmount, onMounted } from 'vue'
7
+ import { computed, defineAsyncComponent, onBeforeUnmount, onMounted } from 'vue'
8
8
  import { useRoute } from 'vue-router'
9
9
 
10
10
  defineProps<{ active: boolean }>()
11
11
 
12
- const waline = useAddonConfig<WalineOptions>('valaxy-addon-waline')
12
+ const WalineClient = defineAsyncComponent(() => import('./LmWalineClient.vue'))
13
+ const waline = useAddonConfig<LmWalineOptions>('valaxy-addon-waline')
13
14
  const route = useRoute()
14
15
  const abortCounts: (() => void)[] = []
15
16
 
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ import type { LmWalineOptions } from '../../features/comment/waline-options'
3
+ import { Waline } from '@waline/client/component'
4
+ import { useAppStore } from 'valaxy'
5
+ import { computed } from 'vue'
6
+ import { useI18n } from 'vue-i18n'
7
+ import { useRoute } from 'vue-router'
8
+ import { resolveWalineClientOptions, resolveWalineEmoji } from '../../features/comment/waline-options'
9
+ // @ts-expect-error Waline 的样式入口是纯 CSS,没有类型声明
10
+ import '@waline/client/style'
11
+
12
+ const props = defineProps<{ options: LmWalineOptions }>()
13
+ const appStore = useAppStore()
14
+ const route = useRoute()
15
+ const { locale } = useI18n()
16
+ const path = computed(() => props.options.path || route.path.replace(/\/$/, ''))
17
+ const emoji = computed(() => resolveWalineEmoji(props.options))
18
+ const clientOptions = computed(() => resolveWalineClientOptions(props.options))
19
+ // 组件未在 props 类型里收录 boolean 形式的 highlighter / imageUploader / texRenderer(运行时支持),这里按组件类型收口。
20
+ const walineProps = computed(() => clientOptions.value as unknown as InstanceType<typeof Waline>['$props'])
21
+ </script>
22
+
23
+ <template>
24
+ <Waline
25
+ v-bind="walineProps"
26
+ :server-u-r-l="clientOptions.serverURL"
27
+ :lang="locale"
28
+ :path="path"
29
+ :dark="appStore.isDark"
30
+ :emoji="emoji"
31
+ />
32
+ </template>
@@ -0,0 +1,30 @@
1
+ import type { WalineInitOptions } from '@waline/client'
2
+
3
+ /** 保留 Valaxy Waline 插件的表情配置语义,其余选项使用主题客户端的类型。 */
4
+ export type LmWalineOptions = Omit<WalineInitOptions, 'emoji' | 'el'> & {
5
+ cdn?: string
6
+ types?: string[]
7
+ emoji?: string[]
8
+ }
9
+
10
+ /** Waline 组件的 emoji 属性只接受表情数组。 */
11
+ type WalineEmojiList = Exclude<WalineInitOptions['emoji'], boolean | undefined>
12
+
13
+ /** 插件的内置表情组与自定义目录可以同时使用;空 types 表示不加载内置组。 */
14
+ export function resolveWalineEmoji({
15
+ cdn = '//unpkg.com/',
16
+ types = ['bilibili', 'qq', 'weibo'],
17
+ emoji = [],
18
+ }: Pick<LmWalineOptions, 'cdn' | 'types' | 'emoji'>): WalineEmojiList {
19
+ return [
20
+ ...types.map(type => `${cdn}@waline/emojis/${type}/`),
21
+ ...emoji.map(url => `${url}/`),
22
+ ] as WalineEmojiList
23
+ }
24
+
25
+ /** 剥离插件独有字段,得到可以直接传给 Waline 组件的选项。 */
26
+ export function resolveWalineClientOptions(options: LmWalineOptions): Omit<LmWalineOptions, 'cdn' | 'types'> {
27
+ // cdn / types 只用于组装表情地址,Waline 组件不接受这两个字段。
28
+ const { cdn: _cdn, types: _types, ...clientOptions } = options
29
+ return clientOptions
30
+ }
@@ -60,9 +60,15 @@ export function usePostCardViewModel(
60
60
 
61
61
  const seed = computed(() => resolvedPost.value.path || `${resolvedPost.value.title || 'post'}-${resolvedIndex.value}`)
62
62
 
63
+ /**
64
+ * 文章自身 Frontmatter 中设置的封面。
65
+ *
66
+ * 主题按配置补充的随机与回退封面属于占位内容,不作为组件封面的底层图片。
67
+ */
68
+ const postCover = computed(() => (resolvedPost.value as Post & { cover?: string }).cover ?? '')
69
+
63
70
  const coverCandidates = computed(() => {
64
71
  // 每组候选从稳定种子命中的位置轮转,保证同一文章顺序稳定且可尝试池内其余地址。
65
- const postCover = (resolvedPost.value as Post & { cover?: string }).cover
66
72
  const { coverRandom, coverApiUrls = [], coverFallback = [] } = postListConfig.value
67
73
  const apiCandidates = coverRandom
68
74
  ? orderBySeed(coverApiUrls, seed.value).map(url => ({
@@ -76,7 +82,7 @@ export function usePostCardViewModel(
76
82
  }))
77
83
 
78
84
  return compactCoverCandidates([
79
- ...(postCover ? [{ source: 'post', url: postCover } as const] : []),
85
+ ...(postCover.value ? [{ source: 'post', url: postCover.value } as const] : []),
80
86
  ...apiCandidates,
81
87
  ...fallbackCandidates,
82
88
  ])
@@ -127,7 +133,8 @@ export function usePostCardViewModel(
127
133
  advanceCoverCandidate()
128
134
  }
129
135
 
130
- const hasMedia = computed(() => !!currentCover.value)
136
+ const coverComponent = computed(() => resolvedPost.value.coverComponent)
137
+ const hasMedia = computed(() => !!coverComponent.value || !!currentCover.value)
131
138
  const isTextOnly = computed(() => !hasMedia.value)
132
139
 
133
140
  const title = computed(() => normalizePostTitle(resolvedPost.value.title))
@@ -158,6 +165,8 @@ export function usePostCardViewModel(
158
165
 
159
166
  return {
160
167
  currentCover,
168
+ coverComponent,
169
+ postCover,
161
170
  dateLabel,
162
171
  displayDate,
163
172
  excerpt,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy-theme-lolimeow",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "author": {
6
6
  "email": "Andreas99514@outlook.com",
7
7
  "name": "Yoyo514",
@@ -43,9 +43,9 @@
43
43
  "valaxy.config.ts"
44
44
  ],
45
45
  "peerDependencies": {
46
- "valaxy": "1.0.0-rc.16",
47
- "vue": "^3.5.41",
48
- "vue-i18n": "^11.4.12",
46
+ "valaxy": "^1.1.0",
47
+ "vue": "^3.5.0",
48
+ "vue-i18n": "^11.0.0",
49
49
  "vue-router": "^5.0.0"
50
50
  },
51
51
  "dependencies": {
@@ -53,12 +53,12 @@
53
53
  "@types/d3-cloud": "1.2.9",
54
54
  "@unhead/vue": "^3.4.2",
55
55
  "@vueuse/core": "^15.0.0",
56
- "@waline/client": "3.4.1",
56
+ "@waline/client": "3.16.0",
57
57
  "d3-cloud": "1.2.9",
58
58
  "tabbable": "^6.5.0"
59
59
  },
60
60
  "devDependencies": {
61
- "valaxy": "1.0.0-rc.16",
61
+ "valaxy": "1.1.0",
62
62
  "valaxy-addon-waline": "^0.2.1"
63
63
  }
64
64
  }
@@ -31,8 +31,7 @@
31
31
  details,
32
32
  figure,
33
33
  iframe,
34
- audio,
35
- .mermaid {
34
+ audio {
36
35
  margin: 1.1rem 0;
37
36
  }
38
37
  }
@@ -8,7 +8,7 @@ html.dark {
8
8
  img,
9
9
  video,
10
10
  iframe,
11
- .mermaid,
11
+ figure.diagram-card,
12
12
  audio {
13
13
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
14
14
  }
@@ -30,3 +30,49 @@
30
30
  scroll-margin-top: 45vh;
31
31
  }
32
32
  }
33
+
34
+ // Reka 将预览传送到正文外,使用独立选择器并保留框架的碰撞检测与高度限制。
35
+ .va-footnote-popover.markdown-body {
36
+ padding: 0.75rem 1rem;
37
+ border-color: var(--lm-surface-modal-border);
38
+ background: var(--lm-surface-reading-bg);
39
+ color: var(--lm-c-text-primary);
40
+ box-shadow: var(--lm-shadow-elevated);
41
+ font-size: 0.875rem;
42
+ line-height: 1.7;
43
+ overflow-wrap: anywhere;
44
+
45
+ > p:first-of-type {
46
+ margin-top: 0;
47
+ }
48
+
49
+ > p:last-of-type {
50
+ margin-bottom: 0;
51
+ }
52
+
53
+ .va-footnote-close {
54
+ color: var(--lm-c-text-secondary);
55
+ }
56
+
57
+ .va-footnote-arrow {
58
+ fill: var(--lm-surface-reading-bg);
59
+ }
60
+ }
61
+
62
+ .markdown-body .va-footnote-preview {
63
+ color: var(--lm-c-primary-text);
64
+ border-radius: 0.25rem;
65
+ }
66
+
67
+ .markdown-body .va-footnote-preview,
68
+ .va-footnote-popover .va-footnote-close {
69
+ &:hover {
70
+ color: var(--lm-c-primary-text-hover);
71
+ background: var(--lm-c-primary-soft);
72
+ }
73
+
74
+ &:focus-visible {
75
+ outline: 2px solid var(--lm-c-primary-focus-ring);
76
+ outline-offset: 2px;
77
+ }
78
+ }
@@ -88,13 +88,19 @@
88
88
  overflow: hidden;
89
89
  }
90
90
 
91
- .mermaid {
92
- display: block;
93
- padding: 1rem;
94
- border: 1px solid var(--lm-c-primary-border-subtle);
95
- border-radius: 0.75rem;
96
- background: color-mix(in srgb, var(--lm-surface-reading-bg) 78%, transparent);
91
+ // valaxy-addon-mermaid 的根元素是 figure.diagram-card(旧内核的 .mermaid 已不再出现)。
92
+ // 外壳外观按插件文档使用 --va-mermaid-* 变量;图表内的元素交给 appearance 与 config。
93
+ // accent 用模式自适应的 -primary-text:插件按钮底色是 accent 混合 8%,-primary-base 在浅色下只有 1.76:1。
94
+ figure.diagram-card {
95
+ --va-mermaid-bg: color-mix(in srgb, var(--lm-surface-reading-bg) 78%, transparent);
96
+ --va-mermaid-panel: var(--lm-c-primary-muted);
97
+ --va-mermaid-text: var(--lm-c-text-primary);
98
+ --va-mermaid-muted: var(--lm-c-text-secondary);
99
+ --va-mermaid-accent: var(--lm-c-primary-text);
100
+ --va-mermaid-border: var(--lm-c-primary-border-subtle);
101
+ --va-mermaid-grid: var(--lm-c-border);
102
+ --va-mermaid-radius: 0.75rem;
103
+
97
104
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
98
- overflow-x: auto;
99
105
  }
100
106
  }