fix(seo): correct social preview image path inside `<meta>` tag (#1623)

This commit is contained in:
Cotes Chung 2024-03-23 03:32:03 +08:00 committed by GitHub
parent cfe44f204b
commit 74cf57aaac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 14 deletions

View File

@ -14,26 +14,28 @@
{%- if url -%}
{% unless url contains ':' %}
{%- comment -%} CND URL {%- endcomment -%}
{% assign prefix = site.img_cdn | default: '' %}
{%- comment -%} Add page image path prefix {%- endcomment -%}
{% assign url = include.img_path | default: '' | append: '/' | append: url %}
{% assign url = prefix
{%- comment -%} CND URL {%- endcomment -%}
{% if site.img_cdn %}
{% assign url = site.img_cdn
| append: '/'
| append: url
| replace: '///', '/'
| replace: '//', '/'
| replace: ':', ':/'
| replace: ':/', '://'
%}
{% unless site.img_cdn contains ':' %}
{% if include.absolute %}
{% assign url = site.url | append: site.baseurl | append: url %}
{% else %}
{% assign url = site.baseurl | append: url %}
{% endif %}
{% endunless %}
{% endif %}
{% endunless %}
{%- endif -%}
{{- url -}}