Merged
Conversation
Adds a PostType model so admins can create custom content types (e.g. Notes, Links, Recipes), each with its own URL namespace and listing page. The default type is "Post" with slug "posts", preserving all existing URLs. Key changes: - New PostType model with CRUD admin UI - Posts have a PostTypeID foreign key with type-aware permalinks - NoRoute resolves type-prefixed URLs (/notes/2024/01/15/slug) - Writing pages can filter by post type via admin dropdown - Migration seeds default "Post" type and links existing posts/pages - Slug conflict prevention between post types and pages - Updated backlinks regex to handle type-prefixed internal links Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #484 +/- ##
==========================================
- Coverage 47.60% 45.72% -1.88%
==========================================
Files 7 8 +1
Lines 1689 1999 +310
==========================================
+ Hits 804 914 +110
- Misses 811 975 +164
- Partials 74 110 +36 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a configurable PostType concept to support multiple content types (e.g., Notes/Links) with their own URL namespaces and listing pages, while keeping the default posts URLs backward-compatible.
Changes:
- Introduces
PostTypemodel + admin CRUD and UI wiring (dropdowns, navigation). - Updates post/page models, routing (type-prefixed URLs + listing pages), and sitemap generation.
- Extends migrations and tests to seed/attach the default
poststype and validate the new behavior.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| www/js/admin-script.js | Sends post_type_id in create/update payloads and redirects to type-aware URLs. |
| tools/migrate_test.go | Adds assertions that the default post type is seeded and writing pages are linked. |
| tools/migrate.go | Migrates PostType, seeds the default type, links writing pages, and updates internal-link regex. |
| templates/post_type_listing.html | New listing template for a post type (/{typeSlug}). |
| templates/post-admin.html | Adds post type selector to the post edit view. |
| templates/admin_settings.html | Adds “Post Types” link to admin nav. |
| templates/admin_post_types.html | New admin listing/create/delete UI for post types. |
| templates/admin_pages.html | Adds “Post Types” link to admin nav. |
| templates/admin_new_post.html | Adds post type dropdown on the new post form. |
| templates/admin_edit_post_type.html | New admin edit UI for a single post type. |
| templates/admin_edit_page.html | Adds optional writing-page post type filter and saves post_type_id. |
| templates/admin_dashboard.html | Adds “Post Types” link to admin nav. |
| templates/admin_all_posts.html | Shows post type name in the all-posts table and adds nav link. |
| templates/admin.html | Adds “Post Types” link to admin nav. |
| goblog.go | Registers post type CRUD API routes and admin HTML routes. |
| blog/post_type.go | Adds the PostType model and its listing permalink helper. |
| blog/post_test.go | Updates permalink/adminlink tests for type-aware URLs. |
| blog/post.go | Adds PostTypeID/relation and makes permalinks/adminlinks type-aware. |
| blog/page.go | Adds optional PostTypeID to pages (writing-page filtering). |
| blog/blog_test.go | Updates migrations/seeding and adds routing coverage for type-prefixed URLs. |
| blog/blog.go | Preloads PostType, adds post type lookup/listing rendering, routing resolution, and sitemap entries. |
| admin/admin_test.go | Adds post type CRUD API + HTML route coverage and seeds default type in tests. |
| admin/admin.go | Implements post type CRUD endpoints, adds slug conflict checks, and wires post type data into admin views and post create/update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Post type select auto-saves on change (draft-aware onchange handler) - GetBacklinks/GetOutboundLinks now preload PostType so Adminlink() uses correct type slug instead of falling back to /admin/posts/... - Fix N+1 in getPostsByTag: batch-load PostType with single query - Validate PostTypeID exists in CreatePost before inserting - Validate Name is non-empty in UpdatePostType - Validate ID and check existence in DeletePostType before deleting - Add error checking to seedDefaultPostType Create/Update operations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PostTypemodel so admins can create custom content types (e.g. Notes, Links, Recipes), each with its own URL namespace (/notes/2024/01/15/slug) and automatic listing page (/notes)Changes
PostTypewith name, slug, descriptionPostTypeIDforeign key;Permalink()andAdminlink()use type slugPostTypeIDfor writing page filtering/{type}/{yyyy}/{mm}/{dd}/{slug}) and admin equivalentsTest plan
/posts/2024/01/15/slug) work unchanged/notesshows a listing of only "Notes" type posts/notes/2024/01/15/my-noteresolves correctlygo test ./...passesCloses #165
🤖 Generated with Claude Code