Skip to content

Commit

Permalink
trialling the layout of the blogheaderder.
Browse files Browse the repository at this point in the history
need to fix alignment of text
  • Loading branch information
wesleyk3y committed Jun 26, 2024
1 parent 91d2718 commit 8f02781
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
63 changes: 63 additions & 0 deletions web/src/components/BlogHeader.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
interface Props {
imageUrl: string;
title: string;
datePublished: string;
authorName: string;
content: string;
}
const { imageUrl, title, datePublished, authorName, content } = Astro.props;
---

<div class="blog-header">
<img src={imageUrl} alt={title} class="blog-header__image" />
<div class="blog-header__text">
<h1 class="blog-header__title">{title}</h1>
<div class="blog-header__meta">
<span class="blog-header__author">{authorName}</span> | <span class="blog-header__date">{datePublished}</span>
</div>
<p class="blog-header__content">{content}</p>
</div>
</div>

<style>
.blog-header {
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
text-align: center;
}

.blog-header__image {
max-width: 100%;
height: auto;
border-radius: 10px;
}

.blog-header__text {
max-width: 800px;
}

.blog-header__title {
font-size: 2.5rem;
margin: 1rem 0;
}

.blog-header__meta {
font-size: 1rem;
color: #6c757d;
}

.blog-header__author, .blog-header__date {
font-weight: bold;
color: #087DF1;
}

.blog-header__content {
font-size: 1.25rem;
color: #343a40;
margin-top: 1rem;
}
</style>
19 changes: 16 additions & 3 deletions web/src/pages/blogs/[blog].astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
---
// src/pages/blogs/[blog].astro
import BlogHeader from "@/components/BlogHeader.astro";
import SwiperCarouselWrapper from "@/components/SwiperCarouselWrapper.astro";
import Layout from "@/layouts/layout.astro";
const { blog } = Astro.params;
const blogData = {
imageUrl: '/path/to/image.jpg', // Update this to the path of your image
title: 'Blog Title',
datePublished: 'Date Published',
authorName: 'Author Name',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
};
const articles = [
{
title: 'Article 1',
Expand All @@ -32,7 +39,13 @@ const articles = [
---

<Layout>
<p>{ blog }</p>
<BlogHeader
imageUrl={blogData.imageUrl}
title={blogData.title}
datePublished={blogData.datePublished}
authorName={blogData.authorName}
content={blogData.content}
/>
<h2>More Blogs</h2>
<SwiperCarouselWrapper articles={articles} />
</Layout>

0 comments on commit 8f02781

Please sign in to comment.