fix: restore dark post view and API revalidation

This commit is contained in:
lezi-fun committed 2026-08-11 13:34:44 +08:00
1 parent 773db0dec7
commit b60aff7c25
12 files changed
+100 -31

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
// GET /api/custom-pages/[name] — 公开单个页面
import pool from '@/lib/db';
import { jsonWithEtag } from '@/lib/http-cache';
export async function GET(req, { params }) {
try {
@@ -10,7 +11,7 @@ export async function GET(req, { params }) {
if (r.rows.length === 0) {
return Response.json({ error: '页面不存在' }, { status: 404 });
}
return Response.json(r.rows[0]);
return jsonWithEtag(req, r.rows[0]);
} catch {
return Response.json({ error: '服务器错误' }, { status: 500 });
}
+3 -2
View File
@@ -1,12 +1,13 @@
// GET /api/custom-pages — 公开页面列表
import pool from '@/lib/db';
import { jsonWithEtag } from '@/lib/http-cache';
export async function GET() {
export async function GET(req) {
try {
const r = await pool.query(
'SELECT id, name, title FROM custom_pages WHERE enabled = true ORDER BY created_at'
);
return Response.json(r.rows);
return jsonWithEtag(req, r.rows);
} catch {
return Response.json({ error: '服务器错误' }, { status: 500 });
}