From d83f4bca3f7026696a41225caac11807ed06fc2f Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Tue, 24 Nov 2020 23:20:54 -0500 Subject: Add more comments. Expand the interface. Allow templates to more easily be rendered with external variables. --- local/index.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'local/index.go') diff --git a/local/index.go b/local/index.go index a90276e..7b821f6 100644 --- a/local/index.go +++ b/local/index.go @@ -10,6 +10,8 @@ import ( var pageIndex map[string]PageList +// RebuildIndex can be called in order to rebuild the entire website +// index func (p *Page) RebuildIndex() error { pageIndex = nil _, err := p.Index() @@ -18,7 +20,7 @@ func (p *Page) RebuildIndex() error { // Index returns a map of all pages below the current Page's Path seperated // into their respective tags If a Page has multiple tags it will be listed -// under each +// under each. func (p *Page) Index() (map[string]PageList, error) { if pageIndex != nil { return pageIndex, nil @@ -29,15 +31,15 @@ func (p *Page) Index() (map[string]PageList, error) { var pageErr error - filepath.Walk(filepath.Dir(p.Path), + filepath.Walk(filepath.Dir(p.path), func(path string, info os.FileInfo, err error) error { if err != nil { return err } - if !info.IsDir() && strings.HasSuffix(info.Name(), ".md") { + if !info.IsDir() && strings.HasSuffix(info.Name(), Suffix) { - p2 := &Page{Path: strings.ReplaceAll(path, ".md", "")} + p2 := NewPage(strings.ReplaceAll(path, Suffix, "")) err = p2.Read() if err != nil { -- cgit v1.2.3