블로그 기능 구현
> 글쓰기, 수정, 삭제 구현 > 목록 페이지 벽돌 레이아웃 구성 > 로그인 기능 추가 > 컨텐츠 공개/숨김 기능 추가
This commit is contained in:
@@ -1,32 +1,37 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<style>
|
||||
.blog-card {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.blog-card img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
<div class="uk-container">
|
||||
<div class="grid-container masonry-grid">
|
||||
{% for post in posts %}
|
||||
<div class="blog-card uk-card uk-card-default">
|
||||
<div class="uk-card-media-top">
|
||||
<img src="{{ post.thumbnail_img }}" alt="{{ post.title }}">
|
||||
<div class="uk-grid uk-grid-small uk-child-width-1-4@m uk-child-width-1-2@s" uk-grid>
|
||||
{% if not posts %}
|
||||
<h4 style="margin-top: 30px">작성된 포스트가 없습니다.</h4>
|
||||
{% else %}
|
||||
{% for post in posts %}
|
||||
<div>
|
||||
<div class="uk-card uk-card-default blog-card">
|
||||
<div class="uk-card-media-top">
|
||||
<img src="{{ post.thumbnail_img | default('https://via.placeholder.com/300x200', true) }}"
|
||||
alt="{{ post.title }}" style="max-width: 100%;max-height: 500px;">
|
||||
</div>
|
||||
<div class="uk-card-body">
|
||||
<h3 class="uk-card-title">{{ post.title }}</h3>
|
||||
<a href="{{ url_for('post', post_id=post.id) }}" class="uk-button uk-button-text">Read
|
||||
more</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-card-body">
|
||||
<h3 class="uk-card-title">{{ post.title }}</h3>
|
||||
<!-- Truncate the contents to 100 characters, removing any HTML tags -->
|
||||
<p>{{ post.contents | striptags | truncate(100) }}</p>
|
||||
<a href="#" class="uk-button uk-button-text">Read more</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.masonry-grid').masonry({
|
||||
// options...
|
||||
itemSelector: '.blog-card',
|
||||
columnWidth: '.blog-card',
|
||||
percentPosition: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user