utils

package
v0.0.0-...-a68df52 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSitemapEntry

func AddSitemapEntry(entries []string, slug string) []string

func ApproxDirection

func ApproxDirection(deg float64) string

func Check

func Check(err error)

func Copy

func Copy(sourceFileName, targetFileName string) error

func CopyHash

func CopyHash(src, dst string) (string, error)

func DateYMS

func DateYMS(s string) string

func DistanceBearing

func DistanceBearing(lat1deg, lon1deg, lat2deg, lon2deg float64) (float64, float64)

func Download

func Download(url string, dst string) error

func DownloadHash

func DownloadHash(url string, dst string) (string, error)

func ExecuteTemplate

func ExecuteTemplate(templateName string, fileName string, data any)

func ExecuteTemplateNoMinify

func ExecuteTemplateNoMinify(templateName string, fileName string, data any)

func GenImage

func GenImage(fileName string, title string, sub1 string, sub2 string, backgroundPNG string) error

func MakeDir

func MakeDir(dir string) error

func MonthStr

func MonthStr(m time.Month) string

func MustCopy

func MustCopy(sourceFileName, targetFileName string)

func MustCopyHash

func MustCopyHash(src, dst string) string

func MustDownload

func MustDownload(url string, dst string)

func MustDownloadHash

func MustDownloadHash(url string, dst string) string

func MustMakeDir

func MustMakeDir(dir string)

func ParseDate

func ParseDate(s string) (time.Time, error)

func SanitizeName

func SanitizeName(s string) string

func SortAndUniquify

func SortAndUniquify(a []string) []string

func Split

func Split(s string) []string

func WeekdayStr

func WeekdayStr(d time.Weekday) string

Types

type Added

type Added struct {
	// contains filtered or unexported fields
}

func ReadAdded

func ReadAdded(fileName string) (*Added, error)

func (Added) GetAdded

func (added Added) GetAdded(t string, name string) (string, error)

func (*Added) SetAdded

func (added *Added) SetAdded(t string, name string, date string) error

func (Added) Write

func (added Added) Write(fileName string) error
type Breadcrumb struct {
	Link     Link
	IsLast   bool
	Position int
}

func InitBreadcrumbs

func InitBreadcrumbs(link Link) []Breadcrumb

func PushBreadcrumb

func PushBreadcrumb(breadcrumbs []Breadcrumb, link Link) []Breadcrumb

type FileHashDate

type FileHashDate struct {
	// contains filtered or unexported fields
}
type Link struct {
	Name string
	Url  string
}

func (Link) IsEmail

func (link Link) IsEmail() bool

func (Link) IsExternal

func (link Link) IsExternal() bool

type Sitemap

type Sitemap struct {
	BaseUrl    string
	Categories []string
	Entries    []*SitemapEntry
}

func CreateSitemap

func CreateSitemap(baseUrl string) *Sitemap

func (*Sitemap) Add

func (sitemap *Sitemap) Add(slug string, name string, category string)

func (*Sitemap) AddCategory

func (sitemap *Sitemap) AddCategory(name string)

func (Sitemap) Gen

func (sitemap Sitemap) Gen(fileName string, hashFileName string, outDir string) error

func (Sitemap) GenHTML

func (sitemap Sitemap) GenHTML() []SitemapCategory

type SitemapCategory

type SitemapCategory struct {
	Name  string
	Links []Link
}

type SitemapEntry

type SitemapEntry struct {
	Slug     string
	Name     string
	Category string
}

type TimeRange

type TimeRange struct {
	Original  string
	Formatted string
	From      time.Time
	To        time.Time
}

func CreateTimeRange

func CreateTimeRange(original string) (TimeRange, error)

func (TimeRange) Before

func (tr TimeRange) Before(t time.Time) bool

func (TimeRange) IsZero

func (tr TimeRange) IsZero() bool

func (TimeRange) Year

func (tr TimeRange) Year() int

Jump to

Keyboard shortcuts

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