feat: allow publishing posts without indexing them

This commit is contained in:
Konstantin 2025-05-21 10:50:55 +02:00
parent 38d59de6c0
commit 36e46f8cfd
Signed by: konstantin
GPG key ID: A128B78773E41ACE
2 changed files with 6 additions and 1 deletions

View file

@ -5,6 +5,8 @@ from urllib.parse import urlparse
from base.indexnow import get_key
import requests
from blog.models import BlogPage
@hooks.register('after_publish_page')
def after_publish_page(request, page):
@ -14,6 +16,9 @@ def after_publish_page(request, page):
if urlparse(page_url).hostname == "localhost":
print("not notifying indexnow for localhost" + get_key() + ", page url: " + page_url)
return
if urlparse(page_url).path.endswith("--priv") or urlparse(page_url).path.endswith("--priv/"):
print("not notifying indexnow for blog page --priv")
return
session = requests.Session()
session.post(
"https://api.indexnow.org/indexnow",