core

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to the given value.

Types

type Article

type Article struct {
	Author      string      `yaml:"author"`
	Title       string      `yaml:"title"`
	Content     string      `yaml:"-"`
	Date        string      `yaml:"date"`
	Category    string      `yaml:"categories"`
	Tags        []string    `yaml:"tags"`
	Draft       bool        `yaml:"draft"`
	FrontMatter FrontMatter `yaml:"-"`
	Key         string      `yaml:"-"`
	Images      []*Image    `yaml:"-"`
}

Article represents one generated content entry.

func (*Article) Clone

func (a *Article) Clone() *Article

func (*Article) ParseDateTime

func (a *Article) ParseDateTime() (time.Time, error)

type ArticleGenerator

type ArticleGenerator struct {
	// contains filtered or unexported fields
}

ArticleGenerator generates Hugo articles from GitHub issues.

func NewArticleGenerator

func NewArticleGenerator(conf config.Config, token string) (*ArticleGenerator, error)

NewArticleGenerator creates a new ArticleGenerator.

func NewArticleGeneratorWithLogger

func NewArticleGeneratorWithLogger(conf config.Config, token string, logger *slog.Logger) (*ArticleGenerator, error)

NewArticleGeneratorWithLogger creates a new ArticleGenerator with an injected logger.

func (*ArticleGenerator) ConvertIssueToArticle

func (g *ArticleGenerator) ConvertIssueToArticle(issue *github.Issue) *Article

ConvertIssueToArticle converts an issue into an Article entity.

func (*ArticleGenerator) Generate

func (g *ArticleGenerator) Generate(ctx context.Context, username, repository string) (int, error)

Generate fetches issues, converts them to articles, and saves them.

func (*ArticleGenerator) GetIssues

func (g *ArticleGenerator) GetIssues(ctx context.Context, username, repository string) ([]*github.Issue, error)

GetIssues retrieves all issues from the specified repository.

func (*ArticleGenerator) SaveArticle

func (g *ArticleGenerator) SaveArticle(ctx context.Context, article *Article) error

SaveArticle stores an Article in the filesystem.

type ArticleRenderer

type ArticleRenderer interface {
	Render(article *Article) (string, error)
}

ArticleRenderer renders an article into a serialized representation.

func NewHugoArticleRenderer

func NewHugoArticleRenderer() ArticleRenderer

NewHugoArticleRenderer creates a HugoArticleRenderer.

type ArticleService

type ArticleService struct {
	// contains filtered or unexported fields
}

ArticleService converts issues into articles.

func NewArticleService

func NewArticleService(conf config.Config) *ArticleService

NewArticleService creates a new ArticleService.

func (*ArticleService) ConvertIssueToArticle

func (s *ArticleService) ConvertIssueToArticle(issue *github.Issue) *Article

ConvertIssueToArticle converts a GitHub issue into an Article.

type ArticleStore

type ArticleStore interface {
	Save(ctx context.Context, article *Article, conf config.Config) error
}

func NewFileSystemArticleRepository

func NewFileSystemArticleRepository(imageRepo AssetFetcher) ArticleStore

NewFileSystemArticleRepository creates a new FileSystemArticleRepository.

func NewFileSystemArticleRepositoryWithLogger

func NewFileSystemArticleRepositoryWithLogger(imageRepo AssetFetcher, logger *slog.Logger) ArticleStore

NewFileSystemArticleRepositoryWithLogger creates a new FileSystemArticleRepository with an injected logger.

type AssetFetcher

type AssetFetcher interface {
	Fetch(ctx context.Context, image *Image) (*ImageAsset, error)
}

func NewHTTPImageRepository

func NewHTTPImageRepository(token string) AssetFetcher

NewHTTPImageRepository creates a new HTTPImageRepository.

func NewHTTPImageRepositoryWithLogger

func NewHTTPImageRepositoryWithLogger(token string, logger *slog.Logger) AssetFetcher

NewHTTPImageRepositoryWithLogger creates a new HTTPImageRepository with an injected logger.

type FileSystemArticleRepository

type FileSystemArticleRepository struct {
	// contains filtered or unexported fields
}

FileSystemArticleRepository stores articles in the filesystem.

func (*FileSystemArticleRepository) Save

func (r *FileSystemArticleRepository) Save(ctx context.Context, article *Article, conf config.Config) error

Save stores an article in the filesystem.

type FrontMatter

type FrontMatter struct {
	// contains filtered or unexported fields
}

FrontMatter stores normalized metadata values.

func EmptyFrontMatter

func EmptyFrontMatter() FrontMatter

func NewFrontMatter

func NewFrontMatter(values map[string]any) FrontMatter

func (FrontMatter) IsEmpty

func (fm FrontMatter) IsEmpty() bool

func (FrontMatter) MarshalYAML

func (fm FrontMatter) MarshalYAML() (data []byte, err error)

func (FrontMatter) Values

func (fm FrontMatter) Values() map[string]any

type GitHubIssueRepository

type GitHubIssueRepository struct {
	// contains filtered or unexported fields
}

GitHubIssueRepository retrieves issues via the GitHub API.

func (*GitHubIssueRepository) ListIssues

func (r *GitHubIssueRepository) ListIssues(ctx context.Context, query IssueListQuery) ([]*github.Issue, error)

ListIssues retrieves all issues from the specified repository.

type HTTPImageRepository

type HTTPImageRepository struct {
	// contains filtered or unexported fields
}

HTTPImageRepository downloads images over HTTP.

func (*HTTPImageRepository) Fetch

func (r *HTTPImageRepository) Fetch(ctx context.Context, image *Image) (*ImageAsset, error)

Fetch retrieves an image stream over HTTP.

type HugoArticleRenderer

type HugoArticleRenderer struct{}

HugoArticleRenderer renders articles as Hugo-compatible markdown.

func (HugoArticleRenderer) Render

func (HugoArticleRenderer) Render(article *Article) (string, error)

Render renders an article as Hugo-compatible markdown.

type Image

type Image struct {
	URL  string
	Time string
	ID   int
}

Image represents one image reference found in the issue body.

func NewImage

func NewImage(url, time string, id int) *Image

type ImageAsset

type ImageAsset struct {
	Body        io.ReadCloser
	ContentType string
}

ImageAsset is a streamed remote asset payload.

type IssueListQuery added in v1.1.0

type IssueListQuery struct {
	Username   string
	Repository string
	Labels     []string
}

type IssueStore

type IssueStore interface {
	ListIssues(ctx context.Context, query IssueListQuery) ([]*github.Issue, error)
}

func NewGitHubIssueRepository

func NewGitHubIssueRepository(token string) (IssueStore, error)

NewGitHubIssueRepository creates a new GitHubIssueRepository.

func NewGitHubIssueRepositoryWithLogger

func NewGitHubIssueRepositoryWithLogger(token string, logger *slog.Logger) (IssueStore, error)

NewGitHubIssueRepositoryWithLogger creates a new GitHubIssueRepository with an injected logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL