Skip to content

Commit

Permalink
wip: add specer and footer
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Jan 12, 2025
1 parent 50b0c23 commit 3ee1e7a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
28 changes: 23 additions & 5 deletions pkg/renderer/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ type renderer struct {
}

func (r *renderer) Render(w io.Writer) error {
if err := Header(r.s.Header).Render(w); err != nil {
return err
}

return nil
return Write(w,
Header(r.s.Header),
Spacer(),
Footer(r.s.Footer))
}

func New(s *spec.Spec) Renderer {
Expand Down Expand Up @@ -59,3 +58,22 @@ func (s *stringer) Render(w io.Writer) error {
func Header(header string) Node {
return &stringer{text: header}
}

func Footer(footer string) Node {
return &stringer{text: footer}
}

func Spacer() Node {
return &stringer{text: "\n"}
}

func Write(out io.Writer, fn ...Renderer) error {
for _, f := range fn {
err := f.Render(out)
if err != nil {
return err
}
}

return nil
}
4 changes: 3 additions & 1 deletion pkg/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ type Spec struct {
// Description is a short description of the project or repository (optional)
Description string `yaml:"description,omitempty"`
// Header is the header of the markdown file
Header string `yaml:"header"`
Header string `yaml:"header"`
// Footer is the footer of the markdown file
Footer string `yaml:"footer"`
Groups []Group `yaml:"groups"`
Contents ContentsConfig `yaml:"contents"`
EntryConfig EntryConfig `yaml:"entry"`
Expand Down

0 comments on commit 3ee1e7a

Please sign in to comment.