builder

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package builder implements the Builder design pattern used to generate all sveltin's artifacts (project, page, metadata, etc.)

Index

Constants

View Source
const (
	Defaults         string = "defaults"
	Externals        string = "externals"
	Website          string = "website"
	Menu             string = "menu"
	InitMenu         string = "init_menu"
	DotEnv           string = "dotenv"
	ProjectSettings  string = "project_settings"
	Readme           string = "readme"
	License          string = "license"
	ThemeConfig      string = "theme_config"
	IndexPage        string = "index"
	IndexNoThemePage string = "index_notheme"
)

constants representing different file names.

View Source
const (
	// Blank represents the fontmatter-only template id used when generating the content file.
	Blank string = "blank"
	// Sample represents the sample-content template id used when generating the content file.
	Sample string = "sample"

	// Svelte set svelte as the language used to scaffold a new page.
	Svelte string = "svelte"
	// SvelteThemeBlank set svelte as the language used to scaffold a new page when new theme.
	SvelteThemeBlank = "svelte_blank"
	// SvelteThemeSveltin set svelte as the language used to scaffold a new page when sveltin theme.
	SvelteThemeSveltin = "svelte_sveltin"
	// Markdown set markdown as the language used to scaffold a new page.
	Markdown string = "markdown"
	// MarkdownThemeBlank set markdown as the language used to scaffold a new page when new theme.
	MarkdownThemeBlank string = "markdown_blank"
	// MarkdownThemeSveltin set markdown as the language used to scaffold a new page when sveltin theme.
	MarkdownThemeSveltin string = "markdown_sveltin"

	// StringMatcher is the string for the string parameters matcher
	StringMatcher string = "string_matcher"
	// GenericMatcher is the string for the generic parameters matcher
	GenericMatcher string = "generic_matcher"

	// ApiFolder is the string for the 'api' folder.
	ApiFolder string = "api"
	// ApiIndexFile is the string for the index api file.
	ApiIndexFile string = "api_index"
	// ApiSlugFile is the string for the slug api file.
	ApiSlugFile string = "api_slug"
	// ApiMetadataIndex is the string for the api template file
	// to get all resources grouped by metadata.
	ApiMetadataIndex string = "api_metadata_index"
	// ApiMetadataSingle is the string for the api template file
	// to be used when creating a metadata of type 'single' and
	// to get all resources filtered by metadata name.
	ApiMetadataSingle string = "api_metadata_single"
	// ApiMetadataList is the string for the api template file
	// to be used when creating a metadata of type 'list' and
	// to get all resources filtered by metadata name.
	ApiMetadataList string = "api_metadata_list"

	// Index is the string for the 'index' file.
	Index string = "index"
	// IndexThemeBlank is the string for the 'index' file when new theme.
	IndexThemeBlank string = "index_blank"
	// IndexThemeSveltin is the string for the 'index' file when sveltin theme.
	IndexThemeSveltin string = "index_sveltin"
	// IndexEndpoint is the string for the 'index.ts' file.
	IndexEndpoint string = "indexendpoint"
	// Slug is the string for the 'slug' file.
	Slug string = "slug"
	// SlugThemeBlank is the string for the 'slug' file when new theme.
	SlugThemeBlank string = "slug_blank"
	// SlugThemeSveltin is the string for the 'slug' file when sveltin theme.
	SlugThemeSveltin string = "slug_sveltin"
	// SlugEndpoint is the string for the 'slug' file.
	SlugEndpoint string = "slugendpoint"
	// SlugLayout is the string from the 'layout' file
	SlugLayout string = "sluglayout"

	// Lib is the string for the 'lib' folder.
	Lib string = "lib"
	// LibSingle is the string representing the template id used
	// for the lib file when metadata's type is single.
	LibSingle string = "lib_single"
	// LibList is the string representing the template id used
	// for the lib file when metadata's type is list.
	LibList string = "lib_list"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

Content define the needed configs to run a Builder.

type Director

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

Director defines the order in which to execute the building steps.

func NewDirector

func NewDirector(b IFileContentBuilder) *Director

NewDirector create a director.

func (*Director) GetContent

func (d *Director) GetContent() Content

GetContent returns the Content struct used by the Builder.

func (*Director) SetBuilder

func (d *Director) SetBuilder(b IFileContentBuilder)

SetBuilder set the Builder to be used.

type IFileContentBuilder

type IFileContentBuilder interface {
	SetEmbeddedResources(res map[string]string)
	SetTemplateID(string)
	SetTemplateData(artifact *config.TemplateData)

	GetContent() Content
	// contains filtered or unexported methods
}

IFileContentBuilder declares building steps that are common to all types of builders.

func GetContentBuilder

func GetContentBuilder(contentType string) IFileContentBuilder

GetContentBuilder returns an concrete implementation for iFileContentBuilder.

type MenuContentBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

MenuContentBuilder represents the builder for the menu.

func NewMenuContentBuilder

func NewMenuContentBuilder() *MenuContentBuilder

NewMenuContentBuilder create a menuContentBuilder struct.

func (b *MenuContentBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (b *MenuContentBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (b *MenuContentBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template.

func (b *MenuContentBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

type MetadataContentBuilder

type MetadataContentBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

MetadataContentBuilder represents the builder for the metadata artefact.

func NewMetadataContentBuilder

func NewMetadataContentBuilder() *MetadataContentBuilder

NewMetadataContentBuilder create a metadataContentBuilder struct.

func (*MetadataContentBuilder) GetContent

func (b *MetadataContentBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (*MetadataContentBuilder) SetEmbeddedResources

func (b *MetadataContentBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (*MetadataContentBuilder) SetTemplateData

func (b *MetadataContentBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template

func (*MetadataContentBuilder) SetTemplateID

func (b *MetadataContentBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

type NoPContentBuilder

type NoPContentBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

NoPContentBuilder represents the builder for the no-page artefacts (sitemap and rss).

func NewNoPageContentBuilder

func NewNoPageContentBuilder() *NoPContentBuilder

NewNoPageContentBuilder create a NoPContentBuilder struct.

func (*NoPContentBuilder) GetContent

func (b *NoPContentBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (*NoPContentBuilder) SetEmbeddedResources

func (b *NoPContentBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (*NoPContentBuilder) SetTemplateData

func (b *NoPContentBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template.

func (*NoPContentBuilder) SetTemplateID

func (b *NoPContentBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

type ProjectBuilder

type ProjectBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

ProjectBuilder represents the builder for the project.

func NewProjectBuilder

func NewProjectBuilder() *ProjectBuilder

NewProjectBuilder create a ProjectBuilder struct.

func (*ProjectBuilder) GetContent

func (b *ProjectBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (*ProjectBuilder) SetEmbeddedResources

func (b *ProjectBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (*ProjectBuilder) SetTemplateData

func (b *ProjectBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template.

func (*ProjectBuilder) SetTemplateID

func (b *ProjectBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

type PublicPageContentBuilder

type PublicPageContentBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

PublicPageContentBuilder represents the builder for the public page artefact.

func NewPageContentBuilder

func NewPageContentBuilder() *PublicPageContentBuilder

NewPageContentBuilder create a PublicPageContentBuilder struct.

func (*PublicPageContentBuilder) GetContent

func (b *PublicPageContentBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (*PublicPageContentBuilder) SetEmbeddedResources

func (b *PublicPageContentBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (*PublicPageContentBuilder) SetTemplateData

func (b *PublicPageContentBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template.

func (*PublicPageContentBuilder) SetTemplateID

func (b *PublicPageContentBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

type ResContentBuilder

type ResContentBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

ResContentBuilder represents the builder for the content artefact.

func NewResContentBuilder

func NewResContentBuilder() *ResContentBuilder

NewResContentBuilder create a ResContentBuilder struct.

func (*ResContentBuilder) GetContent

func (b *ResContentBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (*ResContentBuilder) SetEmbeddedResources

func (b *ResContentBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (*ResContentBuilder) SetTemplateData

func (b *ResContentBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template.

func (*ResContentBuilder) SetTemplateID

func (b *ResContentBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

type ResourceContentBuilder

type ResourceContentBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

ResourceContentBuilder represents the builder for the resource artefact.

func NewResourceContentBuilder

func NewResourceContentBuilder() *ResourceContentBuilder

NewResourceContentBuilder create a ResourceContentBuilder struct.

func (*ResourceContentBuilder) GetContent

func (b *ResourceContentBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (*ResourceContentBuilder) SetEmbeddedResources

func (b *ResourceContentBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (*ResourceContentBuilder) SetTemplateData

func (b *ResourceContentBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template.

func (*ResourceContentBuilder) SetTemplateID

func (b *ResourceContentBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

type ThemeBuilder

type ThemeBuilder struct {
	ContentType       string
	EmbeddedResources map[string]string
	PathToTplFile     string
	TemplateID        string
	TemplateData      *config.TemplateData
	Funcs             template.FuncMap
}

ThemeBuilder represents the builder for the project.

func NewThemeBuilder

func NewThemeBuilder() *ThemeBuilder

NewThemeBuilder create a ThemeBuilder struct.

func (*ThemeBuilder) GetContent

func (b *ThemeBuilder) GetContent() Content

GetContent returns the full Content config needed by the Builder.

func (*ThemeBuilder) SetEmbeddedResources

func (b *ThemeBuilder) SetEmbeddedResources(res map[string]string)

SetEmbeddedResources set the map to relative embed FS.

func (*ThemeBuilder) SetTemplateData

func (b *ThemeBuilder) SetTemplateData(artifactData *config.TemplateData)

SetTemplateData set the data used by the template.

func (*ThemeBuilder) SetTemplateID

func (b *ThemeBuilder) SetTemplateID(id string)

SetTemplateID set the id for the template to be used.

Jump to

Keyboard shortcuts

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