model

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDateFormat = errors.New("invalid date format: expected RFC 3339")
	ErrMalformedYAML     = errors.New("malformed YAML in front-matter")
)

Functions

func GenerateFrontMatter added in v0.16.0

func GenerateFrontMatter(created time.Time) string

GenerateFrontMatter creates a YAML front-matter string with the given created time. The updated field is omitted by default. A blank line is added after the closing delimiter for readability.

func HasFrontMatter added in v0.16.0

func HasFrontMatter(content []byte) bool

HasFrontMatter checks if content starts with front-matter delimiters

func HasNowPlaceholder added in v0.16.0

func HasNowPlaceholder(content []byte) bool

HasNowPlaceholder checks if content contains "updated: now" in front-matter

func UpdateFrontMatter added in v0.16.0

func UpdateFrontMatter(content []byte, created, updated time.Time, replaceNow bool) ([]byte, error)

UpdateFrontMatter updates the front-matter in content while preserving unknown fields. If created is non-zero, it sets/updates the created field. If updated is non-zero, it sets/updates the updated field. If replaceNow is true and updated is non-zero, it replaces "now" placeholder.

Types

type Calender

type Calender struct {
	YearMonth CalenderYearMonth
	Weeks     [][7]CalenderDay
}

func NewCalender added in v0.6.0

func NewCalender(ym CalenderYearMonth, nippoList []Nippo) (*Calender, error)

type CalenderDay

type CalenderDay struct {
	HasContent bool
	Date       NippoDate
}

func (CalenderDay) String added in v0.6.0

func (cday CalenderDay) String() string

type CalenderYearMonth

type CalenderYearMonth struct {
	Year  int
	Month time.Month
	// contains filtered or unexported fields
}

func NewCalenderYearMonth added in v0.10.1

func NewCalenderYearMonth(fileName string) (CalenderYearMonth, error)

func (CalenderYearMonth) FileString added in v0.10.1

func (ym CalenderYearMonth) FileString() string

func (CalenderYearMonth) PathString added in v0.6.0

func (ym CalenderYearMonth) PathString() string

func (CalenderYearMonth) String added in v0.6.0

func (ym CalenderYearMonth) String() string

func (CalenderYearMonth) Time added in v0.10.1

func (ym CalenderYearMonth) Time() time.Time

func (CalenderYearMonth) TitleString added in v0.6.0

func (ym CalenderYearMonth) TitleString() string

type FrontMatter added in v0.16.0

type FrontMatter struct {
	Created time.Time `yaml:"created,omitempty"`
	Updated time.Time `yaml:"updated,omitempty"`
	Raw     map[string]interface{}
}

FrontMatter represents the YAML front-matter metadata in a nippo file

func ParseFrontMatter added in v0.16.0

func ParseFrontMatter(content []byte) (*FrontMatter, []byte, error)

ParseFrontMatter extracts YAML front-matter from content and returns the parsed FrontMatter and the remaining body content. Returns nil FrontMatter if no front-matter is present.

type Index

type Index struct {
	Nippo
}

type Nippo

type Nippo struct {
	Date        NippoDate
	FilePath    string
	Content     []byte
	FrontMatter *FrontMatter
	RemoteFile  *drive.File
}

func NewNippo

func NewNippo(filePath string) (*Nippo, error)

func (*Nippo) GetCreatedTime added in v0.16.0

func (n *Nippo) GetCreatedTime() time.Time

GetCreatedTime returns the created time from front-matter if available, otherwise returns the time derived from the nippo date (filename).

func (*Nippo) GetHtml

func (n *Nippo) GetHtml() ([]byte, error)

func (*Nippo) GetMarkdown

func (n *Nippo) GetMarkdown() ([]byte, error)

func (*Nippo) GetUpdatedTime added in v0.16.0

func (n *Nippo) GetUpdatedTime() time.Time

GetUpdatedTime returns the updated time from front-matter if available, otherwise returns zero time.

type NippoDate

type NippoDate interface {
	PathString() string
	FileString() string
	TitleString() string

	Year() int
	Month() time.Month
	Day() int
	Weekday() time.Weekday
}

func NewNippoDate

func NewNippoDate(filePath string) NippoDate

Jump to

Keyboard shortcuts

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