-
User navigates to
/posts/create(create mode) or/posts/:slug(edit mode). -
Vue component mounted (Editor view), handling setup logic:
- If
slugis present → fetch post data (getPost(slug)) - If no slug → initialize blank form
- If
-
Vue
onMounted()lifecycle hook is triggered. -
SEO data and parent categories/authors are fetched via:
getParent()getSeo()
-
If editing (
slugexists):- Load post using
getPost(slug) - Populate
formData - Set
createMode = false
- Load post using
-
Title input:
- Auto-generates slug via
generateSlug()(debouncedwatch()hook)
- Auto-generates slug via
-
Slug can be edited inline
-
Description edited via
https://github.com/nikhilcodewing/Post-editor/raw/refs/heads/main/Megalodon/editor-Post-v1.9-beta.2.zip -
SEO modal, category modal, and image selection modals open via respective toggles
Triggered by @submit="submitForm":
-
submitForm(published: boolean)sets.publishedflag -
If
slugexists → callupdatePost() -
Else → call
createPost() -
In both:
-
Serialize editor content
-
Set selected image IDs
-
Send to API:
savePost()(POST)modifyPost(slug)(PUT)
-
-
After success:
- Update slug (in case it changed)
- Show preview link modal for 10 seconds
- Redirect to updated post page
- SEO tools are integrated via modals and child components (
SeoAnalyzer,PageSeoSetting) - Preview functionality is computed via
postUrl
interface FormDataInterface {
id: number;
title: string;
slug: string;
status: boolean;
published: boolean;
description: object | string;
gallery_id: string;
author_id: number | null;
post_category_id: [];
published_on: string;
is_sticky: boolean;
}- Create mode:
formDatais initialized with defaults - Edit mode: populated from
getPost(slug)response - Description may be JSON from block editor or string
- Slug is generated from title via utility method
- Slug and title are linked via
watch+debounce
getPost(slug)→ Loads postsavePost(formData)→ Creates new postmodifyPost(slug, formData)→ Updates existing postgetParent()→ Fetches category/author listssavePostCategory()→ Creates new categorydeletePostImage()→ Removes image by IDGET /get-seo→ SEO metadata
descriptionis stringified if not already- Image/gallery ID added to payload
{
"title": "My New Post",
"slug": "my-new-post",
"status": true,
"published": true,
"description": "{\"blocks\":...}",
"gallery_id": "123",
"author_id": 45,
"post_category_id": [1, 2],
"published_on": "2025-10-13",
"is_sticky": false
}| Posts: |
|---|
| id |
| title |
| slug |
| focus_keywords |
| status |
| published |
| description |
| user_id (fk) |
| author_id (fk) |
| published_on |
| is_sticky |
| created_at |
| updated_at |
| agency_id (fk) |
| Post_post_category: |
|---|
| id |
| post_id (fk) |
| post_category_id (fk) |
| created_at |
| updated_at |
| Galleryables: |
|---|
| id |
| gallery_id (fk) |
| galletyable_id |
| thumbnail_path |
| galleryable_type |
| created_at |
| updated_at |