Skip to content

Commit 7750685

Browse files
authored
Merge pull request #467 from pyvec/copilot/fix-466
Fix og:image to use absolute URLs for social media compatibility
2 parents b406ea9 + 8549522 commit 7750685

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/_templates/page.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
{%- block extrahead %}
1414
{{ super() }}
15-
<meta property="og:image" content="{{ pathto('_static/images/og-image.png', 1) }}">
15+
{%- if site_baseurl -%}
16+
<meta property="og:image" content="{{ site_baseurl.rstrip('/') }}/{{ pathto('_static/images/og-image.png', 1).lstrip('./') }}">
17+
{%- else -%}
18+
<meta property="og:image" content="{{ pathto('_static/images/og-image.png', 1) }}">
19+
{%- endif -%}
1620
<meta property="og:image:type" content="image/png">
17-
<meta property="og:image:alt" content="Ilustrace organizátora Python akcí">
1821
{%- endblock -%}

docs/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,9 @@
151151
def setup(app):
152152
app.add_css_file("custom.css")
153153
app.add_js_file("redirect.js")
154+
155+
# Make html_baseurl available in templates as site_baseurl
156+
def add_baseurl_to_context(app, pagename, templatename, context, doctree):
157+
context['site_baseurl'] = app.config.html_baseurl
158+
159+
app.connect('html-page-context', add_baseurl_to_context)

0 commit comments

Comments
 (0)