feat: SEO — meta tags, keywords, SSR vendors, robots.txt, sitemap.xml, Schema.org
This commit is contained in:
+41
-1
@@ -548,7 +548,47 @@ def apply_pending_overlay(
|
||||
|
||||
@bp.get("/")
|
||||
def index():
|
||||
return render_template("index.html")
|
||||
conn = get_db()
|
||||
ssr_vendors = [r[0] for r in conn.execute("SELECT name FROM vendors ORDER BY lower(name)")]
|
||||
ssr_categories = [r[0] for r in conn.execute(
|
||||
"SELECT name FROM (SELECT name FROM categories UNION SELECT name FROM ib_categories) ORDER BY lower(name)"
|
||||
)]
|
||||
conn.close()
|
||||
proto = request.headers.get("X-Forwarded-Proto", "https")
|
||||
canonical_url = f"{proto}://{request.host}"
|
||||
return render_template("index.html",
|
||||
ssr_vendors=ssr_vendors,
|
||||
ssr_categories=ssr_categories,
|
||||
canonical_url=canonical_url,
|
||||
)
|
||||
|
||||
|
||||
@bp.get("/robots.txt")
|
||||
def robots_txt():
|
||||
from flask import Response
|
||||
body = (
|
||||
"User-agent: *\n"
|
||||
"Allow: /\n"
|
||||
f"Disallow: {ADMIN_PATH}\n"
|
||||
"Disallow: /sdjlkfhsjkadahjksdhjgfkhsssssdjkjfljsdfjklsdajfkldsjflksdjfkldsj\n"
|
||||
"\n"
|
||||
f"Sitemap: https://{{host}}/sitemap.xml\n"
|
||||
).replace("{host}", request.host)
|
||||
return Response(body, mimetype="text/plain")
|
||||
|
||||
|
||||
@bp.get("/sitemap.xml")
|
||||
def sitemap_xml():
|
||||
from flask import Response
|
||||
proto = request.headers.get("X-Forwarded-Proto", "https")
|
||||
base = f"{proto}://{request.host}"
|
||||
body = (
|
||||
'<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
|
||||
f' <url><loc>{base}/</loc><changefreq>weekly</changefreq><priority>1.0</priority></url>\n'
|
||||
'</urlset>'
|
||||
)
|
||||
return Response(body, mimetype="application/xml")
|
||||
|
||||
|
||||
@bp.get("/api/data")
|
||||
|
||||
Reference in New Issue
Block a user