Revert "Simplify the first post and last post generation"

This reverts commit d5e6973e8229d6b55f3656b58a904d314b92ccbe.