config

package
v0.0.0-...-f648938 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config parses the Tribo config file and command line arguments and provides access to the values.

The Init() function should be called before trying to use any of the config values.

All values should be accessed from the Values variable.

import (
	"os"

	"github.com/cswilson90/tribo/internal/config"
)

config.Init(os.Args[1:])
baseURLPath := config.Values.BaseUrlPath

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(cmdArgs []string)

Init reads config values from the config file and command line and populates Values. The config is loaded from default values then the config file then the command line with duplicates being overwritten by the last place to specify them. The command line arguments (minus the program name) should be given as an argument to this function.

Types

type TriboConfig

type TriboConfig struct {
	/*
		BaseUrlPath is the base path of the blog on the hostname where it's hosted.
		For example if the blog is hosted at http://example.com/blog/ you would set
		this config value to "/blog".
		The value can be left blank if the blog is served from the root of the site.
	*/
	BaseUrlPath     string `yaml:"baseUrlPath"`
	BlogName        string `yaml:"blogName"`
	BlogDescription string `yaml:"blogDescription"`

	// NoRss controls whether an RSS feed is generated.
	// The default value is false so an RSS feed will be generated.
	NoRss bool `yaml:"noRss"`
	/*
		RssLinkURL is used to build absolute links when linking to posts in the RSS feed.
		It should be set to the scheme and hostname of the URL the blog is served from.
		The BaseURLPath is appended to this value to build the links.
		For example if the blog is served from http://example.com/blog/ you should set
		this value to "http://example.com/".
		Can be ignored if NoRss is set to true.
	*/
	RssLinkUrl string `yaml:"rssLinkUrl"`

	OutputDir   string `yaml:"outputDir"`
	PostsDir    string `yaml:"postsDir"`
	StaticDir   string `yaml:"staticDir"`
	TemplateDir string `yaml:"templateDir"`

	// Parallelism controls the max number of blog posts built in parallel.
	// Defaults to the number of CPUs available on the machine.
	Parallelism int `yaml:"parallelism"`
	// FuturePosts controls whether blog posts with a publish date set in the future
	// are published.
	FuturePosts bool `yaml:"futurePosts"`
	// NoOutputCleanup controls whether Tribo tries to clean up old blog posts in the output.
	// By default Tribo will delete any directories from the output directory that it thinks are
	// from posts which no longer exist or have been moved due to a title or published date change.
	// You can set this option to true to stop this behaviour if it is causing problems.
	NoOutputCleanup bool `yaml:"noOutputCleanup"`
}

TriboConfig stores all config values for Tribo.

var (
	/*
		Values contains all the config variables for Tribo.
		Other parts of the program should access the config values using this variable.

			import "github.com/cswilson/tribo/internal/config"

			baseURLPath := config.Values.BaseUrlPath

	*/
	Values TriboConfig
)

Jump to

Keyboard shortcuts

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