clarity-theme 0.1.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/LICENSE +21 -0
- package/README.md +276 -0
- package/README.zh-CN.md +297 -0
- package/app/app.config.ts +110 -0
- package/app/app.vue +5 -0
- package/app/assets/css/_variable.scss +8 -0
- package/app/assets/css/animation.scss +50 -0
- package/app/assets/css/article.scss +152 -0
- package/app/assets/css/color.scss +58 -0
- package/app/assets/css/font.scss +35 -0
- package/app/assets/css/main.scss +230 -0
- package/app/assets/css/reusable.scss +186 -0
- package/app/assets/icons/solar-rewind-back-bold-duotone.svg +1 -0
- package/app/assets/icons/solar-rewind-forward-bold-duotone.svg +1 -0
- package/app/components/blog/BlogAside.vue +63 -0
- package/app/components/blog/BlogFooter.vue +61 -0
- package/app/components/blog/BlogHeader.global.vue +146 -0
- package/app/components/blog/BlogPanel.vue +79 -0
- package/app/components/blog/BlogSidebar.vue +160 -0
- package/app/components/blog/BlogWidget.vue +134 -0
- package/app/components/blog/Mask.vue +42 -0
- package/app/components/blog/SkipToContent.vue +22 -0
- package/app/components/blog/ThemeToggle.vue +50 -0
- package/app/components/content/Alert.vue +96 -0
- package/app/components/content/Badge.vue +90 -0
- package/app/components/content/Blur.vue +22 -0
- package/app/components/content/CardList.vue +32 -0
- package/app/components/content/Chat.vue +79 -0
- package/app/components/content/Copy.vue +134 -0
- package/app/components/content/EmojiClock.vue +53 -0
- package/app/components/content/FeedCard.vue +212 -0
- package/app/components/content/FeedGroup.vue +130 -0
- package/app/components/content/Folding.vue +69 -0
- package/app/components/content/Key.vue +164 -0
- package/app/components/content/LinkBanner.vue +59 -0
- package/app/components/content/LinkCard.vue +74 -0
- package/app/components/content/MdTitle.vue +26 -0
- package/app/components/content/Mermaid.vue +133 -0
- package/app/components/content/MusicScore.vue +178 -0
- package/app/components/content/Pic.vue +55 -0
- package/app/components/content/Poetry.vue +41 -0
- package/app/components/content/ProseA.vue +40 -0
- package/app/components/content/ProseCode.vue +95 -0
- package/app/components/content/ProsePre.vue +291 -0
- package/app/components/content/ProseTable.vue +70 -0
- package/app/components/content/Quote.vue +51 -0
- package/app/components/content/Tab.vue +100 -0
- package/app/components/content/Timeline.vue +73 -0
- package/app/components/content/Tip.vue +52 -0
- package/app/components/content/VideoEmbed.vue +127 -0
- package/app/components/partial/Button.vue +98 -0
- package/app/components/partial/DlGroup.vue +69 -0
- package/app/components/partial/Dropdown.vue +54 -0
- package/app/components/partial/Error.vue +70 -0
- package/app/components/partial/Expand.vue +51 -0
- package/app/components/partial/IconNavList.vue +42 -0
- package/app/components/partial/Pagination.vue +113 -0
- package/app/components/partial/RadioGroup.vue +77 -0
- package/app/components/partial/Secret.vue +23 -0
- package/app/components/partial/Slider.vue +96 -0
- package/app/components/partial/Toggle.vue +70 -0
- package/app/components/popover/Lightbox.vue +77 -0
- package/app/components/popover/Search.vue +214 -0
- package/app/components/popover/SearchItem.vue +64 -0
- package/app/components/post/Archive.vue +104 -0
- package/app/components/post/Article.vue +138 -0
- package/app/components/post/Comment.vue +275 -0
- package/app/components/post/Excerpt.vue +66 -0
- package/app/components/post/OrderToggle.vue +101 -0
- package/app/components/post/PostFooter.vue +80 -0
- package/app/components/post/PostHeader.vue +147 -0
- package/app/components/post/PostSurround.vue +111 -0
- package/app/components/post/Slide.vue +215 -0
- package/app/components/util/Date.vue +62 -0
- package/app/components/util/HydrateSafe.vue +10 -0
- package/app/components/util/Img.vue +38 -0
- package/app/components/util/Link.vue +11 -0
- package/app/components/widget/BlogLog.vue +27 -0
- package/app/components/widget/BlogStats.vue +39 -0
- package/app/components/widget/BlogTech.vue +65 -0
- package/app/components/widget/Empty.vue +3 -0
- package/app/components/widget/Toc.vue +129 -0
- package/app/composables/useArticle.ts +118 -0
- package/app/composables/useAvoid.ts +87 -0
- package/app/composables/useCopy.ts +21 -0
- package/app/composables/usePagination.ts +70 -0
- package/app/composables/useShiki.ts +129 -0
- package/app/composables/useToc.ts +57 -0
- package/app/composables/useWidgets.ts +56 -0
- package/app/error.vue +34 -0
- package/app/layouts/default.vue +66 -0
- package/app/pages/[...slug].vue +59 -0
- package/app/pages/archive.vue +207 -0
- package/app/pages/index.vue +83 -0
- package/app/pages/link.vue +65 -0
- package/app/pages/preview.vue +59 -0
- package/app/plugins/easter-egg.ts +23 -0
- package/app/plugins/init.ts +6 -0
- package/app/plugins/tippy.ts +22 -0
- package/app/shiki.config.ts +8 -0
- package/app/stores/layout.ts +34 -0
- package/app/stores/search.ts +37 -0
- package/app/types/article.ts +16 -0
- package/app/types/feed.ts +1 -0
- package/app/types/index.ts +14 -0
- package/app/types/modal.ts +16 -0
- package/app/types/nav.ts +11 -0
- package/app/utils/anim.ts +37 -0
- package/app/utils/img.ts +83 -0
- package/config/app.ts +88 -0
- package/config/content.d.mts +1 -0
- package/config/content.mjs +69 -0
- package/config/content.ts +91 -0
- package/config/define.mjs +21 -0
- package/config/define.ts +23 -0
- package/config/feed.ts +42 -0
- package/config/feeds.empty.ts +4 -0
- package/config/index.d.mts +1 -0
- package/config/index.mjs +6 -0
- package/config/index.ts +6 -0
- package/config/public.ts +71 -0
- package/config/schema.d.mts +1 -0
- package/config/schema.mjs +103 -0
- package/config/schema.ts +129 -0
- package/config/server.ts +35 -0
- package/img/index.d.mts +1 -0
- package/img/index.mjs +78 -0
- package/img/index.ts +8 -0
- package/modules/clarity-config/anti-mirror-client.ts +11 -0
- package/modules/clarity-config/index.ts +324 -0
- package/nuxt.config.ts +225 -0
- package/package.json +148 -0
- package/public/assets/atom.css +274 -0
- package/public/assets/atom.xsl +110 -0
- package/public/fonts/AlimamaFangYuanTi.woff2 +0 -0
- package/remark-plugins/rehype-meta-slots.d.mts +1 -0
- package/remark-plugins/rehype-meta-slots.mjs +49 -0
- package/remark-plugins/rehype-meta-slots.ts +58 -0
- package/remark-plugins/remark-code-component.d.mts +1 -0
- package/remark-plugins/remark-code-component.mjs +25 -0
- package/remark-plugins/remark-code-component.ts +41 -0
- package/server/api/stats.get.ts +109 -0
- package/server/routes/atom.xml.get.ts +101 -0
- package/server/routes/subscriptions.opml.get.ts +70 -0
- package/server/utils/clarity.ts +11 -0
- package/shared/types/content.ts +30 -0
- package/shared/utils/clarity.ts +34 -0
- package/shared/utils/icon.ts +218 -0
- package/shared/utils/link.ts +52 -0
- package/shared/utils/str.ts +88 -0
- package/shared/utils/time.ts +116 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ArticleProps } from '../../types/article'
|
|
3
|
+
|
|
4
|
+
defineOptions({ inheritAttrs: false })
|
|
5
|
+
const props = defineProps<ArticleProps>()
|
|
6
|
+
|
|
7
|
+
const clarity = useClarityConfig()
|
|
8
|
+
|
|
9
|
+
const coverFilter = computed(() => props.meta?.coverFilter || (props.meta?.coverDim && 'brightness(0.75)') || undefined)
|
|
10
|
+
|
|
11
|
+
const shareText = `【${clarity.site.title}】${props.title}\n\n${
|
|
12
|
+
props.description ? `${props.description}\n\n` : ''}${
|
|
13
|
+
new URL(props.path!, clarity.site.url).href}`
|
|
14
|
+
|
|
15
|
+
const { copy, copied } = useCopy(shareText)
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<div class="post-header" :class="{ 'has-cover': image }">
|
|
20
|
+
<Pic v-if="image" class="post-cover" :src="image" :alt="title" :filter="coverFilter" />
|
|
21
|
+
<div class="post-nav">
|
|
22
|
+
<div class="operations">
|
|
23
|
+
<Icon v-show="false" name="tabler:check" />
|
|
24
|
+
<ZButton
|
|
25
|
+
:icon="copied ? 'tabler:check' : 'tabler:share'"
|
|
26
|
+
text="文字分享"
|
|
27
|
+
@click="copy()"
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div v-if="!meta?.hideInfo" class="post-info">
|
|
32
|
+
<UtilDate
|
|
33
|
+
v-if="date"
|
|
34
|
+
v-tip
|
|
35
|
+
:tip-transform="d => `创建于${d}`"
|
|
36
|
+
:date
|
|
37
|
+
icon="tabler:pencil-minus"
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
<UtilDate
|
|
41
|
+
v-if="updated && isTimeDiffSignificant(date, updated, undefined, 1)"
|
|
42
|
+
v-tip
|
|
43
|
+
:tip-transform="d => `修改于${d}`"
|
|
44
|
+
:date="updated"
|
|
45
|
+
icon="tabler:clock-edit"
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<span v-if="categories">
|
|
49
|
+
<Icon :name="getCategoryIcon(categories[0])" />
|
|
50
|
+
{{ categories[0] }}
|
|
51
|
+
</span>
|
|
52
|
+
|
|
53
|
+
<span>
|
|
54
|
+
<Icon name="tabler:pilcrow" />
|
|
55
|
+
{{ formatNumber(readingTime?.words) }} 字
|
|
56
|
+
</span>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<h1 class="post-title" :class="getPostTypeClassName(type)">
|
|
61
|
+
{{ title }}
|
|
62
|
+
</h1>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<style lang="scss" scoped>
|
|
67
|
+
.post-header {
|
|
68
|
+
contain: paint; // overflow hidden + position relative
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
gap: 1rem;
|
|
73
|
+
margin: 0.5rem;
|
|
74
|
+
border-radius: 1rem;
|
|
75
|
+
background-color: var(--c-bg-2);
|
|
76
|
+
color: var(--c-text);
|
|
77
|
+
|
|
78
|
+
@media (max-width: $breakpoint-mobile) {
|
|
79
|
+
margin: 0;
|
|
80
|
+
border-radius: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&:hover .operations,
|
|
84
|
+
&:focus-within .operations {
|
|
85
|
+
opacity: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&.has-cover {
|
|
89
|
+
min-height: 16rem;
|
|
90
|
+
max-height: 20rem;
|
|
91
|
+
color: white;
|
|
92
|
+
transition: font-size 0.2s;
|
|
93
|
+
|
|
94
|
+
.post-info {
|
|
95
|
+
filter: drop-shadow(0 1px 2px #000);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.post-title {
|
|
99
|
+
background-image: linear-gradient(transparent, #0003, #0005);
|
|
100
|
+
text-shadow: var(--text-shadow-black);
|
|
101
|
+
|
|
102
|
+
&.text-story {
|
|
103
|
+
text-align: center;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.operations {
|
|
110
|
+
position: absolute;
|
|
111
|
+
opacity: 0;
|
|
112
|
+
inset-inline-end: 1em;
|
|
113
|
+
color: var(--c-text-1);
|
|
114
|
+
transition: opacity 0.2s;
|
|
115
|
+
z-index: 1;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.post-cover {
|
|
119
|
+
position: absolute;
|
|
120
|
+
inset: 0;
|
|
121
|
+
|
|
122
|
+
> :deep(img) {
|
|
123
|
+
width: 100%;
|
|
124
|
+
height: 100%;
|
|
125
|
+
object-fit: cover;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.post-title {
|
|
130
|
+
padding: 0.8em 1rem;
|
|
131
|
+
font-size: 1.6em;
|
|
132
|
+
line-height: 1.2;
|
|
133
|
+
z-index: 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.post-nav {
|
|
137
|
+
padding: 0.8em 1rem;
|
|
138
|
+
font-size: 0.8em;
|
|
139
|
+
|
|
140
|
+
.post-info {
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-wrap: wrap;
|
|
143
|
+
gap: 0.5em 1.2em;
|
|
144
|
+
column-gap: clamp(1em, 3%, 1.5em);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
</style>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ArticleProps } from '../../types/article'
|
|
3
|
+
|
|
4
|
+
const route = useRoute()
|
|
5
|
+
|
|
6
|
+
const { data: surrounds } = await useAsyncData(
|
|
7
|
+
`surround:${route.path}`,
|
|
8
|
+
() => queryCollectionItemSurroundings('content', route.path, { fields: ['date', 'title', 'type'] })
|
|
9
|
+
.order('date', 'ASC')
|
|
10
|
+
.where('stem', 'LIKE', `posts/%`),
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
const [prev = null, next = null] = surrounds.value ?? []
|
|
14
|
+
|
|
15
|
+
const [DefineTemplate, ReuseTemplate] = createReusableTemplate<{
|
|
16
|
+
post: ArticleProps | null
|
|
17
|
+
icon: string
|
|
18
|
+
fallbackIcon: string
|
|
19
|
+
fallbackText: string
|
|
20
|
+
alignEnd?: boolean
|
|
21
|
+
}>({ inheritAttrs: false })
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<DefineTemplate v-slot="{ post, icon, fallbackIcon, fallbackText, alignEnd }">
|
|
26
|
+
<UtilLink :to="post?.path" class="surround-link" :align-end>
|
|
27
|
+
<Icon :class="{ 'rtl-flip': post }" :name="post ? icon : fallbackIcon" />
|
|
28
|
+
<div class="surround-text">
|
|
29
|
+
<strong class="title" :class="getPostTypeClassName(post?.type)">
|
|
30
|
+
{{ post?.title || fallbackText }}
|
|
31
|
+
</strong>
|
|
32
|
+
<UtilDate v-if="post?.date" class="date" :date="post.date" />
|
|
33
|
+
</div>
|
|
34
|
+
</UtilLink>
|
|
35
|
+
</DefineTemplate>
|
|
36
|
+
|
|
37
|
+
<div v-if="prev || next" class="surround-post" dir="ltr">
|
|
38
|
+
<ReuseTemplate
|
|
39
|
+
:post="next" icon="clarity:solar-rewind-back-bold-duotone"
|
|
40
|
+
fallback-icon="line-md:coffee-twotone-loop" fallback-text="新故事即将发生"
|
|
41
|
+
/>
|
|
42
|
+
<ReuseTemplate
|
|
43
|
+
:post="prev" icon="clarity:solar-rewind-forward-bold-duotone"
|
|
44
|
+
fallback-icon="line-md:construction-twotone" fallback-text="已抵达博客尽头"
|
|
45
|
+
align-end
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<style lang="scss" scoped>
|
|
51
|
+
.surround-post {
|
|
52
|
+
contain: layout;
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-wrap: wrap;
|
|
55
|
+
gap: 1rem;
|
|
56
|
+
margin: 3rem 1rem;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.surround-link {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: 0.5em;
|
|
63
|
+
transition: color 0.2s;
|
|
64
|
+
|
|
65
|
+
&:not([href]) {
|
|
66
|
+
opacity: 0.4;
|
|
67
|
+
user-select: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&[align-end] {
|
|
71
|
+
// direction: rtl 会导致末尾标点居左
|
|
72
|
+
flex-direction: row-reverse;
|
|
73
|
+
margin-inline-start: auto;
|
|
74
|
+
text-align: end;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
> .surround-text {
|
|
78
|
+
text-wrap: balance;
|
|
79
|
+
transition: transform 0.2s;
|
|
80
|
+
|
|
81
|
+
> .date {
|
|
82
|
+
display: block;
|
|
83
|
+
opacity: 0.6;
|
|
84
|
+
font-size: 0.8rem;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
> .iconify {
|
|
89
|
+
opacity: 0.5;
|
|
90
|
+
font-size: 2rem;
|
|
91
|
+
transition: transform 0.2s;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&[href]:hover {
|
|
95
|
+
color: var(--c-primary);
|
|
96
|
+
|
|
97
|
+
> .surround-text {
|
|
98
|
+
transform: translateX(-1em);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&[align-end] > .surround-text {
|
|
102
|
+
transform: translateX(1em);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
> .iconify {
|
|
106
|
+
opacity: 0.2;
|
|
107
|
+
transform: scale(2);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ArticleProps } from '../../types/article'
|
|
3
|
+
import Autoplay from 'embla-carousel-autoplay'
|
|
4
|
+
import emblaCarouselVue from 'embla-carousel-vue'
|
|
5
|
+
import { WheelGesturesPlugin } from 'embla-carousel-wheel-gestures'
|
|
6
|
+
|
|
7
|
+
defineProps<{ list: ArticleProps[] }>()
|
|
8
|
+
|
|
9
|
+
const clarity = useClarityConfig()
|
|
10
|
+
const compConf = computed(() => clarity.component.slide)
|
|
11
|
+
|
|
12
|
+
// @keep-sorted
|
|
13
|
+
const [carouselEl, carouselApi] = emblaCarouselVue({
|
|
14
|
+
containScroll: false,
|
|
15
|
+
loop: true,
|
|
16
|
+
skipSnaps: true,
|
|
17
|
+
}, [
|
|
18
|
+
Autoplay({ stopOnInteraction: false, stopOnMouseEnter: true }),
|
|
19
|
+
WheelGesturesPlugin(),
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
// 鼠标横向滚动 / Shift + 纵向滚轮事件
|
|
23
|
+
useEventListener(carouselEl, 'wheel', (e) => {
|
|
24
|
+
const delta = e.deltaX + (e.shiftKey ? e.deltaY : 0)
|
|
25
|
+
if (Math.abs(delta) < 80)
|
|
26
|
+
return
|
|
27
|
+
delta > 0 ? carouselApi.value?.scrollNext() : carouselApi.value?.scrollPrev()
|
|
28
|
+
}, { passive: true })
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<div class="z-slide">
|
|
33
|
+
<div class="z-slide-header">
|
|
34
|
+
<span class="title text-creative">精选文章</span>
|
|
35
|
+
<div class="at-slide-hover">
|
|
36
|
+
<Icon name="tabler:mouse" />
|
|
37
|
+
按住 Shift 横向滚动
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div ref="carouselEl" class="z-slide-body" dir="ltr">
|
|
42
|
+
<div class="slide-list">
|
|
43
|
+
<UtilLink
|
|
44
|
+
v-for="(article, index) in list"
|
|
45
|
+
:key="index"
|
|
46
|
+
class="slide-item"
|
|
47
|
+
:title="article.description"
|
|
48
|
+
:to="article.path"
|
|
49
|
+
>
|
|
50
|
+
<NuxtImg class="cover" :src="article.image" :alt="compConf.showTitle ? '' : article.title" />
|
|
51
|
+
|
|
52
|
+
<div v-if="compConf.showTitle" class="stable-info text-creative">
|
|
53
|
+
{{ article.title }}
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div class="hover-info">
|
|
57
|
+
<div class="title text-creative">
|
|
58
|
+
{{ article.title }}
|
|
59
|
+
</div>
|
|
60
|
+
<UtilDate v-if="article.date" class="desc" :date="article.date" />
|
|
61
|
+
</div>
|
|
62
|
+
</UtilLink>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<ZButton
|
|
66
|
+
class="carousel-action prev at-slide-hover"
|
|
67
|
+
aria-label="上一页"
|
|
68
|
+
icon="tabler:chevron-left"
|
|
69
|
+
tabindex="-1"
|
|
70
|
+
@click="carouselApi?.scrollPrev()"
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
<ZButton
|
|
74
|
+
class="carousel-action next at-slide-hover"
|
|
75
|
+
aria-label="下一页"
|
|
76
|
+
icon="tabler:chevron-right"
|
|
77
|
+
tabindex="-1"
|
|
78
|
+
@click="carouselApi?.scrollNext()"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<style lang="scss" scoped>
|
|
85
|
+
.z-slide {
|
|
86
|
+
margin: 1rem;
|
|
87
|
+
|
|
88
|
+
.at-slide-hover {
|
|
89
|
+
opacity: 0;
|
|
90
|
+
transition: opacity 0.2s;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&:hover .at-slide-hover,
|
|
94
|
+
&:focus-within .at-slide-hover {
|
|
95
|
+
opacity: 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.z-slide-header {
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-wrap: wrap;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: space-between;
|
|
104
|
+
gap: 2rem;
|
|
105
|
+
height: 3rem;
|
|
106
|
+
margin-bottom: -0.2rem;
|
|
107
|
+
mask-image: linear-gradient(#FFF, transparent);
|
|
108
|
+
color: var(--c-text-3);
|
|
109
|
+
|
|
110
|
+
>.title {
|
|
111
|
+
font-size: 3rem;
|
|
112
|
+
font-weight: bold;
|
|
113
|
+
line-height: 1;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.z-slide-body {
|
|
118
|
+
--fadeout-width: 1.5rem;
|
|
119
|
+
|
|
120
|
+
position: relative;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
padding: 2px 0;
|
|
123
|
+
mask-image: linear-gradient(to var(--end), transparent, #FFF var(--fadeout-width), #FFF calc(100% - var(--fadeout-width)), transparent);
|
|
124
|
+
cursor: grab;
|
|
125
|
+
user-select: none;
|
|
126
|
+
|
|
127
|
+
.slide-list {
|
|
128
|
+
display: flex;
|
|
129
|
+
scroll-snap-type: x mandatory;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.carousel-action {
|
|
134
|
+
position: absolute;
|
|
135
|
+
top: 50%;
|
|
136
|
+
padding: 0.5em 0.2em;
|
|
137
|
+
font-size: 1.5em;
|
|
138
|
+
transform: translateY(-50%);
|
|
139
|
+
transition: all 0.2s;
|
|
140
|
+
|
|
141
|
+
&.prev { inset-inline-start: 1rem; }
|
|
142
|
+
&.next { inset-inline-end: 1rem; }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.slide-item {
|
|
146
|
+
contain: paint;
|
|
147
|
+
flex-shrink: 0;
|
|
148
|
+
position: relative;
|
|
149
|
+
width: max(12rem, 28%);
|
|
150
|
+
max-width: 80%;
|
|
151
|
+
aspect-ratio: 1.77;
|
|
152
|
+
margin: 0 min(0.5em, 1%);
|
|
153
|
+
border-radius: 0.5rem;
|
|
154
|
+
scroll-snap-align: center;
|
|
155
|
+
scroll-snap-stop: always;
|
|
156
|
+
|
|
157
|
+
// Firefox 图片 alt 为空时 fallback 失效
|
|
158
|
+
@supports (-moz-force-broken-image-icon: 1) {
|
|
159
|
+
background-color: var(--c-border);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
> .cover {
|
|
163
|
+
display: block;
|
|
164
|
+
width: 100%;
|
|
165
|
+
height: 100%;
|
|
166
|
+
object-fit: cover;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
>.stable-info, > .hover-info {
|
|
170
|
+
position: absolute;
|
|
171
|
+
text-align: center;
|
|
172
|
+
text-shadow: var(--text-shadow-black);
|
|
173
|
+
color: white;
|
|
174
|
+
transition: opacity 0.2s;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
> .stable-info {
|
|
178
|
+
overflow: hidden;
|
|
179
|
+
bottom: 0;
|
|
180
|
+
width: 100%;
|
|
181
|
+
padding: 0.5em;
|
|
182
|
+
background-image: linear-gradient(transparent, #0003, #0005);
|
|
183
|
+
white-space: nowrap;
|
|
184
|
+
text-overflow: ellipsis;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
> .hover-info {
|
|
188
|
+
display: grid;
|
|
189
|
+
place-items: center;
|
|
190
|
+
opacity: 0;
|
|
191
|
+
inset: 0;
|
|
192
|
+
padding: 1em;
|
|
193
|
+
backdrop-filter: brightness(0.8) saturate(10) contrast(0.8) blur(2em);
|
|
194
|
+
|
|
195
|
+
> .title {
|
|
196
|
+
text-wrap: balance;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
> .desc {
|
|
200
|
+
opacity: 0.5;
|
|
201
|
+
font-size: 0.8em;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&:hover, &:focus-within {
|
|
206
|
+
>.stable-info {
|
|
207
|
+
opacity: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
> .hover-info {
|
|
211
|
+
opacity: 1;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Temporal } from 'temporal-polyfill'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<{
|
|
5
|
+
icon?: string
|
|
6
|
+
date?: string | Temporal.ZonedDateTime
|
|
7
|
+
format?: dateTimeFormatOptions
|
|
8
|
+
absolute?: boolean
|
|
9
|
+
relative?: boolean
|
|
10
|
+
nospace?: boolean
|
|
11
|
+
tipFormat?: dateTimeFormatOptions
|
|
12
|
+
tipTransform?: (formattedDate: string) => string
|
|
13
|
+
}>(), {
|
|
14
|
+
tipTransform: String,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const today = Temporal.Now.plainDateISO()
|
|
18
|
+
const zdt = computed(() => {
|
|
19
|
+
try {
|
|
20
|
+
return typeof props.date === 'string' ? toZonedTemporal(props.date) : props.date
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const relative = computed(() => props.absolute || !zdt.value
|
|
28
|
+
? false
|
|
29
|
+
: props.relative || today.since(zdt.value, { largestUnit: 'week' }).weeks < 1,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const mounted = useMounted()
|
|
33
|
+
const tooltip = computed(() => mounted.value && zdt.value
|
|
34
|
+
? props.tipTransform(toZdtLocaleString(zdt.value, props.tipFormat))
|
|
35
|
+
: props.date as string,
|
|
36
|
+
)
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<span :title="tooltip">
|
|
41
|
+
<Icon v-if="icon" :name="icon" />
|
|
42
|
+
<template v-if="icon && !nospace"> </template>
|
|
43
|
+
|
|
44
|
+
<span v-if="!zdt">Invalid Date</span>
|
|
45
|
+
|
|
46
|
+
<time
|
|
47
|
+
v-else-if="format"
|
|
48
|
+
:datetime="toInstantString(zdt)"
|
|
49
|
+
v-text="toZdtLocaleString(zdt, format)"
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<NuxtTime
|
|
53
|
+
v-else
|
|
54
|
+
:datetime="toInstantString(zdt)"
|
|
55
|
+
:relative
|
|
56
|
+
:year="zdt.year === today.year ? undefined : '2-digit'"
|
|
57
|
+
month="long"
|
|
58
|
+
day="numeric"
|
|
59
|
+
numeric="auto"
|
|
60
|
+
/>
|
|
61
|
+
</span>
|
|
62
|
+
</template>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { joinURL, withLeadingSlash, withTrailingSlash } from 'ufo'
|
|
3
|
+
import ImageComponent from '#build/mdc-image-component.mjs'
|
|
4
|
+
|
|
5
|
+
export interface UtilImgProps {
|
|
6
|
+
src: string
|
|
7
|
+
width?: string | number
|
|
8
|
+
height?: string | number
|
|
9
|
+
alt?: string
|
|
10
|
+
densities?: string
|
|
11
|
+
mirror?: ImgService
|
|
12
|
+
filter?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<UtilImgProps>(), {
|
|
16
|
+
alt: '',
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const src = computed(() => {
|
|
20
|
+
if (props.src.startsWith('/') && !props.src.startsWith('//')) {
|
|
21
|
+
const _base = withLeadingSlash(withTrailingSlash(useRuntimeConfig().app.baseURL))
|
|
22
|
+
if (_base !== '/' && !props.src.startsWith(_base))
|
|
23
|
+
return joinURL(_base, props.src)
|
|
24
|
+
}
|
|
25
|
+
if (props.mirror)
|
|
26
|
+
return getImgUrl(props.src, props.mirror)
|
|
27
|
+
return props.src
|
|
28
|
+
})
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<component
|
|
33
|
+
:is="ImageComponent"
|
|
34
|
+
:src :alt :width :height :densities
|
|
35
|
+
:style="{ filter }"
|
|
36
|
+
:referrerpolicy="mirror ? 'no-referrer' : undefined"
|
|
37
|
+
/>
|
|
38
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{ to?: string }>()
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<a v-if="to?.startsWith('#')" :href="to"><slot /></a>
|
|
7
|
+
<span v-else-if="typeof to === 'undefined'"><slot /></span>
|
|
8
|
+
<NuxtLink v-else :to :target="isExtLink(to) ? '_blank' : undefined">
|
|
9
|
+
<slot />
|
|
10
|
+
</NuxtLink>
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const clarity = useClarityConfig()
|
|
3
|
+
|
|
4
|
+
const blogLog = computed(() => {
|
|
5
|
+
const entries = clarity.changelog.map(({ date, text }) => ({ label: date, value: text }))
|
|
6
|
+
if (clarity.site.established) {
|
|
7
|
+
entries.push({ label: clarity.site.established, value: '发布第一篇文章' })
|
|
8
|
+
}
|
|
9
|
+
return entries
|
|
10
|
+
})
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<BlogWidget card title="更新日志">
|
|
15
|
+
<ZDlGroup v-if="blogLog.length" size="large" :items="blogLog" />
|
|
16
|
+
<p v-else class="no-log">
|
|
17
|
+
暂无更新日志,可在 clarity.config.ts 的 changelog 中配置。
|
|
18
|
+
</p>
|
|
19
|
+
</BlogWidget>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<style lang="scss" scoped>
|
|
23
|
+
.no-log {
|
|
24
|
+
padding: 1em;
|
|
25
|
+
color: var(--c-text-3);
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { UtilDate } from '#components'
|
|
3
|
+
|
|
4
|
+
const clarity = useClarityConfig()
|
|
5
|
+
const runtimeConfig = useRuntimeConfig()
|
|
6
|
+
|
|
7
|
+
// 响应头不正确时,stats.value 可能会是字符串,首次属性访问可能为 undefined
|
|
8
|
+
const { data: stats } = useFetch('/api/stats')
|
|
9
|
+
|
|
10
|
+
const yearlyTip = computed(() => Object
|
|
11
|
+
.entries(stats.value?.annual || {})
|
|
12
|
+
.reverse()
|
|
13
|
+
.map(([year, item]) => `${year}年:${item.posts}篇,${formatNumber(item.words)}字`)
|
|
14
|
+
.join('\n') || '数据获取失败',
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const blogStats = [{
|
|
18
|
+
label: '运营时长',
|
|
19
|
+
value: clarity.site.established ? timeElapse(clarity.site.established) : '--',
|
|
20
|
+
tip: clarity.site.established ? `博客于${clarity.site.established}上线` : '未配置建站日期',
|
|
21
|
+
}, {
|
|
22
|
+
label: '上次更新',
|
|
23
|
+
value: () => h(UtilDate, {
|
|
24
|
+
date: runtimeConfig.public.buildTime,
|
|
25
|
+
relative: true,
|
|
26
|
+
tipPrefix: '构建于',
|
|
27
|
+
}),
|
|
28
|
+
}, {
|
|
29
|
+
label: clarity.stats.postsOnly ? '文章字数' : '总字数',
|
|
30
|
+
value: computed(() => formatNumber(stats.value?.total?.words) || '--'),
|
|
31
|
+
tip: yearlyTip,
|
|
32
|
+
}]
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<BlogWidget card title="博客统计">
|
|
37
|
+
<ZDlGroup :items="blogStats" size="small" />
|
|
38
|
+
</BlogWidget>
|
|
39
|
+
</template>
|