fix: on/off tab in home page

This commit is contained in:
Đỗ Minh Nhật
2026-04-11 04:46:33 +07:00
parent 5b96bfeb87
commit e7929568dc
14 changed files with 48 additions and 26 deletions

View File

@@ -445,14 +445,11 @@ exports.apiGetBlogs = async (req, res) => {
};
exports.api = async (req, res) => {
try {
const docs = await getAllHomeDocs();
let data = docs[0]?.toObject() || {};
// Chỉ dùng doc mới nhất, không merge nhiều docs
const doc = await getHomeDoc();
let data = doc?.toObject() || {};
const baseUrl = `${req.protocol}://${req.get("host")}`;
if (docs.length > 1) {
data.hero = getPreferredHeroData(docs.map((doc) => doc.toObject()));
}
// === Xử lý Blog Preview động ===
const blogPreview = data.blogPreview || {};
let blogs = [];