Documentation ¶
Index ¶
- Variables
- func Load(sources interface{}, destinations interface{}, selectedSources []string, ...) ([]Source, []Destination, error)
- type Blogger
- func (b Blogger) Authorize(clientId string, clientSecret string, providedRefreshToken string) (string, string, error)
- func (b Blogger) CleanMarkdownPosts(wg *sync.WaitGroup, interval time.Duration, markdownDest *Markdown, ...)
- func (b Blogger) GetBlogId(accessToken string) (string, error)
- func (b Blogger) GetName() string
- func (b Blogger) GetType() string
- func (b Blogger) Pull(options PushPullOptions) (PostData, error)
- func (b Blogger) Push(data PostData, options PushPullOptions) error
- func (b *Blogger) Watch(wg *sync.WaitGroup, interval time.Duration, options PushPullOptions, ...)
- type Destination
- type Frontmatter
- type FrontmatterMapping
- type Markdown
- func (m Markdown) Commit(slug string, push bool) (hash string, err error)
- func (m Markdown) GetName() string
- func (m Markdown) GetType() string
- func (m Markdown) ParseMarkdown(markdown string) (markdownWithoutFrontmatter string, html string, frontmatterObject *Frontmatter, ...)
- func (m Markdown) Pull(options PushPullOptions) (PostData, error)
- func (m Markdown) Push(data PostData, options PushPullOptions) error
- type PostData
- type PushPullOptions
- type Source
- type WatchableSource
Constants ¶
This section is empty.
Variables ¶
var FrontMatterMappings = map[string]string{
"title": "title",
"date": "date",
"date_updated": "lastmod",
"description": "description",
"categories": "categories",
"tags": "tags",
"canonical_url": "canonicalURL",
"managed": "managedByCrossBlogger"}
This is more just a set of defaults compatible with Hugo's frontmatter
Functions ¶
func Load ¶
func Load(sources interface{}, destinations interface{}, selectedSources []string, selectedDestinations []string) ([]Source, []Destination, error)
Load a slice of Destinations and Sources from values passed which the calling module shoukd have read from config If selectedDestinations is empty or nil, all destinations are loaded
Types ¶
type Blogger ¶
type Blogger struct { Name string BlogUrl string CategoryPrefix string // https://developers.google.com/blogger/docs/3.0/reference/posts/delete Overwrite bool GenerateLlmDescriptions bool // contains filtered or unexported fields }
func (Blogger) Authorize ¶
func (b Blogger) Authorize(clientId string, clientSecret string, providedRefreshToken string) (string, string, error)
Return the access token, refresh token (if one was not provided), and an error (if one occurred). The access and refresh tokens are only returned if an error did not occur. In Google Cloud, create OAuth client credentials for a desktop app and enable the Blogger API.
func (Blogger) CleanMarkdownPosts ¶
func (b Blogger) CleanMarkdownPosts(wg *sync.WaitGroup, interval time.Duration, markdownDest *Markdown, options PushPullOptions, errChan chan<- error)
Go through the contentDir of the Markdown struct and delete any posts that are not in the list of known posts. Only delete them if Frontmatter.Managed is true, however.
func (Blogger) Pull ¶
func (b Blogger) Pull(options PushPullOptions) (PostData, error)
Pull the post from the blog and return the post data.
type Destination ¶
type Destination interface { Push(PostData, PushPullOptions) error GetName() string GetType() string }
func CreateDestination ¶
func CreateDestination(destMap map[string]interface{}) (Destination, error)
type Frontmatter ¶
type Frontmatter struct { // TOOD: make frontmatter mappings configurable, somehow Title string Date string DateUpdated string Description string Categories []string Tags []string CanonicalUrl string Managed bool }
func FrontmatterFromMap ¶
func FrontmatterFromMap(m map[string]interface{}, frontmatterMapping FrontmatterMapping) (*Frontmatter, error)
Take a map and return a Frontmatter struct, taking FrontmatterMapping into account
func (*Frontmatter) ToMap ¶
func (f *Frontmatter) ToMap(frontmatterMapping FrontmatterMapping) map[string]interface{}
Take a Frontmatter struct and taking FrontmatterMapping into account, return a map ready to be marshaled into YAML
type FrontmatterMapping ¶
type FrontmatterMapping struct { Title string Date string LastUpdated string Description string Categories string Tags string CanonicalURL string Managed string }
func FrontmatterMappingFromInterface ¶
func FrontmatterMappingFromInterface(m interface{}) (*FrontmatterMapping, error)
Convert a frontmatter_mapping (interface{} due to how Viper works) to a FrontmatterMapping struct
type Markdown ¶
type Markdown struct { Name string // ContentDir, for retrieving, should only be used if treating the passed post path as relative results in no file found ContentDir string GitDir string // Example: []string{"title", "date", "lastmod", "canonicalURL"} FrontmatterMapping Overwrite bool }
func (Markdown) Commit ¶
Commit and optionally push the changes to the Git repository. If contentDir is not a subdirectory of the gitDir, error.
func (Markdown) ParseMarkdown ¶
type PushPullOptions ¶
type Source ¶
type Source interface { Pull(PushPullOptions) (PostData, error) GetName() string GetType() string }