Documentation
¶
Index ¶
- func Ptr[T any](v T) *T
- type Article
- type ArticleGenerator
- func (g *ArticleGenerator) ConvertIssueToArticle(issue *github.Issue) *Article
- func (g *ArticleGenerator) Generate(ctx context.Context, username, repository string) (int, error)
- func (g *ArticleGenerator) GetIssues(ctx context.Context, username, repository string) ([]*github.Issue, error)
- func (g *ArticleGenerator) SaveArticle(ctx context.Context, article *Article) error
- type ArticleRenderer
- type ArticleService
- type ArticleStore
- type AssetFetcher
- type FileSystemArticleRepository
- type FrontMatter
- type GitHubIssueRepository
- type HTTPImageRepository
- type HugoArticleRenderer
- type Image
- type ImageAsset
- type IssueListQuery
- type IssueStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
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 ¶
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 ¶
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.
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.
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 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.