forked from UKSOURCE/cms.hailearning.edu.vn
Merge branch 'fea/dat-07042026-float-social-buttons' of https://gits.techvanguard.vn/UKSOURCE/cms.hailearning.edu.vn into fea/nhat-06042026-menu-management
This commit is contained in:
138
models/home.js
138
models/home.js
@@ -5,8 +5,53 @@ const { Schema } = mongoose;
|
||||
// Reusable small schemas
|
||||
const LinkSchema = new Schema(
|
||||
{
|
||||
label: { type: String, default: "" },
|
||||
href: { type: String, default: "" },
|
||||
label: { type: String, default: "", maxlength: 32 },
|
||||
href: { type: String, default: "", maxlength: 255 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
|
||||
const FloatingContactBrandSchema = new Schema(
|
||||
{
|
||||
imageSrc: { type: String, default: "", maxlength: 255 },
|
||||
imageAlt: { type: String, default: "", maxlength: 60 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
|
||||
const FloatingContactTriggerSchema = new Schema(
|
||||
{
|
||||
imageSrc: { type: String, default: "", maxlength: 255 },
|
||||
icon: { type: String, default: "fa-comments", maxlength: 64 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
|
||||
const FloatingContactActionSchema = new Schema(
|
||||
{
|
||||
id: { type: String, default: "" },
|
||||
platform: { type: String, default: "" },
|
||||
enabled: { type: Boolean, default: true },
|
||||
label: { type: String, default: "", maxlength: 48 },
|
||||
subtitle: { type: String, default: "", maxlength: 48 },
|
||||
href: { type: String, default: "", maxlength: 255 },
|
||||
iconImage: { type: String, default: "", maxlength: 255 },
|
||||
iconType: { type: String, default: "iconClass" },
|
||||
iconClass: { type: String, default: "", maxlength: 120 },
|
||||
iconText: { type: String, default: "", maxlength: 12 },
|
||||
order: { type: Number, default: 0 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
|
||||
const FloatingContactSchema = new Schema(
|
||||
{
|
||||
enabled: { type: Boolean, default: true },
|
||||
position: { type: String, default: "bottom-right" },
|
||||
panelTitle: { type: String, default: "", maxlength: 72 },
|
||||
brand: { type: FloatingContactBrandSchema, default: () => ({}) },
|
||||
trigger: { type: FloatingContactTriggerSchema, default: () => ({}) },
|
||||
actions: { type: [FloatingContactActionSchema], default: [] },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -14,13 +59,13 @@ const LinkSchema = new Schema(
|
||||
// Hero slide (for multiple hero items in slider)
|
||||
const HeroSlideSchema = new Schema(
|
||||
{
|
||||
title: { type: String, default: "" },
|
||||
subtitle: { type: String, default: "" },
|
||||
description: { type: String, default: "" },
|
||||
title: { type: String, default: "", maxlength: 72 },
|
||||
subtitle: { type: String, default: "", maxlength: 48 },
|
||||
description: { type: String, default: "", maxlength: 220 },
|
||||
primaryButton: { type: LinkSchema, default: () => ({}) },
|
||||
secondaryButton: { type: LinkSchema, default: () => ({}) },
|
||||
heroImage: { type: String, default: "" },
|
||||
videoUrl: { type: String, default: "" },
|
||||
heroImage: { type: String, default: "", maxlength: 255 },
|
||||
videoUrl: { type: String, default: "", maxlength: 255 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -31,28 +76,28 @@ const HeroSchema = new Schema(
|
||||
enabled: { type: Boolean, default: true },
|
||||
|
||||
// Background for whole hero section
|
||||
backgroundImage: { type: String, default: "" },
|
||||
backgroundImage: { type: String, default: "", maxlength: 255 },
|
||||
|
||||
// Multiple slides
|
||||
slides: { type: [HeroSlideSchema], default: [] },
|
||||
|
||||
// Legacy single-slide fields (backward compatible)
|
||||
title: { type: String, default: "" },
|
||||
subtitle: { type: String, default: "" },
|
||||
description: { type: String, default: "" },
|
||||
title: { type: String, default: "", maxlength: 72 },
|
||||
subtitle: { type: String, default: "", maxlength: 48 },
|
||||
description: { type: String, default: "", maxlength: 220 },
|
||||
primaryButton: { type: LinkSchema, default: () => ({}) },
|
||||
secondaryButton: { type: LinkSchema, default: () => ({}) },
|
||||
heroImage: { type: String, default: "" },
|
||||
videoUrl: { type: String, default: "" },
|
||||
heroImage: { type: String, default: "", maxlength: 255 },
|
||||
videoUrl: { type: String, default: "", maxlength: 255 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
|
||||
const WhyChooseUsItemSchema = new Schema(
|
||||
{
|
||||
icon: { type: String, default: "" },
|
||||
title: { type: String, default: "" },
|
||||
description: { type: String, default: "" },
|
||||
icon: { type: String, default: "", maxlength: 255 },
|
||||
title: { type: String, default: "", maxlength: 40 },
|
||||
description: { type: String, default: "", maxlength: 72 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -69,7 +114,7 @@ const WhyChooseUsSchema = new Schema(
|
||||
mainImage: { type: String, default: "" },
|
||||
secondaryImage: { type: String, default: "" },
|
||||
items: { type: [WhyChooseUsItemSchema], default: [] },
|
||||
features: { type: [String], default: [] },
|
||||
features: { type: [{ type: String, maxlength: 96 }], default: [] },
|
||||
ctaButton: { type: LinkSchema, default: () => ({}) },
|
||||
},
|
||||
{ _id: false },
|
||||
@@ -77,10 +122,10 @@ const WhyChooseUsSchema = new Schema(
|
||||
|
||||
const VisaSolutionItemSchema = new Schema(
|
||||
{
|
||||
number: { type: String, default: "" },
|
||||
title: { type: String, default: "" },
|
||||
description: { type: String, default: "" },
|
||||
link: { type: String, default: "" },
|
||||
number: { type: String, default: "", maxlength: 4 },
|
||||
title: { type: String, default: "", maxlength: 56 },
|
||||
description: { type: String, default: "", maxlength: 180 },
|
||||
link: { type: String, default: "", maxlength: 255 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -99,11 +144,11 @@ const VisaSolutionsSchema = new Schema(
|
||||
|
||||
const VisaCountrySchema = new Schema(
|
||||
{
|
||||
name: { type: String, default: "" },
|
||||
code: { type: String, default: "" },
|
||||
flag: { type: String, default: "" },
|
||||
link: { type: String, default: "" },
|
||||
visaTypes: { type: [String], default: [] },
|
||||
name: { type: String, default: "", maxlength: 40 },
|
||||
code: { type: String, default: "", maxlength: 12 },
|
||||
flag: { type: String, default: "", maxlength: 255 },
|
||||
link: { type: String, default: "", maxlength: 255 },
|
||||
visaTypes: { type: [{ type: String, maxlength: 48 }], default: [] },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -124,12 +169,12 @@ const VisaCountriesSchema = new Schema(
|
||||
|
||||
const TestimonialSchema = new Schema(
|
||||
{
|
||||
name: { type: String, default: "" },
|
||||
role: { type: String, default: "" },
|
||||
country: { type: String, default: "" },
|
||||
name: { type: String, default: "", maxlength: 48 },
|
||||
role: { type: String, default: "", maxlength: 48 },
|
||||
country: { type: String, default: "", maxlength: 48 },
|
||||
rating: { type: Number, default: 5 },
|
||||
comment: { type: String, default: "" },
|
||||
avatar: { type: String, default: "" },
|
||||
comment: { type: String, default: "", maxlength: 280 },
|
||||
avatar: { type: String, default: "", maxlength: 255 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -162,8 +207,8 @@ const VideoGallerySchema = new Schema(
|
||||
|
||||
const FaqItemSchema = new Schema(
|
||||
{
|
||||
question: { type: String, default: "" },
|
||||
answer: { type: String, default: "" },
|
||||
question: { type: String, default: "", maxlength: 120 },
|
||||
answer: { type: String, default: "", maxlength: 320 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -184,10 +229,10 @@ const FaqSchema = new Schema(
|
||||
|
||||
const AchievementItemSchema = new Schema(
|
||||
{
|
||||
value: { type: String, default: "" },
|
||||
suffix: { type: String, default: "" },
|
||||
label: { type: String, default: "" },
|
||||
description: { type: String, default: "" },
|
||||
value: { type: String, default: "", maxlength: 6 },
|
||||
suffix: { type: String, default: "", maxlength: 4 },
|
||||
label: { type: String, default: "", maxlength: 40 },
|
||||
description: { type: String, default: "", maxlength: 120 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -206,9 +251,9 @@ const AchievementsSchema = new Schema(
|
||||
|
||||
const VisaConsultancyItemSchema = new Schema(
|
||||
{
|
||||
name: { type: String, default: "" },
|
||||
icon: { type: String, default: "" },
|
||||
year: { type: String, default: "" },
|
||||
name: { type: String, default: "", maxlength: 48 },
|
||||
icon: { type: String, default: "", maxlength: 255 },
|
||||
year: { type: String, default: "", maxlength: 8 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -222,7 +267,7 @@ const VisaConsultancySchema = new Schema(
|
||||
|
||||
const BrandItemSchema = new Schema(
|
||||
{
|
||||
logo: { type: String, default: "" },
|
||||
logo: { type: String, default: "", maxlength: 255 },
|
||||
},
|
||||
{ _id: false },
|
||||
);
|
||||
@@ -247,16 +292,16 @@ const PartnersSchema = new Schema(
|
||||
|
||||
const BlogPreviewItemSchema = new Schema(
|
||||
{
|
||||
title: { type: String, default: "" },
|
||||
excerpt: { type: String, default: "" },
|
||||
category: { type: String, default: "" },
|
||||
title: { type: String, default: "", maxlength: 120 },
|
||||
excerpt: { type: String, default: "", maxlength: 280 },
|
||||
category: { type: String, default: "", maxlength: 48 },
|
||||
date: { type: String, default: "" }, // keep as string for easy JSON compatibility (e.g. "2025-08-20")
|
||||
author: {
|
||||
name: { type: String, default: "" },
|
||||
name: { type: String, default: "", maxlength: 48 },
|
||||
avatar: { type: String, default: "" },
|
||||
},
|
||||
comments: { type: Number, default: 0 },
|
||||
link: { type: String, default: "" },
|
||||
link: { type: String, default: "", maxlength: 255 },
|
||||
thumbnail: { type: String, default: "" },
|
||||
},
|
||||
{ _id: false },
|
||||
@@ -296,6 +341,7 @@ const HomeSchema = new Schema(
|
||||
achievements: { type: AchievementsSchema, default: () => ({}) },
|
||||
partners: { type: PartnersSchema, default: () => ({}) },
|
||||
blogPreview: { type: BlogPreviewSchema, default: () => ({}) },
|
||||
floatingContact: { type: FloatingContactSchema, default: () => ({}) },
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
|
||||
Reference in New Issue
Block a user