Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #478 +/- ##
==========================================
+ Coverage 43.23% 45.36% +2.13%
==========================================
Files 6 6
Lines 1071 1186 +115
==========================================
+ Hits 463 538 +75
- Misses 573 607 +34
- Partials 35 41 +6 ☔ 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 backlinks feature to the blog by persisting (1) internal post-to-post link relationships derived from markdown content and (2) external backlinks derived from HTTP Referer headers, then exposing this data in admin-only UI sections.
Changes:
- Introduces
BacklinkandExternalBacklinkmodels plus post-level external link extraction. - Adds backlink computation/retrieval + referer tracking logic to blog handlers.
- Extends migrations to create/seed backlink data and adds tests for both internal and external backlinks.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
tools/migrate.go |
Migrates new tables and seeds internal backlinks for existing posts. |
blog/post.go |
Adds backlink models and Post.ExternalLinks() extraction helper. |
blog/blog.go |
Implements backlink computation/queries and referer tracking; wires tracking into handlers. |
admin/admin.go |
Triggers backlink recomputation on post create/update; passes backlink data to templates. |
templates/post.html |
Adds admin-only sections for backlinks/outbound links/external links/external backlinks. |
templates/post-admin.html |
Adds backlink/outbound/external link sections to the admin post view. |
blog/blog_test.go |
Adds tests covering internal backlinks and external referer tracking behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2054e7c to
6d17025
Compare
Implements issue #164: internal backlinks (which posts link to each other), external backlink tracking via HTTP Referer headers, and external link extraction from post content. Backlink sections are admin-only and visible on both the regular post page and the admin post editor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix swapped logged_in/is_admin in admin Post handler - Add indexes on Backlink fields and uniqueIndex on ExternalBacklink - Use gorm:"type:text" for Referer column to support long URLs - Distinguish ErrRecordNotFound from other DB errors in TrackReferer - Use gorm.Expr for atomic hit_count increment - Compare hostnames without ports for self-referral detection - Fix comment: "Skip non-HTTP(S) schemes" - Use exact slug match and bounded date range in ComputeBacklinks/seedBacklinks - Log errors from strconv.Atoi and db.Create in seedBacklinks - Add test for self-referral with port mismatch Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6d17025 to
8cca2a8
Compare
Summary
/posts/YYYY/MM/DD/sluglinksChanges
blog/post.go: AddedBacklink,ExternalBacklinkmodels andExternalLinks()methodblog/blog.go: AddedComputeBacklinks,GetBacklinks,GetOutboundLinks,GetExternalBacklinks,TrackReferermethods; wired referer tracking intoPost()andNoRoute()handlersadmin/admin.go: CallComputeBacklinksafter create/update; pass backlink data to admin templatetemplates/post.html: Added admin-only backlink sectionstemplates/post-admin.html: Added backlink sectionstools/migrate.go: Added new models toAutoMigrate; addedseedBacklinksfor existing postsblog/blog_test.go: AddedTestBacklinksandTestExternalBacklinkstestsTest plan
go test ./...passesCloses #164
🤖 Generated with Claude Code