Documentation
¶
Index ¶
- Variables
- func GenerateFrontMatter(created time.Time) string
- func HasFrontMatter(content []byte) bool
- func HasNowPlaceholder(content []byte) bool
- func UpdateFrontMatter(content []byte, created, updated time.Time, replaceNow bool) ([]byte, error)
- type Calender
- type CalenderDay
- type CalenderYearMonth
- type FrontMatter
- type Index
- type Nippo
- type NippoDate
Constants ¶
This section is empty.
Variables ¶
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
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
HasFrontMatter checks if content starts with front-matter delimiters
func HasNowPlaceholder ¶ added in v0.16.0
HasNowPlaceholder checks if content contains "updated: now" in front-matter
func UpdateFrontMatter ¶ added in v0.16.0
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 ¶
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 Nippo ¶
type Nippo struct {
Date NippoDate
FilePath string
Content []byte
FrontMatter *FrontMatter
RemoteFile *drive.File
}
func (*Nippo) GetCreatedTime ¶ added in v0.16.0
GetCreatedTime returns the created time from front-matter if available, otherwise returns the time derived from the nippo date (filename).
func (*Nippo) GetMarkdown ¶
func (*Nippo) GetUpdatedTime ¶ added in v0.16.0
GetUpdatedTime returns the updated time from front-matter if available, otherwise returns zero time.