Skip to content

Commit

Permalink
Review "shared" index page (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbaldry authored Feb 22, 2024
1 parent 7799ca6 commit 1611ecf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/sources/shared/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
headless: true
description: nothing
description: Only required to make the children of this page available as resources.
date: 2024-02-22
---
24 changes: 13 additions & 11 deletions tools/cmd/review/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,31 @@ const (
countSections
)

type Date time.Time
type DateArgument struct {
time time.Time
}

func (d *Date) String() string {
return time.Time(*d).Format(time.DateOnly)
func (d *DateArgument) String() string {
return d.time.Format(time.DateOnly)
}

func (d *Date) Set(str string) error {
t, err := time.Parse(time.DateOnly, str)
if err != nil {
func (d *DateArgument) Set(str string) error {
if t, err := time.Parse(time.DateOnly, str); err != nil {
return err
} else {
d.time = t
}

*d = Date(t)

return nil
}

type metadata struct {
Date time.Time `yaml:"date"`
Date time.Time `yaml:"date"`
Headless bool `yaml:"headless"`
}

func main() {
before := Date(time.Now().AddDate(0, 0, -90))
before := DateArgument{time: time.Now().AddDate(0, 0, -90)}

flag.Var(&before, "before", "YYYY-MM-DD date after which to include documents, defaults to ninety days ago.")

Expand Down Expand Up @@ -101,7 +103,7 @@ func main() {
return fmt.Errorf("unable to unmarshal front matter in %q: %w", path, err)
}

if frontMatter.Date.Before(time.Time(before)) {
if frontMatter.Date.Before(before.time) && !frontMatter.Headless {
pages = append(pages, path)
}

Expand Down

0 comments on commit 1611ecf

Please sign in to comment.