-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve the post list experience
- Loading branch information
1 parent
7a3d424
commit 218ca8c
Showing
4 changed files
with
151 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<template> | ||
<div class="posts-list"> | ||
<div class="post" v-for="post in posts" @click="router.push(post.path)"> | ||
|
||
<div class="post__excerpt" v-html="post.excerpt"></div> | ||
|
||
<div class="post__metadata"> | ||
<DateTime class="post__date" :time="post.frontmatter.date" format="YYYY-MM-DD" /> | ||
<span class="post__tag" v-for="tag in (post.frontmatter?.tags || [])">#{{ tag }}</span> | ||
<a class="post__keep-reading" :href="post.path">Keep Reading →</a> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import {} from 'vue' | ||
import {useRouter} from 'vue-router' | ||
export default { | ||
props: { | ||
posts: { | ||
type: Array, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
return { | ||
posts: props.posts, | ||
router: useRouter() | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
.posts-list .post { | ||
margin-left: 1rem; | ||
margin-right: 2rem; | ||
margin-bottom: 2rem; | ||
padding-left: 1rem; | ||
cursor: pointer; | ||
border-left: 4px solid rgba(180, 180, 180, 0.0); | ||
transition: border-color 0.2s ease-in-out; | ||
} | ||
.posts-list .post:hover { | ||
border-color: var(--c-brand); | ||
} | ||
.posts-list .post__title { | ||
margin-bottom: 0; | ||
} | ||
.posts-list .post__title a { | ||
color: var(--c-text); | ||
} | ||
.posts-list .post__metadata { | ||
} | ||
.posts-list .post__excerpt .header-anchor { | ||
display: none; | ||
} | ||
.posts-list .post__excerpt h1 { | ||
font-size: 1.4rem; | ||
padding-top: 0; | ||
margin-top: 1rem; | ||
} | ||
.posts-list .post__excerpt h1:first-child + p { | ||
margin-top: 0; | ||
} | ||
.posts-list .post__keep-reading { | ||
margin-left: 0.5rem; | ||
} | ||
.posts-list .post__date { | ||
font-size: 0.9rem; | ||
opacity: 0.7; | ||
margin: 0 0.5rem; | ||
} | ||
.posts-list .post__tag { | ||
font-size: 0.9rem; | ||
font-weight: bold; | ||
margin: 0 5px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters