<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
    integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" 
    crossorigin="anonymous">

    <title>Rishav's Blog</title>
</head>
<body>
    <div class="container">
        <h1 class="mb-4">Blog Articles</h1>
       <a href="/articles/new" class="btn btn-success"> New Article </a>

       
       <% articles.forEach(article => { %>
        <div class="card mt-4">
            <div class="card-body">
                <h4 class="card-title"><%= article.title %></h4>
                <div class="card-subtitle text-muted mb-2">
                   <%= article.createdAt.toLocaleDateString() %>
                </div>
                   <div class="card-text mb-2">
                    <%= article.description %> 
                    
                    <div>
                        <form action="articles/<%= article.id %>?_method=Delete" method="POST" class="d-inline">
                            <a href="articles/<%= article.id %>" class= "btn btn-primary">Read More</a>

                            <a href="/articles/edit/<%= article.id %>" class="btn btn-primary">Edit</a>
                            
                            <button type="submit" class="btn btn-danger">Delete</button>
                       </form>
                    </div>
                </div>  

            </div>
                
            </div>
        
    <%}) %>
    
</div>
    
    <!--This is html body-->
    
</body>
</html>