Collections
Collections
Section titled âCollectionsâCollections represent dynamic content types that can have multiple entries, such as blog posts, services, team members, and products.
Collection Types
Section titled âCollection TypesâStelo CMS supports various collection types:
Services
Section titled âServicesâBusiness offerings and service descriptions
- Service name and description
- Pricing information
- Feature lists
- Media galleries
Blog Posts
Section titled âBlog PostsâArticles and news content
- Article content with rich text
- Publication dates
- Categories and tags
- Author attribution
Team Members
Section titled âTeam MembersâStaff profiles and biographies
- Photo and contact information
- Role and department
- Bio and expertise
- Social media links
Testimonials
Section titled âTestimonialsâClient reviews and feedback
- Client information
- Review content
- Ratings and recommendations
- Project references
Products
Section titled âProductsâE-commerce catalog items
- Product descriptions
- Pricing and variants
- Image galleries
- Inventory tracking
Collection Schema
Section titled âCollection Schemaâmodel Collection { id String @id @default(cuid()) type CollectionType slug Json // Localized slugs title Json // Localized titles content Json // Localized rich content excerpt Json? // Localized excerpts metadata Json? // Type-specific metadata
published Boolean @default(false) publishedAt DateTime? featured Boolean @default(false) sortOrder Int? // Manual ordering
createdAt DateTime @default(now()) updatedAt DateTime @updatedAt
authorId String? author User? @relation(fields: [authorId], references: [id])
mediaFiles CollectionMedia[]}
enum CollectionType { SERVICE BLOG_POST TEAM_MEMBER TESTIMONIAL PRODUCT PROJECT FAQ CUSTOM}Dynamic Fields
Section titled âDynamic FieldsâCollections support type-specific metadata:
// Service-specific metadata{ price: 1500, duration: "2-3 weeks", features: ["Feature 1", "Feature 2"], category: "web-development"}
// Team member metadata{ position: "Senior Developer", department: "Engineering", email: "john@company.com", social: { linkedin: "https://linkedin.com/in/john", twitter: "@johndoe" }}
// Product metadata{ price: 99.99, sku: "PROD-001", inventory: 50, variants: [ { size: "small", color: "red", price: 89.99 }, { size: "large", color: "blue", price: 109.99 } ]}Collection Management
Section titled âCollection ManagementâCreating Collections
Section titled âCreating Collectionsâconst service = await trpc.collections.create.mutate({ type: "SERVICE", title: { en: "Web Development", fr: "DĂ©veloppement Web" }, content: { en: { body: "<p>Professional web development services...</p>", excerpt: "Custom websites and applications" }, fr: { body: "<p>Services professionnels de dĂ©veloppement web...</p>", excerpt: "Sites web et applications sur mesure" } }, metadata: { price: 2500, duration: "4-6 weeks", features: ["Responsive Design", "SEO Optimization", "CMS Integration"] }});Querying Collections
Section titled âQuerying Collectionsâ// Get all servicesconst services = await trpc.collections.getByType.query({ type: "SERVICE", locale: "en", published: true});
// Get featured itemsconst featured = await trpc.collections.getFeatured.query({ limit: 6});
// Search collectionsconst results = await trpc.collections.search.query({ query: "development", types: ["SERVICE", "BLOG_POST"]});Media Integration
Section titled âMedia IntegrationâCollections can include multiple media files:
- Featured Image: Primary visual representation
- Gallery: Additional images or videos
- Attachments: Documents and files
// Associate media with collectionawait trpc.collections.addMedia.mutate({ collectionId: "collection_123", mediaFileId: "media_456", role: "featured" // featured, gallery, attachment});Sorting and Organization
Section titled âSorting and OrganizationâCollections support various sorting options:
- Manual: Custom sort order
- Chronological: By creation or publication date
- Alphabetical: By title
- Featured: Promoted items first
Collections provide the flexibility to create rich, dynamic content while maintaining the structure and consistency needed for professional websites.