diff --git a/.github/DISCUSSION_TEMPLATE/general.yml b/.github/DISCUSSION_TEMPLATE/general.yml new file mode 100644 index 0000000..4e879f9 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/general.yml @@ -0,0 +1,26 @@ +body: + - type: checkboxes + attributes: + label: Checklist + description: Following the guidelines can make you more likely to get responses. + options: + - label: >- + I have read and accepted the + [contributing guidelines](https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/docs/CONTRIBUTING.md). + required: true + + - type: dropdown + attributes: + label: What is the topic? + options: + - Sharing tips and tricks + - Just chatting + validations: + required: true + + - type: textarea + attributes: + label: Description + description: Please describe in detail what you want to share. + validations: + required: true diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml new file mode 100644 index 0000000..a2e2aa1 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -0,0 +1,40 @@ +body: + - type: checkboxes + attributes: + label: Checklist + description: Following the guidelines can make you more likely to get responses. + options: + - label: >- + I have read and accepted the + [contributing guidelines](https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/docs/CONTRIBUTING.md). + required: true + + - type: dropdown + id: download + attributes: + label: How did you create the site? + options: + - Generated from `chirpy-starter` + - Built from `jekyll-theme-chirpy` + validations: + required: true + + - type: textarea + attributes: + label: Description + description: Please describe your need in detail. + validations: + required: true + + - type: textarea + attributes: + label: Operations you have already tried + description: Describe the effort you went through. + validations: + required: true + + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Or logs? Anything that will give us more context about the issue you are encountering! diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 2eb21a1..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -name: Bug Report -about: Create a report to help us improve ---- - -> **Tips**: Remember, contributions to this repository should follow the [contributing guidelines](https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/docs/CONTRIBUTING.md). - -## Describe the bug - - - -## To Reproduce - -Steps to reproduce the behavior: - - -## Expected behavior - - - -## Logs/Screenshots - - - -## Environment - -| Command | Version | -|-----------------------------------|---------| -| `ruby -v` | | -| `gem -v` | | -| `bundle -v` | | -| `bundle exec jekyll -v` | | -| `bundle info jekyll-theme-chirpy` | | - - - - - -## Additional context - - diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..7b513fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,64 @@ +name: Bug Report +description: Create a report to help us improve +body: + - type: checkboxes + attributes: + label: Checklist + description: Following the guidelines can make you more likely to get responses. + options: + - label: >- + I have read and accepted the + [contributing guidelines](https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/docs/CONTRIBUTING.md). + required: true + + - type: dropdown + id: download + attributes: + label: How did you create the site? + options: + - Generated from `chirpy-starter` + - Built from `jekyll-theme-chirpy` + validations: + required: true + + - type: textarea + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + validations: + required: true + + - type: textarea + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run '...' + 4. See error... + validations: + required: true + + - type: textarea + attributes: + label: Expected Behavior + description: A concise description of what you expected to happen. + validations: + required: true + + - type: textarea + attributes: + label: Environment + value: | + - Ruby: + - Jekyll: + - Chirpy: + validations: + required: true + + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Or logs? Anything that will give us more context about the issue you are encountering! diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 2a8d6d6..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: Feature Request -about: Suggest an idea for this project -labels: enhancement ---- - -> **Tips**: Remember, contributions to this repository should follow the [contributing guidelines](https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/docs/CONTRIBUTING.md). - -## Is your feature request related to a problem? Please describe - - - - -## Describe the solution you'd like - - - - -## Describe alternatives you've considered - - - - -## Additional context - - diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..7957035 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,38 @@ +name: Feature Request +description: Suggest an idea for this project +labels: + - enhancement +body: + - type: checkboxes + attributes: + label: Checklist + description: Following the guidelines can make you more likely to get responses. + options: + - label: >- + I have read and accepted the + [contributing guidelines](https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/docs/CONTRIBUTING.md). + required: true + + - type: textarea + attributes: + label: Is your feature request related to a problem? Please describe + description: A clear and concise description of what the problem is. + validations: + required: true + + - type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + + - type: textarea + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ae5da61..0ff984a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,29 +1,17 @@ -## Description - - - ## Type of change - - + - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Improvement (refactoring and improving code) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update -## Additional context - - - -## How has this been tested - +## Description -- [ ] I have run `bash ./tools/test` (at the root of the project) locally and passed -- [ ] I have tested this feature in the browser +## Additional context + diff --git a/.stylelintrc.json b/.stylelintrc.json index f489fee..a4ccded 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -15,7 +15,7 @@ "scss/operator-no-newline-after": null, "rule-empty-line-before": [ "always", - { "ignore": ["after-comment", "first-nested", "inside-block"] } + { "ignore": ["after-comment", "first-nested"] } ], "value-keyword-case": ["lower", { "ignoreProperties": ["/^\\$/"] }], "media-feature-range-notation": "prefix" diff --git a/Gemfile b/Gemfile index e3415c8..043b28e 100644 --- a/Gemfile +++ b/Gemfile @@ -21,8 +21,3 @@ gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem # do not have a Java counterpart. gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] - -# Lock jekyll-sass-converter to 2.x on Linux-musl -if RUBY_PLATFORM =~ /linux-musl/ - gem "jekyll-sass-converter", "~> 2.0" -end diff --git a/README.md b/README.md index 3fb4a19..fc6bb65 100644 --- a/README.md +++ b/README.md @@ -19,45 +19,44 @@ ## Features
- - Click to view features - -

+

Click to expand/close details +   - - Dark / Light Theme Mode - - Localized UI language - - Pinned Posts on Home Page - - Hierarchical Categories - - Trending Tags - - Table of Contents - - Last Modified Date - - Syntax Highlighting - - Mathematical Expressions - - Mermaid Diagrams & Flowcharts - - Dark / Light Mode Images - - Embed Videos - - Disqus / Utterances / Giscus Comments - - Built-in Search - - Atom Feeds - - PWA - - Google Analytics - - SEO & Performance Optimization +- Dark / Light Theme Mode +- Localized UI language +- Pinned Posts on Home Page +- Hierarchical Categories +- Trending Tags +- Table of Contents +- Last Modified Date +- Syntax Highlighting +- Mathematical Expressions +- Mermaid Diagrams & Flowcharts +- Dark / Light Mode Images +- Embed Videos +- Disqus / Giscus / Utterances Comments +- Built-in Search +- Atom Feeds +- PWA +- Google Analytics +- SEO & Performance Optimization -

## Documentation -To explore usage, development, and upgrade guide of the project, please refer to the [**Wiki**][wiki]. +To learn how to use, develop, and upgrade the project, please refer to the [Wiki][wiki]. ## Contributing -Contributions (Issues/PRs/Discussions) are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. For details, see the "[Contributing Guidelines][contribute-guide]". +Contributions (_pull requests_, _issues_, and _discussions_) are what make the open-source community such an amazing place +to learn, inspire, and create. Any contributions you make are greatly appreciated. +For details, see the "[Contributing Guidelines][contribute-guide]". ## Credits -This theme is mainly built with [Jekyll][jekyllrb] ecosystem, -[Bootstrap][bootstrap], [Font Awesome][icons] and some other [wonderful tools][lib]. +This project is mainly built with [Jekyll][jekyllrb] ecosystem, +[Bootstrap][bootstrap], [Font Awesome][icons], and some other [wonderful tools][lib]. The avatar and favicon design come from [Clipart Max][image]. Many thanks to the [contributors][contributors] who participated in the development @@ -67,15 +66,15 @@ Last but not least, thanks to [JetBrains][jetbrains] for providing the _Open Sou ## Sponsoring -If you'd like to sponsor this project, the following options are available. +If you like this project or have built something through it, please consider sponsoring it, and your support would be greatly appreciated. [![Ko-fi](https://img.shields.io/badge/Support_Me_on_Ko--fi-ff5e5b?logo=ko-fi&logoColor=white)][ko-fi]  -[![Wechat Pay](https://img.shields.io/badge/Tip_Me_on_WeChat-brightgreen?logo=wechat&logoColor=white)][donation]  -[![Alipay](https://img.shields.io/badge/Tip_Me_on_Alipay-blue?logo=alipay&logoColor=white)][donation] +[![Wechat Pay](https://img.shields.io/badge/Support_Me_on_WeChat-brightgreen?logo=wechat&logoColor=white)][donation]  +[![Alipay](https://img.shields.io/badge/Support_Me_on_Alipay-blue?logo=alipay&logoColor=white)][donation] ## License -This work is published under [MIT License][license]. +This project is published under [MIT License][license]. [gem]: https://rubygems.org/gems/jekyll-theme-chirpy [ci]: https://github.com/cotes2020/jekyll-theme-chirpy/actions/workflows/ci.yml?query=event%3Apush+branch%3Amaster diff --git a/_config.yml b/_config.yml index f7245f8..05044ca 100644 --- a/_config.yml +++ b/_config.yml @@ -3,10 +3,6 @@ # Import the theme theme: jekyll-theme-chirpy -# Change the following value to '/PROJECT_NAME' ONLY IF your site type is GitHub Pages Project sites -# and doesn't have a custom domain. -baseurl: "" - # The language of the webpage › http://www.lingoes.net/en/translator/langcode.htm # If it has the same name as one of the files in folder `_data/locales`, the layout language will also be changed, # otherwise, the layout language will use the default value of 'en'. @@ -25,7 +21,8 @@ tagline: A text-focused Jekyll theme # it will display as the sub-title description: >- # used by seo meta and the atom feed A minimal, responsive and feature-rich Jekyll theme for technical writing. -# fill in the protocol & hostname for your site, e.g., 'https://username.github.io' +# Fill in the protocol & hostname for your site. +# e.g. 'https://username.github.io', note that it does not end with a '/'. url: "" github: @@ -114,6 +111,9 @@ pwa: paginate: 10 +# The base URL of your site +baseurl: "" + # ------------ The following options are not recommended to be modified ------------------ kramdown: @@ -180,7 +180,6 @@ exclude: - docs - tools - README.md - - CHANGELOG.md - LICENSE - rollup.config.js - package*.json diff --git a/_data/locales/de-DE.yml b/_data/locales/de-DE.yml index 7ea3956..6b187b4 100644 --- a/_data/locales/de-DE.yml +++ b/_data/locales/de-DE.yml @@ -58,7 +58,7 @@ post: pageview_measure: Aufrufe read_time: unit: Minuten - prompt: lesen + prompt: Lesezeit relate_posts: Weiterlesen share: Teilen button: @@ -70,6 +70,13 @@ post: title: Link kopieren succeed: Link erfolgreich kopiert! +# Date time format. +# See: , +df: + post: + strftime: "%d.%m.%Y" + dayjs: "DD.MM.YYYY" + # categories page categories: category_measure: diff --git a/_data/locales/en.yml b/_data/locales/en.yml index 2f3f339..d7faa44 100644 --- a/_data/locales/en.yml +++ b/_data/locales/en.yml @@ -40,7 +40,7 @@ copyright: Except where otherwise noted, the blog posts on this site are licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) License by the author. -meta: Using the :PLATFORM theme :THEME +meta: Using the :THEME theme for :PLATFORM not_found: statment: Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. diff --git a/_data/locales/ru-RU.yml b/_data/locales/ru-RU.yml index 4377300..185407c 100644 --- a/_data/locales/ru-RU.yml +++ b/_data/locales/ru-RU.yml @@ -3,14 +3,14 @@ # ----- Commons label ----- layout: - post: Публикация + post: Пост category: Категория tag: Тег # The tabs of sidebar tabs: # format: : - home: Домашняя страница + home: Главная categories: Категории tags: Теги archives: Архив @@ -19,8 +19,8 @@ tabs: # the text displayed in the search bar & search results search: hint: поиск - cancel: Отменить - no_results: Ох! Ничего не найдено. + cancel: Отмена + no_results: Упс! Ничего не найдено. panel: lastmod: Недавно обновлено @@ -30,48 +30,58 @@ panel: copyright: # Shown at the bottom of the post license: - template: Публикация защищена лицензией :LICENSE_NAME. + template: Авторский пост защищен лицензией :LICENSE_NAME. name: CC BY 4.0 link: https://creativecommons.org/licenses/by/4.0/ # Displayed in the footer brief: Некоторые права защищены. verbose: >- - Публикации на сайте защищены лицензией Creative Commons Attribution 4.0 International (CC BY 4.0), - если в тексте публикации не указано иное. + Если не указано иное, авторские посты на этом сайте защищены лицензией Creative Commons Attribution 4.0 International (CC BY 4.0). -meta: Powered by :PLATFORM with :THEME theme +meta: Использует тему :THEME для :PLATFORM not_found: - statment: Извините, эта ссылка указывает на ресурс который не существует. + statment: Извините, мы перепутали URL-адрес или он указывает на что-то несуществующее. notification: update_found: Доступна новая версия контента. - update: Обновлять + update: Обновить # ----- Posts related labels ----- post: written_by: Автор - posted: Время публикации + posted: Опубликовано updated: Обновлено words: слов pageview_measure: просмотров read_time: - unit: минут + unit: мин. prompt: чтения - relate_posts: Вам также может быть интересно + relate_posts: Похожие посты share: Поделиться button: - next: Предыдущая публикация - previous: Следующая публикация + next: Следующий пост + previous: Предыдущий пост copy_code: - succeed: Скопировано успешно! + succeed: Скопировано! share_link: title: Скопировать ссылку succeed: Ссылка успешно скопирована! +# Date time format. +# See: , +df: + post: + strftime: "%d.%m.%Y" + dayjs: "DD.MM.YYYY" + # categories page categories: - category_measure: категории - post_measure: публикации + category_measure: + singular: категория + plural: категории + post_measure: + singular: пост + plural: посты diff --git a/_data/origin/basic.yml b/_data/origin/basic.yml index 14d865a..ed99ea8 100644 --- a/_data/origin/basic.yml +++ b/_data/origin/basic.yml @@ -35,14 +35,12 @@ magnific-popup: css: /assets/lib/magnific-popup/magnific-popup.css js: /assets/lib/magnific-popup/jquery.magnific-popup.min.js -lazysizes: - js: /assets/lib/lazysizes/lazysizes.min.js +lazy-polyfill: + css: /assets/lib/loading-attribute-polyfill/loading-attribute-polyfill.min.css + js: /assets/lib/loading-attribute-polyfill/loading-attribute-polyfill.umd.min.js clipboard: js: /assets/lib/clipboard/clipboard.min.js -polyfill: - js: /assets/lib/polyfill-v3-es6/polyfill.min.js - mathjax: js: /assets/lib/mathjax/tex-chtml.js diff --git a/_data/origin/cors.yml b/_data/origin/cors.yml index 6d6f496..a95ef6b 100644 --- a/_data/origin/cors.yml +++ b/_data/origin/cors.yml @@ -19,12 +19,12 @@ jquery: js: https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js bootstrap: - css: https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css - js: https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js + css: https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css + js: https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js toc: - css: https://cdn.jsdelivr.net/npm/tocbot@4.21.1/dist/tocbot.min.css - js: https://cdn.jsdelivr.net/npm/tocbot@4.21.1/dist/tocbot.min.js + css: https://cdn.jsdelivr.net/npm/tocbot@4.21.2/dist/tocbot.min.css + js: https://cdn.jsdelivr.net/npm/tocbot@4.21.2/dist/tocbot.min.js fontawesome: css: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css @@ -33,27 +33,25 @@ search: js: https://cdn.jsdelivr.net/npm/simple-jekyll-search@1.10.0/dest/simple-jekyll-search.min.js mermaid: - js: https://cdn.jsdelivr.net/npm/mermaid@10.4.0/dist/mermaid.min.js + js: https://cdn.jsdelivr.net/npm/mermaid@10.5.0/dist/mermaid.min.js dayjs: js: - common: https://cdn.jsdelivr.net/npm/dayjs@1.11.9/dayjs.min.js - locale: https://cdn.jsdelivr.net/npm/dayjs@1.11.9/locale/:LOCALE.min.js - relativeTime: https://cdn.jsdelivr.net/npm/dayjs@1.11.9/plugin/relativeTime.min.js - localizedFormat: https://cdn.jsdelivr.net/npm/dayjs@1.11.9/plugin/localizedFormat.min.js + common: https://cdn.jsdelivr.net/npm/dayjs@1.11.10/dayjs.min.js + locale: https://cdn.jsdelivr.net/npm/dayjs@1.11.10/locale/:LOCALE.min.js + relativeTime: https://cdn.jsdelivr.net/npm/dayjs@1.11.10/plugin/relativeTime.min.js + localizedFormat: https://cdn.jsdelivr.net/npm/dayjs@1.11.10/plugin/localizedFormat.min.js magnific-popup: css: https://cdn.jsdelivr.net/npm/magnific-popup@1.1.0/dist/magnific-popup.min.css js: https://cdn.jsdelivr.net/npm/magnific-popup@1.1.0/dist/jquery.magnific-popup.min.js -lazysizes: - js: https://cdn.jsdelivr.net/npm/lazysizes@5.3.2/lazysizes.min.js +lazy-polyfill: + css: https://cdn.jsdelivr.net/npm/loading-attribute-polyfill@2.1.1/dist/loading-attribute-polyfill.min.css + js: https://cdn.jsdelivr.net/npm/loading-attribute-polyfill@2.1.1/dist/loading-attribute-polyfill.umd.min.js clipboard: js: https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js -polyfill: - js: https://polyfill.io/v3/polyfill.min.js?features=es6 - mathjax: js: https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-chtml.js diff --git a/_includes/comments/disqus.html b/_includes/comments/disqus.html index 02a5367..e59ed37 100644 --- a/_includes/comments/disqus.html +++ b/_includes/comments/disqus.html @@ -1,6 +1,6 @@ -
+

Comments powered by Disqus.

diff --git a/_includes/comments/giscus.html b/_includes/comments/giscus.html index ed918a9..8f04246 100644 --- a/_includes/comments/giscus.html +++ b/_includes/comments/giscus.html @@ -30,6 +30,7 @@ 'data-theme': initTheme, 'data-input-position': '{{ site.comments.giscus.input_position | default: 'bottom' }}', 'data-lang': '{{ site.comments.giscus.lang | default: lang }}', + 'data-loading': 'lazy', crossorigin: 'anonymous', async: '' }; diff --git a/_includes/comments/utterances.html b/_includes/comments/utterances.html index afd7cd3..34dddcd 100644 --- a/_includes/comments/utterances.html +++ b/_includes/comments/utterances.html @@ -1,51 +1,50 @@ - + diff --git a/_includes/embed/twitch.html b/_includes/embed/twitch.html index ab0419a..043d532 100644 --- a/_includes/embed/twitch.html +++ b/_includes/embed/twitch.html @@ -1,4 +1,7 @@ - + frameborder="0" + allowfullscreen="true" + scrolling="no" +> diff --git a/_includes/embed/youtube.html b/_includes/embed/youtube.html index 715063c..640011f 100644 --- a/_includes/embed/youtube.html +++ b/_includes/embed/youtube.html @@ -1,6 +1,9 @@ - + allowfullscreen +> diff --git a/_includes/head.html b/_includes/head.html index 408358f..fb12d99 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -80,6 +80,10 @@ {% endif %} + {% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %} + + {% endif %} + {% if page.layout == 'page' or page.layout == 'post' %} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index f6c8e9d..6352c96 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -12,7 +12,7 @@ {% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %} - {% assign urls = urls | append: ',' | append: site.data.origin[type].lazysizes.js %} + {% assign urls = urls | append: ',' | append: site.data.origin[type]['lazy-polyfill'].js %} {% unless page.layout == 'home' %} @@ -87,7 +87,7 @@ } }; - + {% endif %} diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index 655ecd6..9d4e679 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -30,22 +30,22 @@ {% endif %} + {% if _content contains '', - '' - | replace: - '', - '' + | replace: '', + '' + | replace: '', + '' %} {% endif %} - + + {% assign IMG_TAG = ' @@ -81,10 +81,9 @@ {% assign _left = _left | remove: ' /' | replace: ' w=', ' width=' | replace: ' h=', ' height=' %} {% assign _attrs = _left | split: '" ' %} - {% assign _width = nil %} - {% assign _height = nil %} - {% assign _lqip = nil %} - {% assign _class = nil %} + {% assign _src = null %} + {% assign _lqip = null %} + {% assign _class = null %} {% for _attr in _attrs %} {% unless _attr contains '=' %} @@ -96,10 +95,6 @@ {% capture _value %}{{ _pair | last | remove: '"' }}{% endcapture %} {% case _key %} - {% when 'width' %} - {% assign _width = _value %} - {% when 'height' %} - {% assign _height = _value %} {% when 'src' %} {% assign _src = _value %} {% when 'lqip' %} @@ -115,54 +110,40 @@ {% assign _left = _left | remove: _old_class %} {% endif %} - {% assign _final_src = nil %} + {% assign _final_src = null %} + {% assign _lazyload = true %} {% unless _src contains '//' %} {% assign _final_src = _path_prefix | append: _src %} - {% capture _src_from %}"{{ _src }}"{% endcapture %} - {% capture _src_to %}"{{ _final_src }}"{% endcapture %} - {% assign _left = _left | replace: _src_from, _src_to %} + {% assign _src_alt = 'src="' | append: _path_prefix %} + {% assign _left = _left | replace: 'src="', _src_alt %} {% endunless %} {% if _lqip %} - {% unless _lqip contains ':' %} - {% assign _final_lqip = _path_prefix | append: _lqip %} - {% capture _lqip_from %}"{{ _lqip }}"{% endcapture %} - {% capture _lqip_to %}"{{ _final_lqip }}"{% endcapture %} - {% assign _left = _left | replace: _lqip_from, _lqip_to %} + {% assign _lazyload = false %} + {% assign _class = _class | append: ' blur' %} + + {% unless _lqip contains 'data:' %} + {% assign _lqip_alt = 'lqip="' | append: _path_prefix %} + {% assign _left = _left | replace: 'lqip="', _lqip_alt %} {% endunless %} - {% endif %} - - {% assign _left = _left | replace: 'src=', 'data-src=' %} - {% if _left contains 'class=' %} - {% assign _left = _left | replace: 'class="', 'class="lazyload '%} + + {% assign _left = _left | replace: 'src=', 'data-src=' | replace: ' lqip=', ' data-lqip="true" src=' %} + {% else %} - {% assign _left = _left | append: ' class="lazyload"' %} + {% assign _class = _class | append: ' shimmer' %} {% endif %} - - {% if _lqip %} - {% assign _left = _left | replace: ' lqip=', ' data-lqip="true" src=' %} - {% else %} - {% if _width and _height %} - - {%- capture _svg -%} - src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{ _width }} {{ _height }}'%3E%3C/svg%3E" - {%- endcapture -%} - {% assign _left = _svg | append: ' ' | append: _left %} - {% assign _class = _class | append: ' shimmer' %} - {% endif %} + + {% if _lazyload %} + {% assign _left = _left | append: ' loading="lazy"' %} {% endif %} - - {% assign _left = _left | append: ' data-proofer-ignore' %} - {% if page.layout == 'home' %} - {%- capture _wrapper_start -%} -
- {%- endcapture -%} + {% assign _wrapper_start = '
' %} + {% assign _img_content = _img_content | append: _wrapper_start %} {% assign _right = _right | prepend: '>' %} + {% assign _img_content = _img_content | slice: 0, _size | append: _class | append: '>' %} + {% else %} - {%- capture _wrapper_start -%} - - {%- endcapture -%} + {% assign _wrapper_start = _final_src + | default: _src + | prepend: '' + %} + {% assign _img_content = _img_content | append: _wrapper_start %} - {% assign _right = _right | prepend: '> - {% assign _img_content = _img_content | append: debug | append: IMG_TAG | append: _left | append: _right %} - + {% assign _img_content = _img_content | append: IMG_TAG | append: _left | append: _right %} {% endfor %} {% if _img_content %} {% assign _content = _img_content %} {% endif %} - {% endif %} @@ -205,13 +190,11 @@ {% assign _new_content = '' %} {% for _snippet in _code_spippets %} - {% if forloop.last %} {% assign _new_content = _new_content | append: _snippet %} {% else %} - - {% assign _left = _snippet | split: '><' | last%} + {% assign _left = _snippet | split: '><' | last %} {% if _left contains 'file="' %} {% assign _label_text = _left | split: 'file="' | last | split: '"' | first %} @@ -226,21 +209,19 @@ {% endcapture %} - {% assign _new_content = _new_content | append: _snippet - | append: '
' - | append: _label - | append: '
' - | append: '
' + {% assign _new_content = _new_content + | append: _snippet + | append: '
' + | append: _label + | append: '
' + | append: '
' %} - {% endif %} - {% endfor %} {% assign _content = _new_content %} - {% endif %} @@ -249,11 +230,11 @@ {% assign _heading_content = _content %} {% for level in heading_levels %} - {% capture mark_start %}' %} {% if _heading_content contains mark_start %} - {% assign _new_content = nil %} + {% assign _new_content = null %} {% assign heading_snippets = _heading_content | split: mark_start %} {% for snippet in heading_snippets %} @@ -263,20 +244,19 @@ {% endif %} {% assign id = snippet | split: '"' | first %} - {% capture anchor %}{% endcapture %} + {% assign anchor = '' + %} {% assign left = snippet | split: mark_end | first %} {% assign right = snippet | slice: left.size, snippet.size %} {% assign left = left | replace_first: '">', '">' | append: '' %} - {% assign _new_content = _new_content | append: mark_start - | append: left | append: anchor | append: right - %} - + {% assign _new_content = _new_content | append: mark_start | append: left | append: anchor | append: right %} {% endfor %} {% assign _heading_content = _new_content %} - {% endif %} {% endfor %} diff --git a/_includes/related-posts.html b/_includes/related-posts.html index ebe98d0..1ba2f32 100644 --- a/_includes/related-posts.html +++ b/_includes/related-posts.html @@ -78,9 +78,9 @@
- {% include datetime.html date=post.date class="small" lang=include.lang %} + {% include datetime.html date=post.date lang=include.lang %}

{{ post.title }}

-
+

{% include no-linenos.html content=post.content %} {{ content | markdownify | strip_html | truncate: 200 | escape }} diff --git a/_includes/toc.html b/_includes/toc.html index a9e48e9..604d2c1 100644 --- a/_includes/toc.html +++ b/_includes/toc.html @@ -6,7 +6,7 @@ {% endif %} {% if enable_toc %} -

+

{{- site.data.locales[include.lang].panel.toc -}}

diff --git a/_javascript/home.js b/_javascript/home.js index 70af328..02948c9 100644 --- a/_javascript/home.js +++ b/_javascript/home.js @@ -1,8 +1,8 @@ import { basic, initSidebar, initTopbar } from './modules/layouts'; -import { initLocaleDatetime, imgLazy } from './modules/plugins'; +import { initLocaleDatetime, loadImg } from './modules/plugins'; basic(); initSidebar(); initTopbar(); initLocaleDatetime(); -imgLazy(); +loadImg(); diff --git a/_javascript/modules/components/clipboard.js b/_javascript/modules/components/clipboard.js index f4634cf..68f6afd 100644 --- a/_javascript/modules/components/clipboard.js +++ b/_javascript/modules/components/clipboard.js @@ -126,6 +126,5 @@ export function initClipboard() { btnCopyLink.on('mouseleave', function (e) { const target = $(e.target); target.tooltip('hide'); - console.log('mouse leave...'); }); } diff --git a/_javascript/modules/components/img-lazyload.js b/_javascript/modules/components/img-lazyload.js deleted file mode 100644 index 6a6c99a..0000000 --- a/_javascript/modules/components/img-lazyload.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Set up image lazy-load - */ - -function stopShimmer($node) { - $node.parent().removeClass('shimmer'); -} - -export function imgLazy() { - const $images = $('main img[data-src]'); - - if ($images.length <= 0) { - return; - } - - /* Stop shimmer when image loaded */ - document.addEventListener('lazyloaded', function (e) { - stopShimmer($(e.target)); - }); - - /* Stop shimmer from cached images */ - $images.each(function () { - if ($(this).hasClass('ls-is-cached')) { - stopShimmer($(this)); - } - }); -} diff --git a/_javascript/modules/components/img-loading.js b/_javascript/modules/components/img-loading.js new file mode 100644 index 0000000..c9b7b7f --- /dev/null +++ b/_javascript/modules/components/img-loading.js @@ -0,0 +1,61 @@ +/** + * Setting up image lazy loading and LQIP switching + */ + +const ATTR_DATA_SRC = 'data-src'; +const ATTR_DATA_LQIP = 'data-lqip'; + +const cover = { + SHIMMER: 'shimmer', + BLUR: 'blur' +}; + +function removeCover(clzss) { + $(this).parent().removeClass(clzss); +} + +function handleImage() { + if (!this.complete) { + return; + } + + if (this.hasAttribute(ATTR_DATA_LQIP)) { + removeCover.call(this, cover.BLUR); + } else { + removeCover.call(this, cover.SHIMMER); + } +} + +/** + * Switches the LQIP with the real image URL. + */ +function switchLQIP() { + const $img = $(this); + const src = $img.attr(ATTR_DATA_SRC); + + $img.attr('src', encodeURI(src)); + $img.removeAttr(ATTR_DATA_SRC); +} + +export function loadImg() { + const $images = $('article img'); + + if ($images.length) { + $images.on('load', handleImage); + } + + // Images loaded from the browser cache do not trigger the 'load' event + $('article img[loading="lazy"]').each(function () { + if (this.complete) { + removeCover.call(this, cover.SHIMMER); + } + }); + + // LQIPs set by the data URI or WebP will not trigger the 'load' event, + // so manually convert the URI to the URL of a high-resolution image. + const $lqips = $(`article img[${ATTR_DATA_LQIP}="true"]`); + + if ($lqips.length) { + $lqips.each(switchLQIP); + } +} diff --git a/_javascript/modules/plugins.js b/_javascript/modules/plugins.js index fa7a7dd..fb892e2 100644 --- a/_javascript/modules/plugins.js +++ b/_javascript/modules/plugins.js @@ -1,6 +1,6 @@ export { categoryCollapse } from './components/category-collapse'; export { initClipboard } from './components/clipboard'; -export { imgLazy } from './components/img-lazyload'; +export { loadImg } from './components/img-loading'; export { imgPopup } from './components/img-popup'; export { initLocaleDatetime } from './components/locale-datetime'; export { toc } from './components/toc'; diff --git a/_javascript/page.js b/_javascript/page.js index 7b31813..f13bd2f 100644 --- a/_javascript/page.js +++ b/_javascript/page.js @@ -1,9 +1,9 @@ import { basic, initSidebar, initTopbar } from './modules/layouts'; -import { imgLazy, imgPopup, initClipboard } from './modules/plugins'; +import { loadImg, imgPopup, initClipboard } from './modules/plugins'; basic(); initSidebar(); initTopbar(); -imgLazy(); +loadImg(); imgPopup(); initClipboard(); diff --git a/_javascript/post.js b/_javascript/post.js index 9a5a61b..86ea32b 100644 --- a/_javascript/post.js +++ b/_javascript/post.js @@ -1,17 +1,17 @@ import { basic, initSidebar, initTopbar } from './modules/layouts'; import { - imgLazy, + loadImg, imgPopup, initLocaleDatetime, initClipboard, toc } from './modules/plugins'; -basic(); initSidebar(); initTopbar(); -imgLazy(); +loadImg(); imgPopup(); initLocaleDatetime(); initClipboard(); toc(); +basic(); diff --git a/_layouts/default.html b/_layouts/default.html index 16f52c2..f938a94 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -1,6 +1,5 @@ --- layout: compress -# Default layout --- @@ -9,14 +8,8 @@ layout: compress {% include lang.html %} -{% capture prefer_mode %} - {% if site.theme_mode %} - data-mode="{{ site.theme_mode }}" - {% endif %} -{% endcapture %} - -{% if layout.tail_includes %} - {% assign has_tail = true %} +{% if site.theme_mode %} + {% capture prefer_mode %}data-mode="{{ site.theme_mode }}"{% endcapture %} {% endif %} @@ -27,19 +20,20 @@ layout: compress {% include sidebar.html lang=lang %}
-
+
{% include topbar.html lang=lang %} -
-
- {{ content }} +
+
+ {% if layout.refactor or layout.layout == 'default' %} + {% include refactor-content.html content=content lang=lang %} + {% else %} + {{ content }} + {% endif %}
-