From b8d1bcd3dea0abd1afef7ef154a4501fbb18938d Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:43:23 +0800 Subject: [PATCH 1/5] fix: resume the preview image SEO tag (#529) Fix #529 --- _includes/head.html | 25 ++++++++++++++++++++++++- _layouts/post.html | 4 ++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/_includes/head.html b/_includes/head.html index 50e021488a9..948c4f8d5d1 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -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 '//' %} + + {% capture target %} Date: Wed, 16 Mar 2022 19:49:14 +0800 Subject: [PATCH 2/5] fix: when the `site.img_cdn` is set to the local path, the preview-image path loses the `baseurl` --- _includes/refactor-content.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index 6db89236f73..dd09205b6e4 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -92,7 +92,11 @@ {% if site.img_cdn %} - {% assign _src_prefix = site.img_cdn %} + {% if site.img_cdn contains '//' %} + {% assign _src_prefix = site.img_cdn %} + {% else %} + {% assign _src_prefix = site.img_cdn | relative_url %} + {% endif %} {% else %} {% assign _src_prefix = site.baseurl %} {% endif %} From 67d51d5df2ad258aeeec6a99e6d41e42592a14cb Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 16 Mar 2022 19:49:57 +0800 Subject: [PATCH 3/5] docs: update preview image's font-matter --- _posts/2019-08-08-text-and-typography.md | 2 +- _posts/2019-08-08-write-a-new-post.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_posts/2019-08-08-text-and-typography.md b/_posts/2019-08-08-text-and-typography.md index cf38af497ba..23f7c03f1a2 100644 --- a/_posts/2019-08-08-text-and-typography.md +++ b/_posts/2019-08-08-text-and-typography.md @@ -9,7 +9,7 @@ tags: [typography] math: true mermaid: true image: - src: /commons/devices-mockup.png + path: /commons/devices-mockup.png width: 800 height: 500 --- diff --git a/_posts/2019-08-08-write-a-new-post.md b/_posts/2019-08-08-write-a-new-post.md index c52c2f1e023..4696e318f7d 100644 --- a/_posts/2019-08-08-write-a-new-post.md +++ b/_posts/2019-08-08-write-a-new-post.md @@ -221,12 +221,12 @@ The output will be: ### Preview Image -If you want to add an image to the top of the post contents, specify the attribute `src`, `width`, `height`, and `alt` for the image: +If you want to add an image to the top of the post contents, specify the attribute `path`, `width`, `height`, and `alt` for the image: ```yaml --- image: - src: /path/to/image/file + path: /path/to/image/file width: 1000 # in pixels height: 400 # in pixels alt: image alternative text @@ -235,7 +235,7 @@ image: Except for `alt`, all other options are necessary, especially the `width` and `height`, which are related to user experience and web page loading performance. The above section "[Size](#size)" also mentions this. -Starting from _Chirpy v5.0.0_, the attributes `height` and `width` can be abbreviated: `height` → `h`, `width` → `w`. In addition, the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `src` only needs the image file name. +Starting from _Chirpy v5.0.0_, the attributes `height` and `width` can be abbreviated: `height` → `h`, `width` → `w`. In addition, the [`img_path`](#image-path) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name. ## Pinned Posts From 96a16c868ede51e7dfa412de63ffa1e5a49add7f Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Thu, 17 Mar 2022 00:29:00 +0800 Subject: [PATCH 4/5] fix: correct the `twitter:creator` of Twitter summary card --- _data/authors.yml | 17 +++++++++++++++++ _layouts/post.html | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 _data/authors.yml diff --git a/_data/authors.yml b/_data/authors.yml new file mode 100644 index 00000000000..f012012135a --- /dev/null +++ b/_data/authors.yml @@ -0,0 +1,17 @@ +## Template › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/advanced-usage.md#setting-author-url +# ------------------------------------- +# {author_id}: +# name: {full name} +# twitter: {twitter_of_author} +# url: {homepage_of_author} +# ------------------------------------- + +cotes: + name: Cotes Chung + twitter: cotes2020 + url: https://github.com/cotes2020/ + +sille_bille: + name: Dinesh Prasanth Moluguwan Krishnamoorthy + twitter: dinesh_MKD + url: https://github.com/SilleBille/ diff --git a/_layouts/post.html b/_layouts/post.html index 48e1d757d9b..e571d71b543 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -37,11 +37,11 @@