{
return `${year}.${month}.${day}`
}
+/**
+ * 게시물 공개 여부 확인
+ * @param {Object} post - 게시물
+ * @returns {boolean} 공개 여부
+ */
+const isPublicPost = (post) => post.status === 'published'
+ && (!post.publishedAt || new Date(post.publishedAt) <= new Date())
+
+/**
+ * 게시물 상태 표시 문자열 생성
+ * @param {Object} post - 게시물
+ * @returns {string} 상태 표시 문자열
+ */
+const getPostStatusLabel = (post) => {
+ if (post.status === 'published' && !isPublicPost(post)) {
+ return '예약'
+ }
+
+ if (post.status === 'published') {
+ return '발행'
+ }
+
+ if (post.status === 'private') {
+ return '비공개'
+ }
+
+ return '초안'
+}
+
/**
* 게시물 삭제
* @param {Object} post - 삭제할 게시물
@@ -96,7 +125,20 @@ const deletePost = async (post) => {
|
- {{ post.status }}
+
+ {{ getPostStatusLabel(post) }}
+
+
+ {{ formatDate(post.publishedAt) }}
+
|
{{ post.tags.join(', ') || '-' }}
diff --git a/server/repositories/content-repository.js b/server/repositories/content-repository.js
index c985c27..2e3b66b 100644
--- a/server/repositories/content-repository.js
+++ b/server/repositories/content-repository.js
@@ -158,6 +158,10 @@ export const listPosts = async () => {
LEFT JOIN post_tags ON post_tags.post_id = posts.id
LEFT JOIN tags ON tags.id = post_tags.tag_id
WHERE posts.status = 'published'
+ AND (
+ posts.published_at IS NULL
+ OR posts.published_at <= now()
+ )
GROUP BY posts.id
ORDER BY posts.published_at DESC NULLS LAST, posts.created_at DESC
`
@@ -343,6 +347,10 @@ export const getPostBySlug = async (slug) => {
LEFT JOIN tags ON tags.id = post_tags.tag_id
WHERE posts.slug = ${slug}
AND posts.status = 'published'
+ AND (
+ posts.published_at IS NULL
+ OR posts.published_at <= now()
+ )
GROUP BY posts.id
LIMIT 1
`
|