types

package
v0.0.0-...-e4b8fe1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func FullLangName

func FullLangName(lang Lang) string

func RandID

func RandID() string

Types

type Document

type Document struct {
	// Type indicates the format of the document content.
	Type DocumentType `json:"type" yaml:"type"`
	// Markdown is the raw Markdown content of the document (if applicable).
	Markdown string `json:"markdown,omitempty" yaml:"markdown,omitempty"`
	// HTML is the HTML content of the document, either directly provided or rendered from Markdown.
	HTML string `json:"html,omitempty" yaml:"html,omitempty"`
	// Metadata contains any additional metadata parsed from the Markdown document.
	Metadata Metadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
}

Document represents the content and metadata of a post in a specific language.

func (*Document) Hash

func (g *Document) Hash() string

type DocumentType

type DocumentType uint16

DocumentType represents the type of a document (e.g., Markdown, HTML).

const (
	DocumentTypeUnknown  DocumentType = iota // unknown
	DocumentTypeMarkdown                     // markdown
	DocumentTypeHTML                         // html
)

func (DocumentType) String

func (i DocumentType) String() string

type Lang

type Lang = string
const (
	LangEnglish    Lang = "en"
	LangSpanish    Lang = "es"
	LangChinese    Lang = "zh"
	LangKorean     Lang = "ko"
	LangJapanese   Lang = "ja"
	LangGerman     Lang = "de"
	LangRussian    Lang = "ru"
	LangFrench     Lang = "fr"
	LangDutch      Lang = "nl"
	LangItalian    Lang = "it"
	LangIndonesian Lang = "id"
	LangPortuguese Lang = "pt"
	LangSwedish    Lang = "sv"
	LangCzech      Lang = "cs"
	LangSlovak     Lang = "sk"
	LangPolish     Lang = "pl"
	LangRomanian   Lang = "ro"
	LangHungarian  Lang = "hu"
	LangFinnish    Lang = "fi"
	LangTurkish    Lang = "tr"
)

type Metadata

type Metadata struct {
	// ID is the unique identifier for the post. (propagated to Post.ID)
	ID string `json:"id" yaml:"id"`
	// Author is the author of the document.
	Author string `json:"author,omitempty" yaml:"author,omitempty"`
	// Title is the title of the document.
	Title string `json:"title,omitempty" yaml:"title,omitempty"`
	// Description is a brief description of the document.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Language is the language of the document.
	Language string `json:"language,omitempty" yaml:"language,omitempty"`
	// Date is the publication date of the document.
	Date time.Time `json:"date,omitempty" yaml:"date,omitempty"`
	// Path is the URL path for the post. (propagated to Post.Path)
	Path string `json:"path,omitempty" yaml:"path,omitempty"`
	// GoPackage is the Go package associated with the post (optional). Only effective if the post is Main Document.
	GoPackage string `json:"go_package,omitempty" yaml:"go_package,omitempty"`
	// GoRepoURL is the URL of the Go package repository (optional). Only effective if the post is Main Document.
	GoRepoURL string `json:"go_repourl,omitempty" yaml:"go_repourl,omitempty"`
	// Canonical is the canonical URL for the post.
	Canonical string `json:"canonical,omitempty" yaml:"canonical,omitempty"`
	// Hidden indicates whether the post should be listed on the front page.
	Hidden bool `json:"hidden,omitempty" yaml:"hidden,omitempty"`
	// NoTranslate indicates whether the post should be translated.
	NoTranslate bool `json:"no_translate,omitempty" yaml:"no_translate,omitempty"`
	// IgnoreLangs is a list of languages to ignore when translating the post.
	IgnoreLangs []string `json:"ignore_langs,omitempty" yaml:"ignore_langs,omitempty"`
	// LangCanonical is the canonical URL for the post in a specific language.
	LangCanonical map[string]string `json:"lang_canonical,omitempty" yaml:"lang_canonical,omitempty"`
}

Metadata is a struct that holds various types of meta data parsed from a Markdown document

func (*Metadata) Hash

func (g *Metadata) Hash() string

type Post

type Post struct {
	// ID is the unique identifier for the post.
	ID string `json:"id" yaml:"id"`
	// FilePath is the file path to the post file.
	FilePath string `json:"file_path" yaml:"file_path"`
	// Path is the URL path for the post.
	Path string `json:"path" yaml:"path"`
	// Hash is a hash of the raw content to detect changes.
	Hash string `json:"hash" yaml:"hash"`

	// CreatedAt is the date and time when the post was created.
	CreatedAt time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty"`
	// UpdatedAt is the date and time when the post was last updated.
	UpdatedAt time.Time `json:"updated_at,omitempty" yaml:"updated_at,omitempty"`

	// Main contains the primary language version of the post content.
	Main *Document `json:"main,omitempty" yaml:"main,omitempty"`
	// Translated contains translated versions of the post content, keyed by language code.
	Translated map[string]*Document `json:"translated,omitempty" yaml:"translated,omitempty"`
}

Post represents a blog post or similar content item.

Jump to

Keyboard shortcuts

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