Change index_view 200 into 20

This commit is contained in:
2025-07-27 23:23:08 +08:00
parent 20d8180ad0
commit 4d0ea1a55b

View File

@@ -34,12 +34,12 @@ def index(request):
posts = posts.order_by('-publish_date').distinct() posts = posts.order_by('-publish_date').distinct()
# 为每篇文章添加摘要(前200个字符 # 为每篇文章添加摘要(前50个字符
for post in posts: for post in posts:
# 移除HTML标签并截取前200个字符作为摘要 # 移除HTML标签并截取前50个字符作为摘要
import re import re
clean_content = re.sub(r'<[^>]+>', '', post.get_markdown_content()) clean_content = re.sub(r'<[^>]+>', '', post.get_markdown_content())
post.summary = clean_content[:200] + '...' if len(clean_content) > 200 else clean_content post.summary = clean_content[:50] + '...' if len(clean_content) > 50 else clean_content
return render(request, 'blog/index.html', { return render(request, 'blog/index.html', {
'posts': posts, 'posts': posts,