feat: Add Next and Previous in Tag

This commit is contained in:
tsuyoshiwada 2018-02-16 15:50:05 +09:00
parent cd9684604b
commit d4d2a7ed80
3 changed files with 109 additions and 16 deletions

View file

@ -61,5 +61,31 @@ func (r *tagReader) ReadAll() ([]*Tag, error) {
})
}
total := len(tags)
for i, tag := range tags {
var (
next *RelateTag
prev *RelateTag
)
if i > 0 {
next = &RelateTag{
Name: tags[i-1].Name,
Date: tags[i-1].Date,
}
}
if i+1 < total {
prev = &RelateTag{
Name: tags[i+1].Name,
Date: tags[i+1].Date,
}
}
tag.Next = next
tag.Previous = prev
}
return tags, nil
}