hackernews

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HNPageURLs = map[PageType]string{
	FrontPage:  hnBaseURL,
	NewPage:    hnBaseURL + "/newest",
	PastPage:   hnBaseURL + "/front",
	ActivePage: hnBaseURL + "/active",
	JobsPage:   hnBaseURL + "/jobs",
}

HNPage maps page types to their respective URLs

Functions

This section is empty.

Types

type HNItem

type HNItem struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	URL         string `json:"url"`
	Text        string `json:"text"`
	By          string `json:"by"`
	Score       int    `json:"score"`
	Time        int64  `json:"time"`
	Type        string `json:"type"`
	Kids        []int  `json:"kids"`
	Dead        bool   `json:"dead"`
	Deleted     bool   `json:"deleted"`
	Descendants int    `json:"descendants"`
}

HNItem represents a Hacker News API item

type PageType

type PageType string

PageType represents available HN page types

const (
	FrontPage  PageType = "frontpage"
	NewPage    PageType = "new"
	PastPage   PageType = "past"
	ActivePage PageType = "active"
	JobsPage   PageType = "jobs"
)

type Source

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

Source implements a Hacker News source

func New

func New() *Source

New creates a new Hacker News source with default settings

func (*Source) Configure

func (s *Source) Configure(config map[string]any) error

Configure sets up the source with the provided configuration

func (*Source) Fetch

func (s *Source) Fetch(ctx context.Context, fetcher fetcher.Fetcher) ([]*models.Article, error)

Fetch retrieves articles from Hacker News

func (*Source) Name

func (s *Source) Name() string

Name returns the source name

type StoryItem

type StoryItem struct {
	ID        int
	Title     string
	URL       string
	By        string
	Score     int
	Comments  int
	TimeAgo   string
	Timestamp time.Time
}

StoryItem represents a story parsed from the HN HTML page

Jump to

Keyboard shortcuts

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