사이트 코드와 홈페이지 위젯 추가 v1.5.34

This commit is contained in:
2026-06-02 14:21:47 +09:00
parent 600b0fd1d9
commit 5b78a8c92f
21 changed files with 618 additions and 39 deletions

View File

@@ -0,0 +1,26 @@
import { setHeader } from 'h3'
import { getSiteSettings } from '../repositories/content-repository'
/**
* ads.txt 본문을 정규화한다.
* @param {string} value - 관리자 설정에 저장된 ads.txt 본문
* @returns {string} text/plain 응답 본문
*/
const normalizeAdsTxt = (value) => {
const text = String(value || '').trim()
return text ? `${text}\n` : ''
}
/**
* 루트 ads.txt 응답
* @param {import('h3').H3Event} event - 요청 이벤트
* @returns {Promise<string>} ads.txt 본문
*/
export default defineEventHandler(async (event) => {
setHeader(event, 'Content-Type', 'text/plain; charset=utf-8')
const settings = await getSiteSettings()
return normalizeAdsTxt(settings.adsTxt)
})