translate

package
v0.0.0-...-c6c09a8 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(baseDir string, contentType string) string

func EstablishDirLevelConf

func EstablishDirLevelConf(t mapper.Type, tc TransConfig) (string, string)

EstablishDirLevelConf provides the ability to augment content directories with with LeafBundle (index.md) or Section level (_index.md) frontmatter during the export process.

func Filename

func Filename(item mapper.Item) string

func FromToml

func FromToml(s string) (c map[string]interface{}, err error)

FromToml reads in a *.toml file and returns all mappings.

func FromYaml

func FromYaml(s string) (c map[string]interface{}, err error)

FromYaml reads in a *.yaml file and returns all mappings.

func GetArchetypeFilename

func GetArchetypeFilename(contentTypeName string) string

ArcheTypeFilename takes a content-type's name and returns the file path to the corresponding archetype file.

func LeafBundleFilename

func LeafBundleFilename(t mapper.Type) string

func SectionFilename

func SectionFilename(t mapper.Type) string

func WriteTomlFrontmatter

func WriteTomlFrontmatter(fm interface{}) string

WriteTomlFrontmatter (fm Map[]) -> string Converts a Map[] into a TOML string, pre and postfixing it with `+++` to designate frontmatter.

func WriteYamlFrontmatter

func WriteYamlFrontmatter(fm interface{}) string

WriteYamlFrontmatter (fm Map[]) -> string Converts a Map[] into a YAML string, pre and postfixing it with `---` to designate frontmatter.

Types

type Content

type Content struct {
	Params      map[string]interface{}
	MainContent string
	Slug        string
}

func (Content) ToToml

func (s Content) ToToml() string

ToToml .() -> string Takes a Content struct and outputs it as TOML frontmatter followed by main-content.

func (Content) ToYaml

func (s Content) ToYaml() string

ToYaml .() -> string Takes a Content struct and outputs it as YAML frontmatter followed by main-content.

type TransConfig

type TransConfig struct {
	Encoding   string
	Section    map[string]interface{}
	LeafBundle map[string]interface{}
}

func LoadConfig

func LoadConfig(config string) TransConfig

type TranslationContext

type TranslationContext struct {
	Result      mapper.ItemResult
	TransConfig TransConfig
}

func (*TranslationContext) ConvertToContent

func (tc *TranslationContext) ConvertToContent(fieldMap map[string]interface{}) Content

ConvertToContent takes a map of values and converts it to a Content struct

func (*TranslationContext) MapContentValuesToTypeNames

func (tc *TranslationContext) MapContentValuesToTypeNames(Map map[string]interface{}, fields []mapper.TypeField, ids map[string]string) map[string]interface{}

MapContentValuesToTypeNames takes the values map and the typefield map from contentful and merges the two.

func (*TranslationContext) MergeMaps

func (tc *TranslationContext) MergeMaps(itemDefault map[string]interface{}, itemOverride map[string]interface{}) (combinedItem map[string]interface{})

MergeMaps takes a defaults and an overrides map and assigns any missing values from the defaults to the overrides map.

func (*TranslationContext) TranslateFromMarkdown

func (tc *TranslationContext) TranslateFromMarkdown(content string) (rawContent map[string]interface{}, err error)

TranslateFromMarkdown takes a markdown file's contents and converts it to a map.

func (*TranslationContext) TranslateToMarkdown

func (tc *TranslationContext) TranslateToMarkdown(rawContent Content) (content string)

TranslateToMarkdown accepts a Content struct and converts it to markdown file contents.

Jump to

Keyboard shortcuts

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