미디어 본문 이미지 사용처 계산 수정
This commit is contained in:
@@ -776,6 +776,46 @@ export const listAdminPosts = async (options = {}) => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 미디어 사용처 계산용 게시물 참조 목록 조회
|
||||
* @returns {Promise<Array<{ id: string, title: string, slug: string, status: string, featuredImage: string | null, content: string }>>} 게시물 미디어 참조 목록
|
||||
*/
|
||||
export const listMediaReferencePosts = async () => {
|
||||
const sql = getPostgresClient()
|
||||
|
||||
if (!sql) {
|
||||
return getSamplePosts().map((post) => ({
|
||||
id: post.id,
|
||||
title: post.title,
|
||||
slug: post.slug,
|
||||
status: post.status,
|
||||
featuredImage: post.featuredImage,
|
||||
content: post.content || ''
|
||||
}))
|
||||
}
|
||||
|
||||
const rows = await sql`
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
slug,
|
||||
status,
|
||||
featured_image,
|
||||
content
|
||||
FROM posts
|
||||
ORDER BY updated_at DESC
|
||||
`
|
||||
|
||||
return rows.map((row) => ({
|
||||
id: row.id,
|
||||
title: toAdminPostFormTitle(row.title),
|
||||
slug: row.slug,
|
||||
status: row.status,
|
||||
featuredImage: row.featured_image,
|
||||
content: row.content || ''
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 게시물 상세 조회
|
||||
* @param {string} id - 게시물 ID
|
||||
@@ -1145,6 +1185,46 @@ export const listPages = async (options = {}) => {
|
||||
return rows.map(mapPageRow)
|
||||
}
|
||||
|
||||
/**
|
||||
* 미디어 사용처 계산용 페이지 참조 목록 조회
|
||||
* @returns {Promise<Array<{ id: string, title: string, slug: string, status: string, featuredImage: string | null, content: string }>>} 페이지 미디어 참조 목록
|
||||
*/
|
||||
export const listMediaReferencePages = async () => {
|
||||
const sql = getPostgresClient()
|
||||
|
||||
if (!sql) {
|
||||
return getSamplePages().map((page) => ({
|
||||
id: page.id,
|
||||
title: page.title,
|
||||
slug: page.slug,
|
||||
status: page.status,
|
||||
featuredImage: page.featuredImage,
|
||||
content: page.content || ''
|
||||
}))
|
||||
}
|
||||
|
||||
const rows = await sql`
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
slug,
|
||||
status,
|
||||
featured_image,
|
||||
content
|
||||
FROM pages
|
||||
ORDER BY updated_at DESC
|
||||
`
|
||||
|
||||
return rows.map((row) => ({
|
||||
id: row.id,
|
||||
title: row.title,
|
||||
slug: row.slug,
|
||||
status: row.status,
|
||||
featuredImage: row.featured_image,
|
||||
content: row.content || ''
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 고정 페이지 목록 조회
|
||||
* @returns {Promise<Array>} 관리자 고정 페이지 목록
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { readdir, rename, rm, stat } from 'node:fs/promises'
|
||||
import { basename, dirname, extname, join, relative } from 'node:path'
|
||||
import { createError } from 'h3'
|
||||
import { getSiteSettings, listAdminPosts, listAdminTags, listPages } from '../repositories/content-repository'
|
||||
import {
|
||||
getSiteSettings,
|
||||
listAdminTags,
|
||||
listMediaReferencePages,
|
||||
listMediaReferencePosts
|
||||
} from '../repositories/content-repository'
|
||||
import { getPostgresClient } from '../repositories/postgres-client'
|
||||
import {
|
||||
getPageCoverThumbnailUrl,
|
||||
@@ -956,8 +961,8 @@ export const listMediaItems = async () => {
|
||||
const items = await readMediaDirectory(uploadRoot)
|
||||
const metadataMap = await getMediaMetadataMap()
|
||||
const [posts, pages, siteSettings, tags] = await Promise.all([
|
||||
listAdminPosts(),
|
||||
listPages(),
|
||||
listMediaReferencePosts(),
|
||||
listMediaReferencePages(),
|
||||
getSiteSettings(),
|
||||
listAdminTags()
|
||||
])
|
||||
@@ -1126,8 +1131,8 @@ export const updateMediaCategories = async (urls, category) => {
|
||||
*/
|
||||
export const deleteMediaItem = async (url) => {
|
||||
const [posts, pages, siteSettings, tags] = await Promise.all([
|
||||
listAdminPosts(),
|
||||
listPages(),
|
||||
listMediaReferencePosts(),
|
||||
listMediaReferencePages(),
|
||||
getSiteSettings(),
|
||||
listAdminTags()
|
||||
])
|
||||
@@ -1187,8 +1192,8 @@ export const renameMediaItem = async (url, name) => {
|
||||
}
|
||||
|
||||
const [posts, pages, siteSettings, tags] = await Promise.all([
|
||||
listAdminPosts(),
|
||||
listPages(),
|
||||
listMediaReferencePosts(),
|
||||
listMediaReferencePages(),
|
||||
getSiteSettings(),
|
||||
listAdminTags()
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user