Dynamic Content Management
Understanding how content is structured and managed in NestSaaS
NestSaaS uses a flexible content model centered around Articles, with metadata that adapts to different content types. This approach allows you to manage diverse content through a unified interface while maintaining the specific characteristics needed for each content type.
Content Model
The core of NestSaaS's content management is the Article model, which provides a flexible structure for all types of content.
Article Structure
Each Article includes:
- Core Fields: Standard fields available for all content
- Metadata: Flexible JSON fields that vary based on the Space type
- Relationships: Connections to categories, tags, and other entities
Core Fields
All Articles include these standard fields:
Field | Type | Description |
---|---|---|
id | number | Unique identifier |
spaceSlug | string | Associated Space slug |
slug | string | URL-friendly identifier |
title | string | Article title |
excerpt | string | Brief summary |
content | string | Main content (stored as html text) |
status | enum | Publication status |
order | number | Sort order |
featured | boolean? | Featured |
protected | boolean? | Protected access |
coverImage | string? | Cover image URL |
blurhash | string? | Cover image blurhash |
website | string? | Cover image blurhash |
draft | json? | content draft for block editor |
metadata | JSON | Flexible metadata fields |
createdAt | date | Creation timestamp |
updatedAt | date | Last update timestamp |
publishedAt | date | Publication timestamp |
categoryId | number | Primary category ID |
authorId | number | User ID |
Content Status
Articles can have different statuses throughout their lifecycle:
- DRAFT: Work in progress, not publicly visible
- APPLICATION: Submitted for review (for user submissions)
- APPROVED: Submission that was approved
- REJECTED: Submission that was not approved
- PUBLISHED: Live and publicly accessible
- ARCHIVED: No longer active but preserved
- HIDDEN: Temporarily hidden from public view
Metadata
The metadata field is a flexible JSON structure that stores Space-specific fields. The structure of this metadata is defined by the Space configuration.
Example metadata for a product:
Example metadata for a restaurants listing:
Content Editor
NestSaaS includes a powerful block-based content editor similar to Notion, allowing you to create rich, structured content.
Content Management
Creating Content
Content is created through the admin interface:
- Select the Space where you want to create content
- Click "New Article" (or the Space-specific label)
- Fill in the core fields (title, excerpt, etc.)
- Add content using the block editor
- Complete the metadata fields specific to the Space
- Set the category and tags
- Save as draft or publish immediately
Editing Content
The editing process includes:
- Modify any field of existing article
- Delete an existing article
Publishing Workflow
NestSaaS supports flexible publishing workflows:
- Simple: Draft → Published
- User Submissions: Application → Review → Published/Rejected
Content Protection(Not Currently, Future support)
Articles can be protected with different access controls:
- Public: Accessible to everyone
- Member: Requires user account
- Paid: Requires subscription or purchase
- Custom: Programmatic access control based on user attributes
Server Actions
Querying Content
NestSaaS provide queries in the server actions actions/article-actions.ts
getArticles( spaceSlug: string, filter: ArticleFilter = {}, sort: ArticleSortBy = [{ featured: "desc" }, { publishedAt: "desc" }], pagination?: ArticlePagination)
getArticleBySlug(spaceSlug, slug)
getRelatedArticles(spaceSlug: string, articleId: number, limit = 3)
getPopularArticles(spaceSlug: string, limit = 5)
getLatestArticles(spaceSlug: string, limit = 5)
getArticlesByCategory(spaceSlug: string, categorySlug: string, pagination?: ArticlePagination)
getArticlesByTag(spaceSlug: string, tagSlug: string, pagination?: ArticlePagination)
Full-Text Search
NestSaaS includes built-in full-text search capabilities, we create a GIN index for faster full-text search.
Adds full-text search capabilities to the articles table:
- Adds a
searchVector
column of typetsvector
- Creates a GIN index for faster full-text search
- Sets up a trigger to automatically update the search vector when articles are inserted or updated
- Updates existing records with search vectors
and then you can excute full-text search on articles:
Best Practices
-
Use Meaningful Titles and Slugs: Create clear, descriptive titles and SEO-friendly slugs.
-
Optimize Cover Images: Use high-quality images that represent your content well.
-
Write Good Excerpts: Craft compelling excerpts that summarize your content and encourage clicks.
-
Structure Content with Blocks: Use the block editor to create well-structured, scannable content.
-
Complete Metadata: Fill in all relevant metadata fields to enhance searchability and functionality.
-
Categorize Properly: Assign appropriate categories and tags to improve content organization.
-
Preview Before Publishing: Always preview your content on different devices before publishing.
Next Steps
- Dynamic Content Organization - Learn how to organize your content
- Media Library - Manage images and other media for your content
- Content Editor - Detailed guide to using the content editor