Skip to content

Commit 8386cee

Browse files
committed
Followed blogs show on homepage
1 parent a5771b2 commit 8386cee

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

DB/lib/BlogDB/DB/Result/Person.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,12 @@ sub is_following_blog {
335335
return $count >= 1 ? 1 : 0;
336336
}
337337

338+
sub get_followed_blogs {
339+
my ( $self ) = @_;
340+
341+
return [ map {
342+
$_->blog
343+
} $self->search_related('person_follow_blog_maps')->all ];
344+
}
345+
338346
1;

Web/templates/default/index.html.tx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@
1616
</form>
1717
</div>
1818

19+
<h2>Followed Blogs</h2>
20+
<div class="row row-cols-3 row-cols-md-3 g-4">
21+
%% for $person.get_followed_blogs -> $blog {
22+
<div class="col">
23+
<div class="card" style="width: 24rem;">
24+
<img src="[% $blog.img_url %]" class="card-img-top" alt="Screenshot">
25+
<div class="card-body">
26+
<h5 class="card-title">[% $blog.title %]</h5>
27+
<p class="card-text">
28+
[% $blog.tagline %] <br />
29+
About: [% $blog.about %]<br/>
30+
</p>
31+
</div>
32+
<div class="card-footer">
33+
<a href="[% $c.url_for( 'view_blog', slug => $blog.slug ) %]" class="btn btn-primary">View Blog</a>
34+
</div>
35+
</div>
36+
</div>
37+
%% }
38+
</div>
39+
40+
<h2>All Blogs</h2>
1941
<div class="row row-cols-3 row-cols-md-3 g-4">
2042
%% for $blogs -> $blog {
2143
<div class="col">

0 commit comments

Comments
 (0)