New plugin: https://github.com/simonw/datasette-sitemap
Can replace this:
|
async def urls(datasette): |
|
paths = ["/", "/for", "/examples", "/plugins", "/tools", "/news"] |
|
db = datasette.get_database("content") |
|
for row in await db.execute("select _path from uses"): |
|
paths.append("/" + row["_path"].split(".")[0]) |
|
for row in await db.execute("select name from plugins"): |
|
paths.append("/plugins/" + row["name"]) |
|
for row in await db.execute("select name from tools"): |
|
paths.append("/tools/" + row["name"]) |
|
return ("https://datasette.io{}".format(path) for path in paths) |
|
|
|
|
|
async def sitemap_xml(datasette): |
|
content = [ |
|
'<?xml version="1.0" encoding="UTF-8"?>', |
|
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', |
|
] |
|
for url in await urls(datasette): |
|
content.append("<url><loc>{}</loc></url>".format(url)) |
|
content.append("</urlset>") |
|
return Response("\n".join(content), 200, content_type="application/xml") |
New plugin: https://github.com/simonw/datasette-sitemap
Can replace this:
datasette.io/plugins/seo.py
Lines 28 to 48 in d2c1545