diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index 973dfb3..c9d7c02 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -35,8 +35,10 @@ %} {% endif %} + {% if _content contains '' | first | split: ' ' %} + + {% for _attr in _attrs %} + {% capture _key %}{{ _attr | split: '=' | first }}{% endcapture %} + {% capture _value %}{{ _attr | split: '=' | last | replace: '"', '' }}{% endcapture %} + + {% case _key %} + {% when 'width' %} + {% assign _width = _value %} + {% when 'height' %} + {% assign _height = _value %} + {% endcase %} + + {% if _width and _height %} + {% capture _svg %}data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{_width}} {{_height}}'%3E%3C/svg%3E{% endcapture %} + {% assign _img_content = _img_content | append: ' {{ _content }} diff --git a/_javascript/utils/img-extra.js b/_javascript/utils/img-extra.js index bdc60e0..91e7324 100644 --- a/_javascript/utils/img-extra.js +++ b/_javascript/utils/img-extra.js @@ -11,10 +11,10 @@ $(function() { return; } - /* lozy loading */ + /* lazy loading */ - const imgs = document.querySelectorAll(`${IMG_SCOPE} img[data-src]`); - const observer = lozad(imgs); + const imgList = document.querySelectorAll(`${IMG_SCOPE} img[data-src]`); + const observer = lozad(imgList); observer.observe(); /* popup */ @@ -40,9 +40,8 @@ $(function() { } }); - /* markup the image links */ + $(`${IMG_SCOPE} a`).has("img").addClass('img-link'); }); - diff --git a/_layouts/post.html b/_layouts/post.html index d95aec6..2cea2c6 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -44,7 +44,11 @@ layout: default