diff --git a/assets/css/main.css b/assets/css/main.css index f296005..c1e443e 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -164,6 +164,25 @@ body { opacity: 0.9; } +/* 标签 */ +.tag-pill { + display: inline-flex; + align-items: center; + padding: 0.125rem 0.625rem; + border-radius: 9999px; + font-size: 0.75rem; + font-weight: 500; + background-color: var(--color-bg-hover); + color: var(--color-text-secondary); + transition: background-color 0.15s ease, color 0.15s ease; + text-decoration: none; +} + +.tag-pill:hover { + background-color: var(--color-primary); + color: white; +} + /* 滚动条 */ ::-webkit-scrollbar { width: 6px; diff --git a/components/blog/PostCard.vue b/components/blog/PostCard.vue index 3e8f041..0fba8c2 100644 --- a/components/blog/PostCard.vue +++ b/components/blog/PostCard.vue @@ -86,6 +86,16 @@ function renderDesc(): string { v-html="renderDesc()" /> +
+ + {{ tag }} + +
+
import { siteConfig } from '~/config/site' +const router = useRouter() const route = useRoute() const slug = route.params.slug as string @@ -52,6 +53,17 @@ function formatDate(date: string) { {{ post.description }}

+
+ + {{ tag }} + +
+
route.query.tag, (tag) => { + if (typeof tag === 'string' && tag) { + searchQuery.value = tag + currentPage.value = 1 + } +}, { immediate: true }) const currentPage = ref(1) const postsPerPage = 10 @@ -46,7 +54,7 @@ const { data: allPosts } = await useAsyncData('posts-list', () => const { searchResults, filteredPosts, highlight } = usePostSearch(allPosts, searchQuery, searchFilters) -const hasAnyFilter = computed(() => searchFilters.value.title || searchFilters.value.description || searchFilters.value.content) +const hasAnyFilter = computed(() => searchFilters.value.title || searchFilters.value.description || searchFilters.value.content || searchFilters.value.tags) const totalPages = computed(() => Math.ceil(searchResults.value.length / postsPerPage)) @@ -83,10 +91,18 @@ watch(() => searchFilters.value, () => { v-model="searchQuery" type="text" placeholder="搜索文章标题、描述或内容..." - class="w-full h-10 rounded-full border bg-transparent pl-10 pr-4 text-sm outline-none transition-all focus:ring-2" + class="w-full h-10 rounded-full border bg-transparent pl-10 pr-10 text-sm outline-none transition-all focus:ring-2" style="border-color: var(--color-border); --tw-ring-color: var(--color-border);" @input="currentPage = 1" /> +