관리자 글 목록 API 응답 경량화
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
<script setup>
|
||||
import { toAdminPostStoredTitle } from '~/lib/admin-post-title.js'
|
||||
|
||||
definePageMeta({
|
||||
layout: 'admin'
|
||||
})
|
||||
@@ -372,7 +370,6 @@ const doesPostMatchSearch = (post, query) => {
|
||||
post.title,
|
||||
post.slug,
|
||||
post.excerpt,
|
||||
post.content,
|
||||
tagText
|
||||
].join(' ').toLowerCase()
|
||||
|
||||
@@ -541,29 +538,6 @@ const selectAnalyticsModalPeriod = async (period) => {
|
||||
await fetchAnalyticsModalData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시물 수정 API 본문을 구성한다.
|
||||
* @param {Object} post - 게시물
|
||||
* @param {Object} [overrides] - 덮어쓸 필드
|
||||
* @returns {Object} PUT 본문
|
||||
*/
|
||||
const buildPostUpdateBody = (post, overrides = {}) => ({
|
||||
title: toAdminPostStoredTitle(post.title),
|
||||
slug: post.slug,
|
||||
content: post.content ?? '',
|
||||
excerpt: post.excerpt ?? '',
|
||||
featuredImage: post.featuredImage ?? null,
|
||||
isFeatured: overrides.isFeatured ?? Boolean(post.isFeatured),
|
||||
seoTitle: post.seoTitle ?? '',
|
||||
seoDescription: post.seoDescription ?? '',
|
||||
canonicalUrl: post.canonicalUrl ?? '',
|
||||
noindex: Boolean(post.noindex),
|
||||
ogImage: post.ogImage ?? null,
|
||||
status: post.status,
|
||||
publishedAt: post.publishedAt,
|
||||
tags: post.tags ?? []
|
||||
})
|
||||
|
||||
/**
|
||||
* 열린 행 메뉴를 닫는다.
|
||||
* @returns {void}
|
||||
@@ -760,9 +734,11 @@ const togglePostFeatured = async (post) => {
|
||||
errorMessage.value = ''
|
||||
|
||||
try {
|
||||
await $fetch(`/admin/api/posts/${post.id}`, {
|
||||
await $fetch(`/admin/api/posts/${post.id}/featured`, {
|
||||
method: 'PUT',
|
||||
body: buildPostUpdateBody(post, { isFeatured: !post.isFeatured })
|
||||
body: {
|
||||
isFeatured: !post.isFeatured
|
||||
}
|
||||
})
|
||||
await refresh()
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user