fix: resume the preview image SEO tag (#529)

Fix #529
This commit is contained in:
Cotes Chung 2022-03-16 19:43:23 +08:00
parent a60a4562bf
commit b8d1bcd3de
No known key found for this signature in database
GPG Key ID: 0D9E54843167A808
2 changed files with 26 additions and 3 deletions

View File

@ -23,7 +23,30 @@
{% endif %}
{% seo title=false %}
{% capture seo_tags %}
{% seo title=false %}
{% endcapture %}
{% if site.img_cdn and seo_tags contains 'og:image' %}
{% assign properties = 'og:image,twitter:image' | split: ',' %}
{% for prop in properties %}
{% if site.img_cdn contains '//' %}
<!-- `site.img_cdn` cross-origin URL -->
{% capture target %}<meta property="{{ prop }}" content="{{ site.url }}{% endcapture %}
{% capture replacement %}<meta property="{{ prop }}" content="{{ site.img_cdn }}{% endcapture %}
{% else %}
<!-- `site.img_cdn` is a local file path -->
{% capture target %}<meta property="{{ prop }}" content="{{ site.url }}{{ site.baseurl }}{% endcapture %}
{% assign replacement = target | append: site.img_cdn %}
{% endif %}
{% assign seo_tags = seo_tags | replace: target, replacement %}
{% endfor %}
{% endif %}
{{ seo_tags }}
<title>
{%- unless page.layout == "home" -%}

View File

@ -11,11 +11,11 @@ tail_includes:
{% include lang.html %}
{% if page.image.src %}
{% if page.image.path %}
{% capture bg %}
{% unless page.image.no_bg %}{{ 'bg' }}{% endunless %}
{% endcapture %}
<img src="{{ page.image.src }}" class="preview-img {{ bg | strip }}"
<img src="{{ page.image.path }}" class="preview-img {{ bg | strip }}"
alt="{{ page.image.alt | default: "Preview Image" }}"
{% if page.image.width %}