diff --git a/myblog/blog/views.py b/myblog/blog/views.py index 5305f36..123f6bf 100644 --- a/myblog/blog/views.py +++ b/myblog/blog/views.py @@ -34,12 +34,12 @@ def index(request): posts = posts.order_by('-publish_date').distinct() - # 为每篇文章添加摘要(前200个字符) + # 为每篇文章添加摘要(前50个字符) for post in posts: - # 移除HTML标签并截取前200个字符作为摘要 + # 移除HTML标签并截取前50个字符作为摘要 import re 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', { 'posts': posts,