From 2470d72dec9aa15c316325aafc35ca41ec638f66 Mon Sep 17 00:00:00 2001 From: Hsiaoming Yang Date: Sun, 14 Apr 2024 17:23:51 +0900 Subject: [PATCH] chore: add sitemap for docs --- .gitignore | 1 + docs/conf.py | 13 ++++++++++++- public/robots.txt | 3 +++ requirements/docs.txt | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 public/robots.txt diff --git a/.gitignore b/.gitignore index 28b3516..6f5d8ea 100644 --- a/.gitignore +++ b/.gitignore @@ -56,4 +56,5 @@ __pypackages__/ public/en public/zh +public/sitemap.xml demo.py diff --git a/docs/conf.py b/docs/conf.py index 215f51a..7c3f5e0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,6 +25,7 @@ "sphinx.ext.extlinks", "sphinx_copybutton", "sphinx_design", + "sphinx_sitemap", ] extlinks = { @@ -83,11 +84,21 @@ "source_docs_path": "/docs/", } +# sitemap configuration +site_url = "https://jose.authlib.org/" +sitemap_url_scheme = "{lang}{link}" +sitemap_filename = "../sitemap.xml" +sitemap_locales = [] + def setup(app): - global language, html_baseurl + global language, html_baseurl, sitemap_filename, sitemap_locales language = app.config.language + if language != 'en': + sitemap_filename = 'sitemap.xml' + sitemap_locales = [None] + html_baseurl = f"https://jose.authlib.org/{language}/" html_context["languages"] = [ ("English", f"https://jose.authlib.org/en/%s/", "en"), diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..3fe9cb6 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +User-agent: * + +Sitemap: https://jose.authlib.org/sitemap.xml diff --git a/requirements/docs.txt b/requirements/docs.txt index 11e3bf1..d192919 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -1,4 +1,5 @@ Sphinx sphinx-design sphinx-copybutton +sphinx-sitemap shibuya