<!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 href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="../../public/assets/css/styles.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;700&family=Roboto:wght@300;700&display=swap"
        rel="stylesheet">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link
        href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;700&family=Roboto:wght@300;400;700&display=swap"
        rel="stylesheet">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link
        href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;700&family=Roboto:wght@300;400;700;900&display=swap"
        rel="stylesheet">
    <title>Deep Thoughts by Sarah D.</title>
</head>

<body>
    <div class="container">
        <div class="mb-4 header">
            <h1>Deep Thoughts</h1>
            <h4>by Sarah D.</h4>
        </div>
        <div class="new-container">
            <button class="btn new-btn">
                <a href="/blogposts/new">New Post</a>
            </button>
        </div>
        <% blogposts.forEach(blogpost=> { %>
            <div class="card mt-4">
                <div class="card-body">
                    <h4 class="card-title">
                        <%= blogpost.title %>
                    </h4>
                    <div class="card-subtitle text-muted mb-2">
                        <%= blogpost.dateCreated.toLocaleDateString() %>
                    </div>
                    <p class="card-text mb-2">
                        <%= blogpost.description %>
                    </p>
                    <a href="blogposts/<%= blogpost.slug %>" class="btn show-btn">Read More</a>
                    <a href="blogposts/edit/<%= blogpost.id %>" class="btn edit-btn">Edit</a>
                    <form action="/blogposts/<%= blogpost.id %>?_method=DELETE" method="POST" class="d-inline">
                        <button type="submit" class="btn delete-btn">Delete</button>
                    </form>
                </div>
            </div>
            <%}) %>
    </div>
</body>

</html>