Kaynağa Gözat

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)
Hugo Locurcio 4 yıl önce
ebeveyn
işleme
6c87f04926
3 değiştirilmiş dosya ile 8 ekleme ve 0 silme
  1. 1 0
      _templates/layout.html
  2. 4 0
      conf.py
  3. 3 0
      requirements.txt

+ 1 - 0
_templates/layout.html

@@ -1,5 +1,6 @@
 {% extends "!layout.html" -%}
 {% block linktags -%}
+  <meta name="theme-color" content="#3d8fcc">
   {% 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 -#}

+ 4 - 0
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")
 

+ 3 - 0
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 `<head>` tag
+sphinxext-opengraph==0.4.1
+
 # Full-page search UI for RTD: https://readthedocs-sphinx-search.readthedocs.io
 readthedocs-sphinx-search==0.1.0rc3