fix: `og:image` will be incorrect if the image uses a cross-domain URL

This commit is contained in:
Cotes Chung 2022-12-15 22:55:52 +08:00
parent 4b6ccbcbcc
commit 8de1abda6b
No known key found for this signature in database
GPG Key ID: 0D9E54843167A808
1 changed files with 17 additions and 12 deletions

View File

@ -24,6 +24,8 @@
{% if page.image %} {% if page.image %}
{% assign img = page.image.path | default: page.image %} {% assign img = page.image.path | default: page.image %}
{% unless img contains '://' %}
{% assign img_path = page.img_path | append: '/' | append: img | replace: '//', '/' %} {% assign img_path = page.img_path | append: '/' | append: img | replace: '//', '/' %}
{% capture target %}"{{ img | absolute_url }}"{% endcapture %} {% capture target %}"{{ img | absolute_url }}"{% endcapture %}
@ -38,6 +40,9 @@
{% endif %} {% endif %}
{% assign seo_tags = seo_tags | replace: target, replacement %} {% assign seo_tags = seo_tags | replace: target, replacement %}
{% endunless %}
{% endif %} {% endif %}
{{ seo_tags }} {{ seo_tags }}