The comics section has been migrated from a local markdown-based system to a database-driven system using MongoDB. This migration follows the same pattern as the news and gallery sections.
The comics now use the ComicsContentModel which extends ContentModel with additional fields:
series: boolean- Indicates if the comic is a series or one-shotdescription: string- Description of the comic
Created ComicsService (src/lib/services/comicsService.ts) with full CRUD operations:
getAllPosts()- Get all comicsgetPostBySlug(slug)- Get comic by sluggetPostById(postId)- Get comic by IDcreatePost(postData)- Create new comicupdatePost(slug, updates)- Update existing comicdeletePost(slug)- Delete comic- Full comment management (add, update, delete, admin functions)
All comic routes now use the database instead of local markdown files:
src/routes/(waves)/comics/+page.server.ts- Main comics pagesrc/routes/(comic)/+layout.server.ts- Individual comic layoutsrc/routes/(admin)/edit-comic/[slug]/+page.server.ts- Edit comic page
Components updated to use ComicsContentModel:
ComicsSection.svelteLatestComics.svelte- Comic layout and edit pages
Updated API endpoints to use the database:
/api/create-comic- Create new comic/api/edit-comic- Edit existing comic/api/delete-comic- Delete comic
Fixed URL routing issues:
- Comics now properly route to
/comic/sluginstead of incorrect paths - Comic viewer supports both series and one-shot formats
- Proper slug extraction from URLs
To migrate existing comics from markdown files to the database:
node scripts/migrate-comics.jsThis script will:
- Read all existing markdown files in
src/routes/(comic)/ - Parse the frontmatter metadata
- Create corresponding entries in the database
- Preserve all existing data (title, description, series status, etc.)
After running the migration:
- Check that all comics appear in the
/comicspage - Verify individual comic pages load correctly
- Test admin functions (create, edit, delete)
- Ensure comic viewer works for both series and one-shots
Once migration is verified and working:
- Backup the old markdown files
- Remove the old
src/routes/(comic)/directories - Update any remaining references to the old system
The comics collection in MongoDB follows this structure:
{
id: "uuid", // Generated UUID
title: "string", // Comic title
slug: "string", // URL slug (auto-generated)
coverImage: "string", // Path to cover image
date: "string", // ISO date string
comments: [], // Array of comments
excerpt: "string", // Always "Comics"
tags: "string", // Always "comics"
series: boolean, // Is this a series?
description: "string" // Comic description
}- Consistency: Comics now follow the same pattern as news and gallery
- Scalability: Database-driven approach handles larger datasets better
- Performance: Faster loading and better caching
- Maintainability: Centralized data management
- Features: Full comment system and admin functions
- URL Fixes: Proper routing and slug handling
Ensure your Spring Boot backend has the ComicsContentModel and corresponding endpoints:
GET /comics/getall- Get all comicsGET /comics/get/slug/{slug}- Get comic by slugGET /comics/get/postId/{postId}- Get comic by IDPOST /comics/createEntry- Create comicPUT /comics/update- Update comicDELETE /comics/delete/id/{id}- Delete comic
- Comics not loading: Check that the backend API is running and accessible
- Migration errors: Ensure the backend is running before running the migration script
- URL routing issues: Clear browser cache and restart the dev server
- Image paths: Verify that comic images are in the correct
static/images/comics/directory
If issues arise, you can rollback by:
- Restoring the old markdown files
- Reverting the route changes
- Removing the ComicsService references
- Restoring the old data loading methods
With the database system in place, future enhancements could include:
- Comic ratings and reviews
- Reading progress tracking
- Advanced search and filtering
- Comic recommendations
- Analytics and statistics