페이지 섹션·공개 목록 설정 누적 변경 일괄 반영
페이지 섹션 관리와 홈 Pages 진열장 연동, 공개 목록 표시개수 설정 관련 누적 로컬 변경을 기능 단위로 정리해 반영한다. 문서 이력과 패키지 버전을 v1.9.23으로 맞춰 코드와 문서 상태를 동기화한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { getQuery } from 'h3'
|
||||
import { listPosts } from '../repositories/content-repository'
|
||||
import { canAccessMembershipContent } from '../repositories/member-repository'
|
||||
import { getMemberSession } from '../utils/member-auth'
|
||||
import {
|
||||
DEFAULT_POST_LIST_PAGE_SIZE,
|
||||
normalizeDisplayCount,
|
||||
normalizeListPage
|
||||
} from '../../lib/display-count-settings.js'
|
||||
|
||||
/**
|
||||
* 공개 게시물 목록 API
|
||||
@@ -10,6 +16,37 @@ import { getMemberSession } from '../utils/member-auth'
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = getMemberSession(event)
|
||||
const includeMembership = await canAccessMembershipContent(session?.userId)
|
||||
const query = getQuery(event)
|
||||
const page = normalizeListPage(query.page)
|
||||
const limit = query.limit
|
||||
? normalizeDisplayCount(query.limit, DEFAULT_POST_LIST_PAGE_SIZE)
|
||||
: null
|
||||
const offset = limit ? (page - 1) * limit : 0
|
||||
const paginated = query.paginated === '1'
|
||||
|
||||
return listPosts({ includeMembership })
|
||||
const result = await listPosts({
|
||||
includeMembership,
|
||||
limit,
|
||||
offset,
|
||||
tagSlug: String(query.tag || '').trim(),
|
||||
featuredOnly: query.featured === '1',
|
||||
includeTotal: paginated
|
||||
})
|
||||
|
||||
if (!paginated) {
|
||||
return result
|
||||
}
|
||||
|
||||
const total = Number(result.total || 0)
|
||||
const pageSize = limit || DEFAULT_POST_LIST_PAGE_SIZE
|
||||
|
||||
return {
|
||||
items: result.items,
|
||||
pagination: {
|
||||
page,
|
||||
limit: pageSize,
|
||||
total,
|
||||
totalPages: Math.max(1, Math.ceil(total / pageSize))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user