github

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package github provides a GitHub Contents API implementation of blog.Store for a specific owner and repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

NewClient creates a new Client to make requests to the Github API with a default HTTP client configured with OpenTelemetry instrumentation and a 10-second timeout. Can be configured with ClientOption functions.

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, owner, repo, filePath string) ([]byte, error)

GetFile returns a repository-relative file or directory listing from the GitHub Contents API.

type ClientOption

type ClientOption func(*Client) error

ClientOption configures a Client during construction.

func WithToken

func WithToken(token string) ClientOption

WithToken configures the GitHub token used to authenticate API requests. If set, the token is automatically sent in the Authorization header of each API request.

type Service

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

Service retrieves Markdown articles through the GitHub Contents API using the provided HTTP client.

func NewService

func NewService(client *Client, owner, repo string, opts ...ServiceOption) (*Service, error)

NewService creates a GitHub-backed article store for owner and repo.

func (*Service) GetArticleBySlug

func (s *Service) GetArticleBySlug(ctx context.Context, slug string) (*blog.Article, error)

GetArticleBySlug returns the raw Markdown file named <slug>.md from the configured article directory.

func (*Service) ListArticles

func (s *Service) ListArticles(ctx context.Context) ([]*blog.Metadata, error)

ListArticles returns Markdown filenames from the configured article directory. Subdirectories are not traversed.

type ServiceOption

type ServiceOption func(*Service) error

ServiceOption configures a Service during construction.

func WithArticlePath

func WithArticlePath(articlePath string) ServiceOption

WithArticlePath configures the repository-relative directory containing article files. An empty path explicitly selects the repository root.

Jump to

Keyboard shortcuts

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