config

package
v0.0.0-...-bc49051 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagConfig      = "config"
	FlagDryRun      = "dry-run"
	FlagParallelism = "parallelism"
)

Flag constants

Variables

View Source
var (
	Version = ""
	GitRef  = ""
)

These are set by ldflags.

Functions

func ReadConfig

func ReadConfig(ctx *cli.Context) (cfg Config, flags Flags, configPaths []string, err error)

ReadConfig reads a config at a given path as yaml.

Types

type Cloudfront

type Cloudfront struct {
	Distribution string `json:"distribution,omitempty" yaml:"distribution,omitempty"`
}

Cloudfront represents cloudfront options.

func (Cloudfront) IsZero

func (cf Cloudfront) IsZero() bool

IsZero returns if the config is set or not.

type Config

type Config struct {
	// Title is the title for the blog.
	Title string `json:"title" yaml:"title"`
	// Author is your name.
	Author string `json:"author" yaml:"author"`
	// Description is a description for the blog, will be used in html head meta.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// BaseURL is the base url for the blog.
	BaseURL string `json:"baseURL,omitempty" yaml:"baseURL,omitempty"`

	// PostsPath is the path to the posts to compile.
	PostsPath string `json:"postsPath,omitempty" yaml:"postsPath,omitempty"`
	// PagesPath is the path to a folder with pages to compile.
	// They are rendered and copied to the root of the output.
	PagesPath string `json:"pagesPath,omitempty" yaml:"pagesPath,omitempty"`
	// OutputPath is the compiled site path.
	OutputPath string `json:"outputPath,omitempty" yaml:"outputPath,omitempty"`
	// PatialsPath is the path to a folder with partials to include
	// when rendering pages and the posts.
	PartialsPath string `json:"partialsPath,omitempty" yaml:"partialsPath,omitempty"`
	// StaticPath is the path to a folder with static files to copy over.
	StaticsPath string `json:"staticsPath,omitempty" yaml:"staticsPath,omitempty"`
	// ThumbnailCachePath is the path to the thumbnail cache.
	ThumbnailCachePath string `json:"thumbnailCachePath,omitempty" yaml:"thumbnailCachePath,omitempty"`

	// SlugTemplate is the template for post slugs.
	// It defaults to "/{{ .Meta.Posted.Year }}/{{ .Meta.Posted.Month }}/{{ .Meta.Posted.Day }}/{{ .Meta.Title | slugify }}/"
	SlugTemplate string `json:"slugTemplate,omitempty" yaml:"slugTemplate,omitempty"`
	// ImagePostTemplate is the path to the post template file.
	// It is what is rendered when you go to /<POST_SLUG>/ for image posts.
	ImagePostTemplatePath string `json:"imagePostTemplatePath,omitempty" yaml:"imagePostTemplatePath,omitempty"`
	// TextPostTemplatePath is the path to the text post template file.
	// It is what is rendered when you go to /<POST_SLUG>/ for text posts.
	TextPostTemplatePath string `json:"textPostTemplatePath,omitempty" yaml:"textPostTemplatePath,omitempty"`
	// TagTemplate is the path to the tag template file.
	// It is what is rendered when you go to /tags/:tag_name
	TagTemplatePath string `json:"tagTemplatePath,omitempty" yaml:"tagTemplatePath,omitempty"`
	// ImageSizes lets you set what size thumbnails to create from post files.
	// This defaults to 2048px, 1024px, and 512px.
	ImageSizes []int `json:"imageSizes,omitempty" yaml:"imageSizes,omitempty"`
	// Extra is optional and allows you to provide variables for templates.
	Extra map[string]string `json:"extra,omitempty" yaml:"extra,omitempty"`

	// S3 governs how the blog is deployed.
	S3 S3 `json:"s3,omitempty" yaml:"s3,omitempty"`
	// Cloudfront governs options for how the s3 files are cached.
	Cloudfront Cloudfront `json:"cloudfront,omitempty" yaml:"cloudfront,omitempty"`

	// PostSortKey is the key that you can use to sort posts in the feed by.
	PostSortKey string `json:"postSortKey,omitempty" yaml:"postSortKey,omitempty"`
	// PostSortAscending determines if we should sort ascending or descending.
	PostSortAscending *bool `json:"postSortAscending,omitempty" yaml:"postSortAscending,omitempty"`
	// SkipImageOriginal instructs the engine to not copy the original image.
	SkipCopyOriginalImage bool `json:"skipImageOriginal,omitempty" yaml:"skipImageOriginal,omitempty"`
	// SkipTags instructs the engine to not create tag summary pages.
	SkipGenerateTags bool `json:"skipGenerateTags,omitempty" yaml:"skipGenerateTags,omitempty"`
	// SkipGenerateJSONData instructs the engine not to create a data.json file.
	SkipGenerateJSONData bool `json:"skipGenerateJSONData,omitempty" yaml:"skipGenerateJSONData,omitempty"`
}

Config is the blog config

func (Config) AuthorOrDefault

func (c Config) AuthorOrDefault() string

AuthorOrDefault returns the author or a default.

func (Config) BaseURLOrDefault

func (c Config) BaseURLOrDefault() string

BaseURLOrDefault returns the base url or a default.

func (*Config) Fields

func (c *Config) Fields() []Field

Fields returns fields to prompt for when creating a new config.

func (Config) ImagePostTemplateOrDefault

func (c Config) ImagePostTemplateOrDefault() string

ImagePostTemplateOrDefault returns the single post template or a default.

func (Config) ImageSizesOrDefault

func (c Config) ImageSizesOrDefault() []int

ImageSizesOrDefault returns the image sizes or a default set.

func (Config) OutputPathOrDefault

func (c Config) OutputPathOrDefault() string

OutputPathOrDefault returns the output path.

func (Config) PagesPathOrDefault

func (c Config) PagesPathOrDefault() string

PagesPathOrDefault returns page file paths or defaults.

func (Config) PartialsPathOrDefault

func (c Config) PartialsPathOrDefault() string

PartialsPathOrDefault returns partial file paths or defaults.

func (Config) PostSortAscendingOrDefault

func (c Config) PostSortAscendingOrDefault() bool

PostSortAscendingOrDefault returns the post sort direction or a default.

func (Config) PostSortKeyOrDefault

func (c Config) PostSortKeyOrDefault() string

PostSortKeyOrDefault returns the post sort key or a default.

func (Config) PostsPathOrDefault

func (c Config) PostsPathOrDefault() string

PostsPathOrDefault returns the images path.

func (Config) SlugTemplateOrDefault

func (c Config) SlugTemplateOrDefault() string

SlugTemplateOrDefault returns the slug template or default.

func (Config) StaticsPathOrDefault

func (c Config) StaticsPathOrDefault() string

StaticsPathOrDefault returns static file paths or defaults.

func (Config) TagTemplateOrDefault

func (c Config) TagTemplateOrDefault() string

TagTemplateOrDefault returns the single tag template or a default.

func (Config) TextPostTemplateOrDefault

func (c Config) TextPostTemplateOrDefault() string

TextPostTemplateOrDefault returns the single text post template or a default.

func (Config) ThumbnailCachePathOrDefault

func (c Config) ThumbnailCachePathOrDefault() string

ThumbnailCachePathOrDefault returns static file paths or defaults.

func (Config) TitleOrDefault

func (c Config) TitleOrDefault() string

TitleOrDefault returns the title or a default.

type Extra

type Extra = map[string]any

Extra is just exta data you might want to pass into the renderer.

type Field

type Field struct {
	Prompt         string
	FieldReference *string
	Default        string
}

Field is a field to prompt for on the config.

type Flags

type Flags struct {
	Config      string
	DryRun      bool
	Parallelism int
}

Flags are persistent flags.

type S3

type S3 struct {
	Region string `json:"region,omitempty" yaml:"region,omitempty"`
	Bucket string `json:"bucket,omitempty" yaml:"bucket,omitempty"`
}

S3 is an optional s3 config.

func (S3) IsZero

func (c S3) IsZero() bool

IsZero returns if the s3 bucket config is set.

Jump to

Keyboard shortcuts

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