Skip to content

Commit

Permalink
Merge pull request #15 from fogo-sh/special-pages-index
Browse files Browse the repository at this point in the history
$SpecialPages, index of all special pages
  • Loading branch information
jackharrhy authored Aug 30, 2023
2 parents b5d3b09 + 19999d4 commit c5364ad
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pkg/content/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func CreateSpecialPages(pages map[string]*Page) error {
specialPages := make([]string, 0)

pagesByCategory := PagesByCategory(pages)
allCategories := AllCategories(pages)

Expand All @@ -26,13 +28,33 @@ func CreateSpecialPages(pages map[string]*Page) error {
return fmt.Errorf("failed to execute template: %w", err)
}

pages[fmt.Sprintf("$Category:%s", category)] = &Page{
Title: fmt.Sprintf("$Category:%s", category),
pageTitle := fmt.Sprintf("$Category:%s", category)
page := &Page{
Title: pageTitle,
LinksTo: keysOfPagesInCategory,
ParsedContent: buf.Bytes(),
}

pages[pageTitle] = page
specialPages = append(specialPages, pageTitle)
}

var buf bytes.Buffer
err := LinkListingTemplate.Execute(&buf, LinkListingData{
LinkList: specialPages,
})
if err != nil {
return fmt.Errorf("failed to execute template: %w", err)
}

page := &Page{
Title: "$SpecialPages",
LinksTo: specialPages,
ParsedContent: buf.Bytes(),
}

pages["$SpecialPages"] = page

return nil
}

Expand Down

0 comments on commit c5364ad

Please sign in to comment.