From 6c87f0492651cf2633c351a91216bde9accf6dcd Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 18 Mar 2021 20:19:43 +0100 Subject: [PATCH] Add Open Graph tags for better link preview on social media This is provided by the sphinxext-opengraph extension. This also adds a theme color property in the HTML layout file. (cherry picked from commit 9becaa548031266bc670d5fe93e49b8e1eb708d7) --- _templates/layout.html | 1 + conf.py | 4 ++++ requirements.txt | 3 +++ 3 files changed, 8 insertions(+) diff --git a/_templates/layout.html b/_templates/layout.html index 6a55c539a..fdec13a7b 100644 --- a/_templates/layout.html +++ b/_templates/layout.html @@ -1,5 +1,6 @@ {% extends "!layout.html" -%} {% block linktags -%} + {% if godot_inject_language_links -%} {% for alternate_lang in godot_docs_supported_languages -%} {# Convert to ISO 639-1 format, e.g. zh_CN -> zh-cn -#} diff --git a/conf.py b/conf.py index 0df941667..620cfc0d4 100644 --- a/conf.py +++ b/conf.py @@ -15,6 +15,7 @@ sys.path.append(os.path.abspath("_extensions")) extensions = [ "sphinx_tabs.tabs", "notfound.extension", + "sphinxext.opengraph", ] # Warning when the Sphinx Tabs extension is used with unknown @@ -54,6 +55,9 @@ on_rtd = os.environ.get("READTHEDOCS", None) == "True" if not on_rtd: notfound_urls_prefix = '' +# Specify the site name for the Open Graph extension. +ogp_site_name = "Godot Engine documentation" + if not os.getenv("SPHINX_NO_GDSCRIPT"): extensions.append("gdscript") diff --git a/requirements.txt b/requirements.txt index 82ea0fb09..222559df4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,5 +12,8 @@ sphinx-tabs==1.1.13 # Custom 404 error page (more useful than the default) sphinx-notfound-page==0.6 +# Adds Open Graph tags in the HTML `` tag +sphinxext-opengraph==0.4.1 + # Full-page search UI for RTD: https://readthedocs-sphinx-search.readthedocs.io readthedocs-sphinx-search==0.1.0rc3