preview
This commit is contained in:
17
app.py
17
app.py
@@ -1,7 +1,7 @@
|
||||
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
|
||||
from content.posts import BLOG_POSTS
|
||||
from flask_logic.logic import get_enriched_post, get_comments_for_post, save_comment
|
||||
from flask_logic.renderer import process_post_content, collect_css
|
||||
from flask_logic.renderer import process_post_content, collect_css, generate_preview
|
||||
# 🌟 IMPORT THE content from separate files.
|
||||
from content.posts import BLOG_POSTS
|
||||
from content.about_text import ABOUT, TITLE
|
||||
@@ -78,13 +78,26 @@ def calculate_pagination(posts, posts_per_page, page):
|
||||
'total_posts': total_posts
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
posts_with_preview = []
|
||||
for post in BLOG_POSTS:
|
||||
preview = generate_preview(post.get("content", ""))
|
||||
|
||||
post_copy = dict(post)
|
||||
post_copy["preview"] = preview
|
||||
|
||||
posts_with_preview.append(post_copy)
|
||||
"""Home page with paginated blog posts."""
|
||||
page = request.args.get('page', 1, type=int)
|
||||
blog_title = TITLE
|
||||
|
||||
pagination = calculate_pagination(BLOG_POSTS, POSTS_PER_PAGE, page)
|
||||
pagination = calculate_pagination(posts_with_preview, POSTS_PER_PAGE, page)
|
||||
|
||||
return render_template('index.html',
|
||||
posts=pagination['posts_to_show'],
|
||||
|
||||
Reference in New Issue
Block a user