diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2020-11-24 23:20:54 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2020-11-24 23:20:54 -0500 |
| commit | d83f4bca3f7026696a41225caac11807ed06fc2f (patch) | |
| tree | 634552e0253407785f81cb28cf136fadec4d65e4 /local/index.go | |
| parent | 2203a437cc7ba0ca087a47d6e99476ba5e09ae71 (diff) | |
| download | go-website-0.0.11.tar.gz go-website-0.0.11.tar.xz | |
Add more comments. Expand the interface. Allow templates to more easily be rendered with external variables.v0.0.11
Diffstat (limited to 'local/index.go')
| -rw-r--r-- | local/index.go | 10 |
1 files changed, 6 insertions, 4 deletions
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 { |
