entity

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenFileForWriting

func OpenFileForWriting(fs afero.Fs, filename string) (afero.File, error)

OpenFileForWriting opens or creates the given file. If the target directory does not exist, it gets created.

Types

type Collator

type Collator struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Collator) CompareStrings

func (c *Collator) CompareStrings(a, b string) int

CompareStrings compares a and b. It returns -1 if a < b, 1 if a > b and 0 if a == b. Note that the Collator is not thread safe, so you may want to acquire a lock on it before calling this method.

type Data added in v0.0.14

type Data map[string]any

func (Data) Pages added in v0.0.14

func (d Data) Pages() Pages

type Language

type Language struct {
	LangSvc site.LanguageService
	// contains filtered or unexported fields
}

func (*Language) Collator

func (l *Language) Collator() *collate.Collator

func (*Language) CurrentLanguageIndex

func (l *Language) CurrentLanguageIndex() int

func (*Language) Lang

func (l *Language) Lang() string

func (*Language) LanguageCode

func (l *Language) LanguageCode() string

func (*Language) LanguageDirection

func (l *Language) LanguageDirection() string

func (*Language) LanguageName

func (l *Language) LanguageName() string

func (*Language) LanguagePrefix

func (l *Language) LanguagePrefix() string

func (*Language) Languages

func (l *Language) Languages() []Language

func (*Language) Location

func (l *Language) Location() *time.Location
type Navigation struct {
	// contains filtered or unexported fields
}

type OrderedTaxonomy added in v0.0.13

type OrderedTaxonomy []OrderedTaxonomyEntry

OrderedTaxonomy is another representation of an Taxonomy using an array rather than a map. Important because you can't order a map.

type OrderedTaxonomyEntry added in v0.0.13

type OrderedTaxonomyEntry struct {
	Name string
	WeightedPages
}

OrderedTaxonomyEntry is similar to an element of a Taxonomy, but with the key embedded (as name) e.g: {Name: Technology, WeightedPages: TaxonomyPages}

func (OrderedTaxonomyEntry) Count added in v0.0.14

func (ie OrderedTaxonomyEntry) Count() int

Count returns the count the pages in this taxonomy.

func (OrderedTaxonomyEntry) Term added in v0.0.14

func (ie OrderedTaxonomyEntry) Term() string

Term returns the name given to this taxonomy.

type Page

type Page struct {
	contenthub.Page
	contenthub.PageOutput

	*Site
	// contains filtered or unexported fields
}

func (*Page) Content

func (p *Page) Content() (any, error)

func (*Page) Data

func (p *Page) Data() any

func (*Page) Date

func (p *Page) Date() time.Time

func (*Page) ExpiryDate

func (p *Page) ExpiryDate() time.Time

func (*Page) File

func (p *Page) File() contenthub.File

func (*Page) GetTerms added in v0.0.13

func (p *Page) GetTerms(taxonomy string) []*Page

func (*Page) GitInfo

func (p *Page) GitInfo() valueobject.GitInfo

func (*Page) IsAncestor

func (p *Page) IsAncestor(other any) bool

func (*Page) Language

func (p *Page) Language() struct {
	Lang         string
	LanguageName string
}

func (*Page) Lastmod

func (p *Page) Lastmod() time.Time

func (*Page) LinkTitle added in v0.1.1

func (p *Page) LinkTitle() string

func (*Page) OutputFormats

func (p *Page) OutputFormats() valueobject.OutputFormats

func (*Page) Pages

func (p *Page) Pages() []*Page

func (*Page) Paginate added in v0.1.1

func (p *Page) Paginate(groups contenthub.PageGroups) (*SitePager, error)

func (*Page) Paginator added in v0.1.1

func (p *Page) Paginator() (*SitePager, error)

func (*Page) Params

func (p *Page) Params() maps.Params

func (*Page) Parent added in v0.1.1

func (p *Page) Parent() *Page
func (p *Page) Permalink() string

func (*Page) Plain added in v0.1.1

func (p *Page) Plain() string

func (*Page) PublishDate

func (p *Page) PublishDate() time.Time
func (p *Page) RelPermalink() string

func (*Page) Resources

func (p *Page) Resources() PageResources

func (*Page) Section

func (p *Page) Section() string

func (*Page) Sites

func (p *Page) Sites() *Sites

func (*Page) Title

func (p *Page) Title() string

func (*Page) Translations

func (p *Page) Translations() []*Page

type PageResources

type PageResources []resources.Resource

func (PageResources) ByType

func (r PageResources) ByType(typ any) PageResources

ByType returns resources of a given resource type (e.g. "image").

func (PageResources) Get

func (r PageResources) Get(name any) resources.Resource

Get locates the name given in Resources. The search is case insensitive.

func (PageResources) GetMatch

func (r PageResources) GetMatch(pattern any) resources.Resource

GetMatch finds the first Resource matching the given pattern, or nil if none found. See Match for a more complete explanation about the rules used.

type Pages

type Pages []*Page

func (Pages) ByLastmod added in v0.0.14

func (p Pages) ByLastmod() Pages

func (Pages) Len

func (p Pages) Len() int

Len returns the number of pages in the list.

func (Pages) Reverse added in v0.0.14

func (p Pages) Reverse() Pages

func (Pages) String

func (p Pages) String() string

type Publisher

type Publisher struct {
	Fs afero.Fs
}

func (*Publisher) Publish

func (p *Publisher) Publish(d site.Descriptor) error

Publish applies any relevant transformations and writes the file to its destination, e.g. /public.

func (*Publisher) PublishFiles

func (p *Publisher) PublishFiles(fr io.ReadSeekCloser, filenames ...string) error

func (*Publisher) PublishSource

func (p *Publisher) PublishSource(src *bytes.Buffer, filename ...string) error

type Ref added in v0.1.1

type Ref struct {
	Site       *Site
	ContentSvc site.ContentService

	NotFoundURL string
	ErrorLogger logg.LevelLogger
}

func (*Ref) RelRefFrom added in v0.1.1

func (r *Ref) RelRefFrom(argsm map[string]any, source any) (string, error)

type Render

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

type Site

type Site struct {
	ConfigSvc      site.ConfigService
	ContentSvc     site.ContentService
	TranslationSvc site.TranslationService
	ResourcesSvc   site.ResourceService
	LanguageSvc    site.LanguageService

	GitSvc *valueobject.GitMap

	Publisher *Publisher

	Template site.Template

	*valueobject.Author
	*valueobject.Compiler

	Title string

	*URL
	*Ref
	*Language
	*Navigation

	Log loggers.Logger `json:"-"`
	// contains filtered or unexported fields
}

func (*Site) AbsURL

func (s *Site) AbsURL(in string) string

func (*Site) Build

func (s *Site) Build(t site.Template) error

func (*Site) GetPage

func (s *Site) GetPage(ref ...string) (*Page, error)

func (*Site) Home

func (s *Site) Home() *Page

func (*Site) IsMultiLingual

func (s *Site) IsMultiLingual() bool

func (*Site) IsMultihost added in v0.1.1

func (s *Site) IsMultihost() bool

func (*Site) IsMultilingual added in v0.1.1

func (s *Site) IsMultilingual() bool

func (*Site) Menus

func (s *Site) Menus() valueobject.Menus

func (*Site) Pages

func (s *Site) Pages() []*Page

func (*Site) Params

func (s *Site) Params() maps.Params

func (*Site) PrepareLazyLoads

func (s *Site) PrepareLazyLoads()

func (*Site) RegularPages added in v0.0.5

func (s *Site) RegularPages() []*Page

func (*Site) RelURL

func (s *Site) RelURL(in string) string

func (*Site) Taxonomies

func (s *Site) Taxonomies() TaxonomyList

func (*Site) Translate added in v0.1.1

func (s *Site) Translate(ctx context.Context, translationID string, templateData any) string

type SitePager added in v0.1.1

type SitePager struct {
	contenthub.Pager
	// contains filtered or unexported fields
}

func (*SitePager) Next added in v0.1.1

func (p *SitePager) Next() *SitePager

func (*SitePager) Pages added in v0.1.1

func (p *SitePager) Pages() Pages

func (*SitePager) Prev added in v0.1.1

func (p *SitePager) Prev() *SitePager

type Sites added in v0.1.1

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

func (*Sites) Default added in v0.1.1

func (s *Sites) Default() *Site

func (*Sites) First added in v0.1.1

func (s *Sites) First() *Site

type Taxonomy

type Taxonomy map[string]WeightedPages

A Taxonomy is a map of keywords to a list of pages. For example

TagTaxonomy['technology'] = WeightedPages
TagTaxonomy['go']  =  WeightedPages

func (Taxonomy) ByCount added in v0.0.13

func (i Taxonomy) ByCount() OrderedTaxonomy

ByCount returns an ordered taxonomy sorted by # of pages per key. If taxonomies have the same # of pages, sort them alphabetical

func (Taxonomy) TaxonomyArray added in v0.0.13

func (i Taxonomy) TaxonomyArray() OrderedTaxonomy

TaxonomyArray returns an ordered taxonomy with a non defined order.

type TaxonomyList

type TaxonomyList map[string]Taxonomy

The TaxonomyList is a list of all taxonomies and their values e.g. List['tags'] => TagTaxonomy (from above)

type URL

type URL struct {
	Base      string
	Canonical bool

	*valueobject.BaseURL
}

func (*URL) BasePathNoSlash

func (u *URL) BasePathNoSlash() string

func (*URL) IsAbsURL

func (u *URL) IsAbsURL(in string) (bool, error)

func (*URL) MakePath

func (u *URL) MakePath(s string) string

MakePath takes a string with any characters and replace it so the string could be used in a path. It does so by creating a Unicode-sanitized string, with the spaces replaced, whilst preserving the original casing of the string. E.g. Social Media -> Social-Media

func (*URL) MakePathSanitized

func (u *URL) MakePathSanitized(s string) string

MakePathSanitized creates a Unicode-sanitized string, with the spaces replaced

func (*URL) URLEscape

func (u *URL) URLEscape(uri string) string

URLEscape escapes unicode letters.

func (*URL) URLize

func (u *URL) URLize(uri string) string

URLize is similar to MakePath, but with Unicode handling Example:

uri: Vim (text editor)
urlize: vim-text-editor

type WeightedPage added in v0.0.14

type WeightedPage struct {
	*Page
	contenthub.OrdinalWeightPage
}

type WeightedPages added in v0.0.13

type WeightedPages []*WeightedPage

WeightedPages is a list of Pages with their corresponding (and relative) weight [{Weight: 30, Page: *1}, {Weight: 40, Page: *2}]

func (WeightedPages) Count added in v0.0.14

func (p WeightedPages) Count() int

func (WeightedPages) Len added in v0.0.14

func (p WeightedPages) Len() int

func (WeightedPages) Less added in v0.0.14

func (p WeightedPages) Less(i, j int) bool

func (WeightedPages) Page added in v0.0.13

func (p WeightedPages) Page() *WeightedPage

Page will return the Page (of Kind taxonomyList) that represents this set of pages. This method will panic if p is empty, as that should never happen.

func (WeightedPages) Pages added in v0.0.14

func (p WeightedPages) Pages() []*WeightedPage

func (WeightedPages) Sort added in v0.0.14

func (p WeightedPages) Sort()

func (WeightedPages) Swap added in v0.0.14

func (p WeightedPages) Swap(i, j int)

Jump to

Keyboard shortcuts

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