ghost

package
v0.0.0-...-19dffb3 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

type Host struct {
	SiteURL    string
	ContentKey string
}

Host represents the target Ghost instance to fetch data from.

type Post

type Post struct {
	Title        string    `json:"title"`
	URL          string    `json:"url"`
	HTML         string    `json:"html"`
	ReadingTime  int       `json:"reading_time"`
	CreatedAt    time.Time `json:"created_at"`
	PublishedAt  time.Time `json:"published_at"`
	PublishedAgo string
	UpdatedAt    time.Time `json:"updated_at"`
	Updated      bool
	UpdatedAgo   string
}

Post is the full data for a post when fetched individually.

type PostMeta

type PostMeta struct {
	Title        string    `json:"title"`
	Slug         string    `json:"slug"`
	Excerpt      string    `json:"excerpt"`
	ReadingTime  int       `json:"reading_time"`
	PublishedAt  time.Time `json:"published_at"`
	PublishedAgo string
}

PostMeta is the metadata for a post, returned when fetching several posts.

type PostResp

type PostResp struct {
	Posts []Post `json:"posts"`
}

PostResp is the response from the Ghost API for a single post.

func GetPost

func GetPost(c *cache.Cache, h Host, slug string) (r PostResp, found bool, err error)

GetPost fetches a single post from Ghost.

type PostsResp

type PostsResp struct {
	Posts []PostMeta `json:"posts"`
	Meta  struct {
		Pagination struct {
			Page  int `json:"page"`
			Limit int `json:"limit"`
			Pages int `json:"pages"`
			Total int `json:"total"`
			Next  int `json:"next"`
			Prev  int `json:"prev"`
		} `json:"pagination"`
	} `json:"meta"`
}

PostsResp is the response from the Ghost API for several posts.

func GetPosts

func GetPosts(c *cache.Cache, h Host, page int) (PostsResp, error)

GetPosts fetches a page of posts from Ghost.

Jump to

Keyboard shortcuts

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