From 2967956cc54f2efbdccc2b9b70a04b5d468e7351 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:06:49 +1300 Subject: [PATCH] only include indexable posts in sitemap.xml --- app/main/routes.py | 10 ++-------- app/templates/post/post_teaser/_title.html | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/main/routes.py b/app/main/routes.py index 8ebf2201..0956b6c9 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -465,14 +465,8 @@ def robots(): @bp.route('/sitemap.xml') @cache.cached(timeout=6000) def sitemap(): - posts = Post.query.filter(Post.from_bot == False, Post.deleted == False) - posts = posts.join(Community, Community.id == Post.community_id) - posts = posts.filter(Community.show_all == True, Community.ap_id == None) # sitemap.xml only includes local posts - if not g.site.enable_nsfw: - posts = posts.filter(Community.nsfw == False) - if not g.site.enable_nsfl: - posts = posts.filter(Community.nsfl == False) - posts = posts.order_by(desc(Post.posted_at)) + posts = Post.query.filter(Post.from_bot == False, Post.deleted == False, Post.instance_id == 1, Post.indexable == True) + posts = posts.order_by(desc(Post.posted_at)).limit(100) resp = make_response(render_template('sitemap.xml', posts=posts, current_app=current_app)) resp.mimetype = 'text/xml' diff --git a/app/templates/post/post_teaser/_title.html b/app/templates/post/post_teaser/_title.html index 4b5a7bc9..fde1df05 100644 --- a/app/templates/post/post_teaser/_title.html +++ b/app/templates/post/post_teaser/_title.html @@ -1,4 +1,4 @@ -