提交正式官网
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { getPageSeoByRoute } from '~/server/utils/page-seo'
|
||||
import { fail, ok } from '~/server/utils/response'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const query = getQuery(event)
|
||||
const routeKey = String(query.routeKey || query.route_key || '').trim()
|
||||
const localeRaw = String(query.locale || 'en').trim()
|
||||
|
||||
if (!routeKey) {
|
||||
setResponseStatus(event, 400)
|
||||
return fail('缺少 routeKey 参数', 400)
|
||||
}
|
||||
|
||||
const locale = localeRaw === 'zh' ? 'zh' : 'en'
|
||||
const record = await getPageSeoByRoute(routeKey, locale)
|
||||
|
||||
if (!record) {
|
||||
setResponseStatus(event, 404)
|
||||
return fail('未找到 SEO 配置', 404)
|
||||
}
|
||||
|
||||
return ok(record)
|
||||
})
|
||||
Reference in New Issue
Block a user