Skip to content

Commit bdee05a

Browse files
committed
update home style
1 parent ece1de7 commit bdee05a

File tree

7 files changed

+416
-362
lines changed

7 files changed

+416
-362
lines changed

docs/.vuepress/theme/lib/client/components/ArticleList.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import Pagination from "./Pagination.vue";
33
44
import { computed, ref, Ref, toRefs, watch } from "vue";
55
import { useSiteLocaleData } from "@vuepress/client";
6-
import { usePaginationChanges } from "../composables/useComponentUtils";
6+
import {
7+
getTagPathByTag,
8+
usePaginationChanges,
9+
} from "../composables/useComponentUtils";
710
import { getTimeAgo, getFormatDate } from "../composables/useDate";
811
912
import type { SiteLocaleData } from "@vuepress/client";
@@ -35,10 +38,6 @@ function getAuthor(author: string) {
3538
return author === undefined ? "Unknown" : author;
3639
}
3740
38-
function getTagPath(tag: string) {
39-
return encodeURI(`/tags/${tag.toLowerCase()}/`);
40-
}
41-
4241
/* Pagination */
4342
const articleListPages = ref<PaginationPages>({
4443
total: articles.value.length,
@@ -91,7 +90,7 @@ watch(
9190
v-for="tag of article.info.tags.slice(0, 3)"
9291
:key="tag"
9392
class="tag-item"
94-
:to="getTagPath(tag)"
93+
:to="getTagPathByTag(tag)"
9594
>{{ tag }}</router-link
9695
>
9796
<span

docs/.vuepress/theme/lib/client/components/Home.vue

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { type Ref } from "vue";
33
import PageFooter from "./PageFooter.vue";
44
import { RouteLink, type SiteData, useSiteData } from "vuepress/client";
5+
import { getTagPathByTag } from "../composables/useComponentUtils";
56
import { type PagesMap, defaultConstants } from "../../shared";
67
78
const siteData: Ref<SiteData & { pagesMap: PagesMap }> = useSiteData() as any;
@@ -11,16 +12,26 @@ const { exceptHomeListSlug } = defaultConstants;
1112
const trimArticles = articles.filter((article) => {
1213
return !exceptHomeListSlug.includes(article.slug);
1314
});
15+
16+
console.log(trimArticles);
1417
</script>
1518

1619
<template>
1720
<div class="v-nc-theme-home">
1821
<div class="page-main">
1922
<div class="home-article-list">
2023
<div class="article" v-for="article in trimArticles">
21-
<RouteLink class="no-underline title" :to="article.pathInferred!">{{
22-
article.data.title
23-
}}</RouteLink>
24+
<RouteLink class="home-link" :to="article.pathInferred!">
25+
<span class="title">{{ article.data.title }}</span>
26+
<span class="tags">
27+
<RouteLink
28+
class="tag"
29+
v-for="tag in article.routeMeta?._blog?.tags"
30+
:to="getTagPathByTag(tag)"
31+
>{{ tag }}</RouteLink
32+
>
33+
</span>
34+
</RouteLink>
2435
</div>
2536
</div>
2637
<PageFooter />
@@ -33,15 +44,26 @@ const trimArticles = articles.filter((article) => {
3344
@apply flex flex-col justify-center items-center;
3445
}
3546
.home-article-list {
36-
@apply w-1/2 h-fit flex flex-wrap justify-center items-center gap-x-2 gap-y-0.5 my-24;
47+
@apply w-1/2 h-fit flex flex-wrap items-center gap-2 my-24;
3748
}
49+
3850
.article {
3951
@apply w-fit h-fit;
4052
}
41-
.article .title {
42-
@apply inline-block max-w-60 h-full px-1
53+
.article .home-link {
54+
@apply inline-flex flex-col justify-center max-w-60 h-full px-1
4355
rounded border-2 border-transparent bg-zinc-100 dark:bg-zinc-600
44-
hover:border-green-300
45-
select-none truncate cursor-pointer transition-all ease-in-out duration-300;
56+
hover:bg-green-100 hover:border-green-300 dark:hover:bg-green-700 dark:hover:border-green-500
57+
select-none cursor-pointer transition-all ease-in-out duration-300;
58+
}
59+
.home-link .title {
60+
@apply inline-block max-w-60
61+
text-xl
62+
truncate;
63+
}
64+
.home-link .tags {
65+
@apply inline-flex max-w-60 gap-0.5
66+
flex-wrap
67+
text-sm;
4668
}
4769
</style>

0 commit comments

Comments
 (0)