add hire/resume pages, contact form, security middleware, and admin improvements
This commit is contained in:
@@ -161,6 +161,28 @@ func (s *Store) Search(query string) ([]*Post, error) {
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// Neighbors returns the posts immediately older and newer than slug in
|
||||
// date-descending order (newer = more recent = lower index).
|
||||
// Either value may be nil if slug is at the boundary.
|
||||
func (s *Store) Neighbors(slug string) (older, newer *Post, err error) {
|
||||
posts, err := s.All(false)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
for i, p := range posts {
|
||||
if p.Slug == slug {
|
||||
if i+1 < len(posts) {
|
||||
older = posts[i+1]
|
||||
}
|
||||
if i > 0 {
|
||||
newer = posts[i-1]
|
||||
}
|
||||
return older, newer, nil
|
||||
}
|
||||
}
|
||||
return nil, nil, errors.New("post not found: " + slug)
|
||||
}
|
||||
|
||||
// AllTags returns a deduplicated list of tags across all published posts.
|
||||
func (s *Store) AllTags() ([]string, error) {
|
||||
posts, err := s.All(false)
|
||||
|
||||
Reference in New Issue
Block a user