From b2b6922a8f67d9c031bcbe317bd65a8c8f9d3877 Mon Sep 17 00:00:00 2001 From: Dean Attali Date: Tue, 7 Jul 2020 05:14:01 +0000 Subject: [PATCH] if share-img not provided, use cover-img or thumbnail. Also make sure all images work with both relative and absolute paths --- README.md | 6 ++-- _includes/head.html | 31 +++++++++++++------ _includes/header.html | 4 +-- _layouts/home.html | 14 ++++----- .../2020-02-26-flake-it-till-you-make-it.md | 2 +- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 3f40807..90520e9 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Parameter | Description title | Page or blog post title subtitle | Short description of page or blog post that goes under the title tags | List of tags to categorize the post. Separate the tags with commas and place them inside square brackets. Example: `[personal, analysis, finance]` -cover-img | Include a large full-width image at the top of the page. You can either provide the path to a single image (eg. `"/path/to/img"`) , or a list of images to cycle through (eg. `["/path/img1", "/path/img2"]`). The first image will also be used as the thumbnail in the feed page. If you want to add a caption to an image, then the image should be provided as `{"/path/to/img" : "Caption of image"}`. +cover-img | Include a large full-width image at the top of the page. You can either provide the path to a single image (eg. `"/path/to/img"`) , or a list of images to cycle through (eg. `["/path/img1", "/path/img2"]`). If you want to add a caption to an image, then the image should be provided as `{"/path/to/img" : "Caption of image"}`. comments | If you want do add comments to a specific page, use `comments: true`. Comments only work if you enable one of the comments providers (Facebook, disqus, staticman, utterances) in `_config.yml` file. Comments are automatically enabled on blog posts but not on other pages; to turn comments off for a specific post, use `comments: false`. ## Less commonly used parameters @@ -140,8 +140,8 @@ Parameter | Description ----------- | ----------- readtime | If you want a post to show how many minutes it will take to read it, use `readtime: true`. show-avatar | If you have an avatar configured in the `_config.yml` but you want to turn it off on a specific page, use `show-avatar: false`. -thumbnail-img | For blog posts, if you want to add a thumbnail that'll show up next to the post's excerpt in the feed, use `thumbnail-img: /path/to/image`. You can use `thumbnail-img: ""` to disable a thumbnail. -share-img | If you want to specify an image to use when sharing the page on Facebook or Twitter, then provide the image's path or full URL here. +thumbnail-img | For blog posts, if you want to add a thumbnail that'll show up next to the post's excerpt in the feed, use `thumbnail-img: /path/to/image`. If no thumbnail is provided, then `cover-img` will be used as the thumbnail. You can use `thumbnail-img: ""` to disable a thumbnail. +share-img | The image to use when sharing the page to social media. If not provided, then `cover-img` or `thumbnail-img` will be used. social-share | By default, every blog post has buttons to share the page on social media. If you want to turn this feature off, use `social-share: false`. nav-short | By default, the navigation bar gets shorter after scrolling down the page. If you want the navigation bar to always be short on a certain page, use `nav-short: true` gh-repo   | If you want to show GitHub buttons at the top of a post, this sets the GitHub repo name (eg. `daattali/beautiful-jekyll`). You must also use the `gh-badge` parameter to specify what buttons to show. diff --git a/_includes/head.html b/_includes/head.html index 4f9a67c..e75689a 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -80,15 +80,30 @@ {% endif %} - {% if page.share-img %} - - {% elsif site.avatar %} - + {%- capture shareimg -%} + {% if page.share-img %} + {{ page.share-img }} + {% elsif page.cover-img %} + {% if page.cover-img.first %} + {{ page.cover-img[0].first.first }} + {% else %} + {{ page.cover-img }} + {% endif %} + {% elsif page.thumbnail-img %} + {{ page.thumbnail-img }} + {% elsif site.avatar %} + {{ site.avatar }} + {% endif %} + {% endcapture %} + {% assign shareimg=shareimg | strip %} + + {% if shareimg != "" %} + {% endif %} - {% if page.share-img %} + {% if shareimg != "" %} {% else %} @@ -112,10 +127,8 @@ {% endif %} - {% if page.share-img %} - - {% elsif site.avatar %} - + {% if shareimg != "" %} + {% endif %} {% if site.matomo %} diff --git a/_includes/header.html b/_includes/header.html index 9964c40..f91bcef 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -10,10 +10,10 @@ {% assign imgnum = forloop.index %} {% for imginfo in bigimg %} {% if imginfo[0] %} - data-img-src-{{ imgnum }}="{{ imginfo[0] | relative_url }}" + data-img-src-{{ imgnum }}="{{ imginfo[0] | absolute_url }}" data-img-desc-{{ imgnum }}="{{ imginfo[1] }}" {% else %} - data-img-src-{{ imgnum }}="{{ imginfo | relative_url }}" + data-img-src-{{ imgnum }}="{{ imginfo | absolute_url }}" {% endif %} {% endfor %} {% endfor %} diff --git a/_layouts/home.html b/_layouts/home.html index f77caad..e5275a9 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -9,7 +9,7 @@ layout: page
{% for post in posts %}
@@ -60,7 +60,7 @@ layout: page Tags: {% if site.link-tags %} {% for tag in post.tags %} - {{- tag -}} + {{- tag -}} {% endfor %} {% else %} {{ post.tags | join: ", " }} @@ -76,12 +76,12 @@ layout: page diff --git a/_posts/2020-02-26-flake-it-till-you-make-it.md b/_posts/2020-02-26-flake-it-till-you-make-it.md index 5c06d2a..b9b550a 100644 --- a/_posts/2020-02-26-flake-it-till-you-make-it.md +++ b/_posts/2020-02-26-flake-it-till-you-make-it.md @@ -3,7 +3,7 @@ layout: post title: Flake it till you make it subtitle: Excerpt from Soulshaping by Jeff Brown cover-img: /assets/img/path.jpg -thumbnail-img: "/assets/img/thumb.png" +thumbnail-img: /assets/img/thumb.png share-img: /assets/img/path.jpg tags: [books, test] ---