mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 21:53:26 +00:00
feat: add site-wide social preview image settings (#1463)
- Add configuration field `social_preview_image` that sets the site-wide default social preview image. For pages that do not have `page.image` set in font matter, the seo tag will use the image specified by `site.social_preview_image` as the Open Graph image. - Refactored the generation of image URLs to reduce redundant code and enhance fault tolerance for missing or repeated slash `/` when defining image paths.
This commit is contained in:
24
_includes/img-url.html
Normal file
24
_includes/img-url.html
Normal file
@@ -0,0 +1,24 @@
|
||||
{%- comment -%}
|
||||
Generate image final URL based on `site.img_cdn`, `page.img_path`
|
||||
|
||||
Arguments:
|
||||
src - basic image path, required
|
||||
img_path - relative path of image, optional
|
||||
|
||||
Return:
|
||||
image URL
|
||||
{%- endcomment -%}
|
||||
|
||||
{% assign url = include.src %}
|
||||
|
||||
{%- if url -%}
|
||||
{%- comment -%} CND URL {%- endcomment -%}
|
||||
{% assign prefix = site.img_cdn | default: '' | relative_url %}
|
||||
|
||||
{%- comment -%} Add page image path prefix {%- endcomment -%}
|
||||
{% assign url = include.img_path | default: '' | append: '/' | append: url %}
|
||||
|
||||
{% assign url = prefix | append: '/' | append: url | replace: '///', '/' | replace: '//', '/' | replace: ':', ':/' %}
|
||||
{%- endif -%}
|
||||
|
||||
{{- url -}}
|
||||
Reference in New Issue
Block a user