config

package
v0.0.0-...-a509ab1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The name of the configuration file which contains the main application config
	ConfigFile = "config.yml"
)

Variables

View Source
var ErrInvalidSMTPConfig = errors.New("invalid SMTP configuration")

ErrInvalidSMTPConfig signals that the app may continue, but without the contact form

Functions

This section is empty.

Types

type Config

type Config struct {
	// Profile: the static configuration about the profile loaded on start
	Profile *ProfileConfig `yaml:"profile"`
	// SMTP configuration used to send emails via the contact form
	SMTP *SMTPConfig `yaml:"smtp"`
	// RenderContact signals if the contact form should be rendered or not
	RenderContact bool
}

Config contains the static configuration of the portfolio, meaning the mailing config and your profile settings

func Get

func Get() *Config

Get returns the loaded config (Load must have been called at least once, else it will fail)

func Load

func Load() (*Config, error)

Load loads and returns the configuration from <config.dir>/config.yaml

type EmailAddress

type EmailAddress struct {
	*mail.Address
}

EmailAddress is a wrapper around mail.Address, which does not implement the UnmarshalYAML function

func (*EmailAddress) UnmarshalYAML

func (m *EmailAddress) UnmarshalYAML(value *yaml.Node) error

UmarshalYAML unmarshals the string address from yaml into an EmailAddress

type ProfileConfig

type ProfileConfig struct {
	// BrandName is the name displayed in the navigation bar
	BrandName string `yaml:"brandname"`
	// BrandImage is the image displayed in the navigation bar
	BrandImage *template.HTML `yaml:"brandimage"`
	// BannerImage is the image displayed on the index page
	BannerImage string `yaml:"bannerimage"`
	// Avatar displayed as profile image
	Avatar string `yaml:"avatar"`
	// FirstName displayed for the profile
	FirstName string `yaml:"firstname"`
	// LastName displayed for the profile
	LastName string `yaml:"lastname"`
	// Contact email address for the profile
	Email *EmailAddress `yaml:"email"`
	// Heading shown on the index page
	Heading *template.HTML `yaml:"heading"`
	// SubHeading shown on the index page
	SubHeading *template.HTML `yaml:"subheading"`
	// Slogan shown on the index page
	Slogan string `yaml:"slogan"`
	// Heading shown on the contact page
	ContactHeading string `yaml:"contactheading"`
	// All links to social media, displayed in the footer bar and on the index page
	SocialMedia []*SocialMedia `yaml:"social"`
	// ContentTypes enabled for the page (each element is optional)
	// - the element itself not and the list must be valid content types
	ContentTypes []string `yaml:"content"`
	// Animations defines if animations should be added to the page or not
	Animations bool `yaml:"animations"`
}

ProfileConfig contains the configurations about the profile which will be highlighted in the portfolio - (optional) means if null, no page will be rendered

func (*ProfileConfig) RenderHTML

func (p *ProfileConfig) RenderHTML() error

RenderHTML renders all HTML fields of the profile by passing them through the templates engine. This enables having e.g. the Assemble function the configs

type SMTPConfig

type SMTPConfig struct {
	// User which is used to login to the smpt service
	// Should be an email, because emails will be sent with this address used
	// as the From header (will be checked on loading)
	User EmailAddress `yaml:"user"`
	// Password which is used to login to the smpt service
	Pass string `yaml:"pass"`
	// The smtp host which will send the emails
	Host string `yaml:"host"`
	// The port on which the smtp host listens on
	Port int `yaml:"port"`
}

SMTPConfig contains the configuration of the mailing service

func (*SMTPConfig) SendMail

func (smtp *SMTPConfig) SendMail(
	receiver *mail.Address,
	replyTo *mail.Address,
	senderName string,
	message string,
) error

SendMail sends the email message to receiver via the configured smtp service

type SocialMedia

type SocialMedia struct {
	// Type of media, should be one of the 'social' type icons of https://icons.getbootstrap.com/#icons
	Type string `yaml:"type"`
	// Link to the social media profile
	Link string `yaml:"link"`
}

SocialMedia represents a generic social media type

Jump to

Keyboard shortcuts

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