Skip to content

Commit 74ebfee

Browse files
committed
chore: vue.js src 디렉토리 분리
1 parent 3dd8309 commit 74ebfee

File tree

14 files changed

+143
-117
lines changed

14 files changed

+143
-117
lines changed

.vitepress/config.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export default defineConfig({
5959
},
6060

6161
vite: {
62+
resolve: {
63+
alias: [{ find: "@", replacement: "/src" }],
64+
},
6265
plugins: [createAutoGeneratePostsPlugin()],
6366
},
6467

.vitepress/theme/components/BlogList.vue

Lines changed: 0 additions & 80 deletions
This file was deleted.

.vitepress/theme/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { h } from "vue";
33
import type { Theme } from "vitepress";
44
import DefaultTheme from "vitepress/theme";
5-
import BlogList from "./components/BlogList.vue";
5+
import PostCardList from "@/components/PostCardList/PostCardList.vue";
66
import "./style.css";
77

88
export default {
@@ -13,6 +13,6 @@ export default {
1313
});
1414
},
1515
enhanceApp({ app, router, siteData }) {
16-
app.component("BlogList", BlogList);
16+
app.component("PostCardList", PostCardList);
1717
},
1818
} satisfies Theme;

contents/posts/Aws/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AWS
2+
3+
AWS 관련 포스트들입니다.
4+
5+
<PostCardList category="Aws" />

contents/posts/JavaScript/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
JavaScript 관련 포스트들입니다.
44

5-
<BlogList category="JavaScript" />
5+
<PostCardList category="JavaScript" />

contents/posts/React/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
React 관련 포스트들입니다.
44

5-
<BlogList category="React" />
5+
<PostCardList category="React" />

contents/posts/Web/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
웹 개발 관련 포스트들입니다.
44

5-
<BlogList category="Web" />
5+
<PostCardList category="Web" />

contents/posts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
### 최신 포스트
66

7-
<BlogList :posts="posts" />
7+
<PostCardList :posts="posts" />
Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
.blog-list {
2-
margin: 2rem 0;
3-
}
4-
5-
.blog-cards {
6-
display: grid;
7-
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
8-
gap: 1.5rem;
9-
margin-top: 2rem;
10-
}
11-
121
.blog-card {
132
background: var(--vp-c-bg-soft);
143
border: 1px solid var(--vp-c-border);
@@ -25,7 +14,7 @@
2514
transform: translateY(-2px);
2615
}
2716

28-
.blog-cards .blog-card .blog-card-footer {
17+
.blog-card .blog-card-footer {
2918
display: flex;
3019
justify-content: space-between;
3120
align-items: center;
@@ -34,31 +23,31 @@
3423
border-top: 1px solid var(--vp-c-divider);
3524
}
3625

37-
.blog-cards .blog-card .blog-card-meta {
26+
.blog-card .blog-card-meta {
3827
display: flex;
3928
align-items: center;
4029
gap: 0.5rem;
4130
}
4231

43-
.blog-cards .blog-card .blog-card-category-indicator {
32+
.blog-card .blog-card-category-indicator {
4433
width: 12px;
4534
height: 12px;
4635
border-radius: 50%;
4736
display: inline-block;
4837
}
4938

50-
.blog-cards .blog-card .blog-card-category-name {
39+
.blog-card .blog-card-category-name {
5140
color: var(--vp-c-text-2);
5241
font-size: 0.8rem;
5342
font-weight: 500;
5443
}
5544

56-
.blog-cards .blog-card .blog-card-date {
45+
.blog-card .blog-card-date {
5746
color: var(--vp-c-text-2);
5847
font-size: 0.8rem;
5948
}
6049

61-
.blog-cards .blog-card .blog-card-title.blog-card-title {
50+
.blog-card .blog-card-title.blog-card-title {
6251
margin-top: 0;
6352
margin-bottom: 0.5rem;
6453
font-size: 1.1rem;
@@ -72,7 +61,7 @@
7261
color: var(--vp-c-brand-1);
7362
}
7463

75-
.blog-cards .blog-card .blog-card-description {
64+
.blog-card .blog-card-description {
7665
color: var(--vp-c-text-2);
7766
line-height: 1.5;
7867
margin-bottom: 0;
@@ -85,14 +74,3 @@
8574
overflow: hidden;
8675
text-overflow: ellipsis;
8776
}
88-
89-
@media (max-width: 768px) {
90-
.blog-cards {
91-
grid-template-columns: 1fr;
92-
gap: 1rem;
93-
}
94-
95-
.blog-card {
96-
padding: 1rem;
97-
}
98-
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<template>
2+
<article class="blog-card" @click="navigateToPost(post.url)">
3+
<div class="blog-card-content">
4+
<h3 class="blog-card-title">
5+
{{ post.frontmatter.title }}
6+
</h3>
7+
8+
<p class="blog-card-description">
9+
{{ post.frontmatter.description }}
10+
</p>
11+
12+
<div class="blog-card-footer">
13+
<div class="blog-card-meta">
14+
<span
15+
class="blog-card-category-indicator"
16+
:style="{
17+
backgroundColor: getCategoryColor(post.frontmatter.category),
18+
}"
19+
></span>
20+
<span class="blog-card-category-name">{{ post.frontmatter.category }}</span>
21+
</div>
22+
<time class="blog-card-date">
23+
{{ formatDate(post.frontmatter.createdAt) }}
24+
</time>
25+
</div>
26+
</div>
27+
</article>
28+
</template>
29+
30+
<script setup lang="ts">
31+
import { getCategoryColor } from "@/constants/colors";
32+
import "./PostCard.css";
33+
34+
interface Post {
35+
url: string;
36+
frontmatter: {
37+
title: string;
38+
createdAt: string;
39+
category: string;
40+
description: string;
41+
};
42+
}
43+
44+
interface Props {
45+
post: Post;
46+
}
47+
48+
defineProps<Props>();
49+
50+
// 날짜 포맷팅 함수 (yyyy-mm-dd 형식)
51+
function formatDate(dateString: string) {
52+
const date = new Date(dateString);
53+
return date
54+
.toLocaleDateString("ko-KR", {
55+
year: "numeric",
56+
month: "2-digit",
57+
day: "2-digit",
58+
})
59+
.replace(/\. /g, "-")
60+
.replace(/\.$/, "");
61+
}
62+
63+
function navigateToPost(url: string) {
64+
window.location.href = url;
65+
}
66+
</script>

0 commit comments

Comments
 (0)