Reverse the order of listed items in html

I want the latest post to be at the top of the page and the posts listed in descending order.

I have tried this:

  @each(post in posts)

         <div class="post-preview">
           <a href="/post/{{ post._id }}">
             <h3 class="post-title">
               {{ post.title }}
             </h3>

           </a>
             <p class="post-meta">Posted by
                 <a href="#">{{ post.username }}</a>
                 on {{ post.createdAt.toDateString() }}
             </p>

         </div>
         <hr>
       @endeach

this puts each new blog post under each other. how do i reverse this?

1 answer

  • answered 2019-10-15 20:18 flppv

    Well, if you can't rearrange data itself, you can use display: flex; flex-direction: column-reverse; on parent