core/content/content.go
Alex Dunmow 79c558a968 fix: replace any with typed context accessors in SDK
- Define PageContext, PostContext, AuthorContext, CategoryContext,
  MasterPageContext structs for typed context passing
- Define EmbedResolver interface
- Make GetQueries generic: GetQueries[T](ctx) (T, bool)
- Fix Content.BlockNoteToHTML to take map[string]any, not any

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-30 22:39:34 +08:00

48 lines
1.2 KiB
Go

package content
import (
"context"
"github.com/google/uuid"
)
// AuthorProfile is a simplified author representation for plugins.
type AuthorProfile struct {
ID uuid.UUID
Name string
Slug string
Bio string
AvatarURL string
Website string
SocialLinks map[string]string
}
// PageInfo is a simplified page representation for plugins.
type PageInfo struct {
ID uuid.UUID
Slug string
Title string
}
// PostInfo is a simplified post representation for plugins.
type PostInfo struct {
ID uuid.UUID
Slug string
Title string
Excerpt string
FeaturedImageURL string
AuthorID uuid.UUID
}
// Content provides content access for plugins.
// The CMS implements this interface and wires it into ServiceDeps.
type Content interface {
GetAuthorProfile(ctx context.Context, id uuid.UUID) (*AuthorProfile, error)
GetPage(ctx context.Context, slug string) (*PageInfo, error)
GetPost(ctx context.Context, slug string) (*PostInfo, error)
Slugify(text string) string
BlockNoteToHTML(doc map[string]any) string
GenerateExcerpt(html string, maxLen int) string
StripHTML(s string) string
}