ghost

package module
v0.0.0-...-73a8b4f Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 10 Imported by: 0

README

go-ghost

GoDoc

go-ghost is a Go (golang) library for accessing the Ghost API.

This is currently a work-in-progress, built specifically to support a Write.as / WriteFreely integration. But contributions (including those to support the full Ghost API) are welcome!

Install

go get -u github.com/writeas/go-ghost

Usage

Create a post:

import (
	"github.com/writeas/go-ghost"
	"github.com/writeas/go-ghost/admin"
)

func main() {
	// NewClient takes your Ghost URL and admin API key
	c := ghost.NewClient("http://localhost:2368", "fc765549cb7e9d05d5ecf2c9:d3e6d27fcf782ceebea59024010aec...")
	err := admin.AddPost(c, ghost.PostParams{
		Title:    ghost.String("My Post Title"),
		Markdown: ghost.String(`This is a **test post** made with the [go-ghost](https://github.com/writeas/go-ghost) library.`),
		Status:   ghost.String("published"),
	})
	if err != nil {
		// Handle error
	}
}

Documentation

Overview

Package ghost provides the binding for Ghost APIs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to the bool value passed in.

func String

func String(v string) *string

String returns a pointer to the string value passed in.

Types

type Author

type Author struct {
	ID              *string `json:"id"`
	Name            *string `json:"name"`
	Slug            *string `json:"slug"`
	ProfileImage    *string `json:"profile_image"`
	CoverImage      *string `json:"cover_image"`
	Bio             *string `json:"bio"`
	Website         *string `json:"website"`
	Location        *string `json:"location"`
	Facebook        *string `json:"facebook"`
	Twitter         *string `json:"twitter"`
	MetaTitle       *string `json:"meta_title"`
	MetaDescription *string `json:"meta_description"`
	URL             *string `json:"url"`
}

type Client

type Client struct {
	URL       string
	Key       string
	Version   string
	GhostPath string
	UserAgent string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url, key string) *Client

NewClient creates a new API client.

func (*Client) Request

func (c *Client) Request(method, path string, data interface{}) (map[string][]interface{}, error)

type Error

type Error struct {
	ID      *string `json:"id"`
	Message *string `json:"message"`
	Context *string `json:"context"`
	Type    *string `json:"type"`
}

func (Error) Error

func (e Error) Error() string

type Post

type Post struct {
	ID                 *string   `json:"id"`
	UUID               *string   `json:"uuid"`
	Title              *string   `json:"title"`
	Slug               *string   `json:"slug"`
	HTML               *string   `json:"html"`
	CommentID          *string   `json:"comment_id"`
	FeatureImage       *string   `json:"feature_image"`
	Featured           *bool     `json:"featured"`
	Page               *bool     `json:"page"`
	MetaTitle          *string   `json:"meta_title"`
	MetaDescription    *string   `json:"meta_description"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
	PublishedAt        time.Time `json:"published_at"`
	CustomExcerpt      *string   `json:"custom_excerpt"`
	OGImage            *string   `json:"og_image"`
	OGTitle            *string   `json:"og_title"`
	OGDescription      *string   `json:"og_description"`
	TwitterImage       *string   `json:"twitter_image"`
	TwitterTitle       *string   `json:"twitter_title"`
	TwitterDescription *string   `json:"twitter_description"`
	CustomTemplate     *string   `json:"custom_template"`
	PrimaryAuthor      *Author   `json:"primary_author"`
	PrimaryTag         *Tag      `json:"primary_tag"`
	URL                *string   `json:"url"`
	Excerpt            *string   `json:"excerpt"`
}

type PostParams

type PostParams struct {
	Title     *string `json:"title"`
	HTML      *string `json:"html,omitempty"`
	Markdown  *string `json:"markdown,omitempty"`
	Mobiledoc *string `json:"mobiledoc,omitempty"`
	Status    *string `json:"status,omitempty"`
}

type Tag

type Tag struct {
	ID              *string   `json:"id"`
	Name            *string   `json:"name"`
	Slug            *string   `json:"slug"`
	Description     *string   `json:"description"`
	FeaturedImage   *string   `json:"featured_image"`
	Visibility      *string   `json:"visibility"`
	MetaTitle       *string   `json:"meta_title"`
	MetaDescription *string   `json:"meta_description"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	Parent          *Tag      `json:"parent"`
}

Directories

Path Synopsis
Package admin supports interacting with the Ghost Admin API.
Package admin supports interacting with the Ghost Admin API.

Jump to

Keyboard shortcuts

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