package main import ( "log" "time" ) func main() { if err := run(); err != nil { log.Fatal(err) } } func run() error { index := NewIndex() if err := index.ReadDir("src", ""); err != nil { return err } manipulator, err := NewManipulator() if err != nil { return err } if err := manipulator.Manipulate(index); err != nil { return err } if err := index.Write("dst"); err != nil { return err } return nil } // Page represents a page. type Page struct { // The path to this page. Path string // The permalink to this page. Permalink string // The title of this page, parsed from the Gemini contents. Title string // The date of the page. Dates are specified in the filename. // Ex: 2020-09-22-hello-world.gmi Date time.Time // The content of this page. Content string } func NewPage(path string, content string) *Page { // TODO: Parse date from path name permalink := "/" + path return &Page{ Path: path, Permalink: permalink, Content: content, } } // Section represents a section (i.e., a directory). type Section struct { // The path to this section. Path string // The permalink to this section. Permalink string // The pages in this section. Pages []*Page } // NewSection returns a new Section with the given path. func NewSection(path string) *Section { var permalink string if path == "" { permalink = "/" } else { permalink = "/" + path + "/" } return &Section{ Path: path, Permalink: permalink, } } // Sort sorts pages by date. func (s *Section) Sort() { // TODO: Implement this }