Skip to content

Commit a0f3364

Browse files
committed
Preview: Add a lot of features
1 parent 8895e86 commit a0f3364

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3962
-2016
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.vitepress/config.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from "vitepress";
2+
import { tabsMarkdownPlugin } from "vitepress-plugin-tabs";
23
import { RssPlugin } from "vitepress-plugin-rss";
34
import { globalConfig } from "#config";
45
import { getRunningTime } from "#theme/utils/getRunningTime";
@@ -31,11 +32,20 @@ export default defineConfig({
3132
publicDir: "../public",
3233
plugins: [RssPlugin(RSS)],
3334
},
35+
sitemap: {
36+
hostname: globalConfig.url,
37+
},
3438
markdown: {
39+
image: {
40+
lazyLoading: true,
41+
},
3542
theme: {
3643
light: "catppuccin-latte",
3744
dark: "catppuccin-mocha",
3845
},
46+
config(md) {
47+
md.use(tabsMarkdownPlugin);
48+
},
3949
},
4050
head: [["link", { rel: "icon", href: globalConfig.favicon }]],
4151

@@ -63,8 +73,8 @@ export default defineConfig({
6373
globalConfig.lang.poweredBy
6474
} <a href="https://vitepress.dev/">VitePress</a> & <a href="https://github.com/silvaire-qwq/Miracle">Miracle</a><br>
6575
${globalConfig.title} ${
66-
globalConfig.lang.hasExistedFor
67-
} ${getRunningTime(globalConfig.dateCreated)} ${globalConfig.lang.days}
76+
globalConfig.lang.hasExistedFor
77+
} ${getRunningTime(globalConfig.dateCreated)} ${globalConfig.lang.days}
6878
6979
`,
7080
},
@@ -77,4 +87,4 @@ export default defineConfig({
7787
provider: "local",
7888
},
7989
},
80-
});
90+
});

.vitepress/theme/components/article/article.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<script setup lang="ts">
2-
import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from "vue";
2+
import {
3+
ref,
4+
computed,
5+
watch,
6+
nextTick,
7+
onMounted,
8+
onBeforeUnmount,
9+
} from "vue";
310
import { Icon } from "@iconify/vue";
411
import PostCard from "./postCard.vue";
512
import { generateGrid } from "../../utils/generateGrid";
@@ -31,7 +38,7 @@ watch(
3138
} else {
3239
articles.value = posts;
3340
}
34-
}
41+
},
3542
);
3643
3744
// 监听 selectedCategory 的变化,重新过滤文章
@@ -52,7 +59,7 @@ onMounted(() => {
5259
if (selectedCategory.value) {
5360
nextTick(() => {
5461
articles.value = posts.filter(
55-
(post) => post.category === selectedCategory.value
62+
(post) => post.category === selectedCategory.value,
5663
);
5764
});
5865
}
@@ -64,12 +71,14 @@ onBeforeUnmount(() => {
6471
6572
// 🔹 按年份分组 + 瀑布流布局
6673
const groupedArticles = computed(() => {
67-
return generateGrid(
74+
const grid = generateGrid(
6875
articles.value,
6976
undefined,
7077
(post) => new Date(post.originDate).getFullYear().toString(),
71-
columnCount.value // ✅ 传入列数
78+
columnCount.value,
7279
);
80+
// 按年份倒序
81+
return grid.sort((a, b) => Number(b.key) - Number(a.key));
7382
});
7483
7584
// 提取所有唯一的类别
@@ -120,7 +129,7 @@ const { handleMouseMove, handleMouseEnter, handleMouseLeave } = useCardHover();
120129
@mousemove="handleMouseMove"
121130
@mouseleave="handleMouseLeave"
122131
>
123-
<Icon icon="material-symbols:tag-rounded" style="opacity: 0.4" />
132+
<Icon :icon="globalConfig.icon.tag" style="opacity: 0.4" />
124133
<span class="name">{{ " " + globalConfig.lang.tags }}</span>
125134
</a>
126135
<span

.vitepress/theme/components/article/postCard.vue

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface CardProps {
66
category: string;
77
date: string;
88
image?: string;
9+
type?: string;
910
}
1011
1112
const props = withDefaults(defineProps<CardProps>(), {
@@ -15,16 +16,26 @@ const props = withDefaults(defineProps<CardProps>(), {
1516
category: "",
1617
date: "",
1718
image: "",
19+
type: "",
1820
});
1921
22+
import { computed } from "vue";
2023
import { useCardHover } from "../../utils/useCardHover";
2124
const { handleMouseMove, handleMouseEnter, handleMouseLeave } = useCardHover();
25+
26+
const link = computed(() => {
27+
if (props.type === "project" && props.category) {
28+
return `https://github.com/${props.category}`;
29+
}
30+
return props.url || "";
31+
});
2232
</script>
2333

2434
<template>
2535
<a
2636
:href="props.url"
2737
v-if="props.url"
38+
:type="props.type"
2839
class="diary"
2940
@mouseenter="handleMouseEnter"
3041
@mousemove="handleMouseMove"
@@ -35,23 +46,24 @@ const { handleMouseMove, handleMouseEnter, handleMouseLeave } = useCardHover();
3546
</div>
3647
<div class="textPlace">
3748
<p class="title" v-if="props.title">{{ props.title }}</p>
38-
39-
<p class="details" v-if="props.description && props.title">{{ props.description }}</p>
40-
<p class="details notitle" v-else-if="props.description">{{ props.description }}</p>
49+
50+
<p class="details" v-if="props.description && props.title">
51+
{{ props.description }}
52+
</p>
53+
<p class="details notitle" v-else-if="props.description">
54+
{{ props.description }}
55+
</p>
4156

4257
<div class="meta">
4358
<!-- 修改此处,使得点击分类时跳转到相应的分类页面 -->
44-
<a
45-
class="category"
46-
v-if="props.category"
47-
:href="`/archives?category=${props.category}`"
48-
>{{ props.category }}</a
59+
<a class="category" v-if="props.category" :href="link">{{
60+
props.category
61+
}}</a
4962
>{{ props.date }}
5063
</div>
5164
</div>
5265
</a>
5366

54-
5567
<a
5668
v-else
5769
class="diary"
@@ -64,9 +76,13 @@ const { handleMouseMove, handleMouseEnter, handleMouseLeave } = useCardHover();
6476
</div>
6577
<div class="textPlace">
6678
<p class="title" v-if="props.title">{{ props.title }}</p>
67-
68-
<p class="details" v-if="props.description && props.title">{{ props.description }}</p>
69-
<p class="details notitle" v-else-if="props.description">{{ props.description }}</p>
79+
80+
<p class="details" v-if="props.description && props.title">
81+
{{ props.description }}
82+
</p>
83+
<p class="details notitle" v-else-if="props.description">
84+
{{ props.description }}
85+
</p>
7086

7187
<div class="meta">
7288
<!-- 修改此处,使得点击分类时跳转到相应的分类页面 -->
@@ -82,7 +98,6 @@ const { handleMouseMove, handleMouseEnter, handleMouseLeave } = useCardHover();
8298
</template>
8399

84100
<style scoped>
85-
86101
.img-container img {
87102
border-radius: var(--vp-border-radius-1) var(--vp-border-radius-1) 0 0;
88103
border-bottom: 1px solid var(--vp-c-divider);
@@ -103,6 +118,11 @@ const { handleMouseMove, handleMouseEnter, handleMouseLeave } = useCardHover();
103118
transition: all var(--vp-transition-time);
104119
}
105120
121+
.diary[type="project"] .title {
122+
text-transform: var(--vp-title-uppercase);
123+
font-family: var(--vp-font-family-mono);
124+
}
125+
106126
.diary:hover {
107127
border-color: var(--vp-c-brand-1);
108128
box-shadow: var(--vp-shadow-brand);
@@ -129,6 +149,7 @@ const { handleMouseMove, handleMouseEnter, handleMouseLeave } = useCardHover();
129149
line-height: 26px;
130150
font-weight: 600;
131151
margin: 0;
152+
text-transform: capitalize;
132153
transition: all var(--vp-transition-time);
133154
}
134155

0 commit comments

Comments
 (0)