From ff12531dde0feeffcb756b4a634acf9c4e49529b Mon Sep 17 00:00:00 2001 From: Sun Tao Date: Fri, 12 Jul 2024 14:58:43 +0800 Subject: [PATCH] :arrow_up: upgrade to v7.0.1 --- .github/DISCUSSION_TEMPLATE/general.yml | 26 --- .github/DISCUSSION_TEMPLATE/q-a.yml | 40 ---- .github/ISSUE_TEMPLATE/bug_report.yml | 64 ----- .github/ISSUE_TEMPLATE/feature_request.yml | 38 --- .github/codeql/codeql-config.yml | 2 - .github/workflows/ci.yml | 45 ---- .github/workflows/codeql.yml | 43 ---- .github/workflows/pages-deploy.yml | 4 +- .github/workflows/stale.yml | 32 --- .github/workflows/style-lint.yml | 25 -- .gitignore | 6 + .markdownlint.json | 8 + .vscode/extensions.json | 3 +- .vscode/settings.json | 3 + Gemfile | 16 +- README.md | 14 +- _config.yml | 47 +++- _data/media.yml | 18 ++ _data/origin/basic.yml | 13 +- _data/origin/cors.yml | 57 +++-- _data/share.yml | 2 +- _includes/analytics/cloudflare.html | 7 + _includes/analytics/goatcounter.html | 6 + _includes/analytics/google.html | 13 ++ _includes/analytics/matomo.html | 14 ++ _includes/analytics/umami.html | 6 + _includes/comments.html | 6 +- _includes/comments/disqus.html | 10 +- _includes/comments/giscus.html | 6 +- _includes/comments/utterances.html | 9 +- _includes/embed/audio.html | 35 +++ _includes/embed/bilibili.html | 7 +- _includes/embed/video.html | 59 +++++ _includes/embed/youtube.html | 2 +- _includes/footer.html | 9 +- _includes/goatcounter.html | 8 - _includes/google-analytics.html | 14 -- _includes/head.html | 176 ++++++-------- _includes/js-selector.html | 68 +++--- _includes/lang.html | 4 +- _includes/{img-url.html => media-url.html} | 16 +- _includes/mermaid.html | 58 ++--- _includes/mode-toggle.html | 75 ++---- _includes/pageviews/goatcounter.html | 19 ++ _includes/post-description.html | 16 ++ _includes/refactor-content.html | 2 +- _includes/related-posts.html | 6 +- _includes/search-loader.html | 2 +- _includes/search-results.html | 2 +- _includes/sidebar.html | 4 +- _includes/toc.html | 4 +- _includes/topbar.html | 2 +- _javascript/commons.js | 2 +- _javascript/home.js | 6 +- _javascript/misc.js | 2 +- _javascript/modules/components/back-to-top.js | 15 +- .../modules/components/category-collapse.js | 52 ++--- _javascript/modules/components/clipboard.js | 141 ++++++----- _javascript/modules/components/img-loading.js | 36 +-- _javascript/modules/components/img-popup.js | 17 +- .../modules/components/locale-datetime.js | 42 ++-- .../modules/components/mode-watcher.js | 15 +- .../modules/components/search-display.js | 130 +++++------ _javascript/modules/components/sidebar.js | 12 +- _javascript/modules/components/toc.js | 2 + .../modules/components/tooltip-loader.js | 7 +- _javascript/page.js | 6 +- _javascript/post.js | 6 +- _javascript/pwa/_frontmatter | 3 + {assets/js => _javascript}/pwa/app.js | 29 ++- {assets/js => _javascript}/pwa/sw.js | 33 +-- _layouts/compress.html | 4 +- _layouts/default.html | 11 +- _layouts/home.html | 7 +- _layouts/post.html | 21 +- _sass/addon/commons.scss | 84 +++---- _sass/colors/typography-dark.scss | 4 - _sass/dist/bootstrap.css | 5 + _sass/layout/post.scss | 33 ++- _sass/main.bundle.scss | 2 + assets/css/jekyll-theme-chirpy.scss | 6 +- assets/feed.xml | 9 +- assets/js/data/mathjax.js | 25 ++ assets/js/data/swconf.js | 14 -- assets/js/dist/app.min.js | 4 + assets/js/dist/categories.min.js | 4 +- assets/js/dist/commons.min.js | 4 +- assets/js/dist/home.min.js | 4 +- assets/js/dist/misc.min.js | 4 +- assets/js/dist/page.min.js | 4 +- assets/js/dist/post.min.js | 4 +- assets/js/dist/sw.min.js | 5 + docs/CHANGELOG.md | 55 ++++- docs/SECURITY.md | 8 +- jekyll-theme-chirpy.gemspec | 2 +- package.json | 135 ++++++++--- purgecss.config.js | 23 ++ rollup.config.js | 48 +++- tools/init | 141 ----------- tools/release | 220 ------------------ tools/run | 5 - tools/test | 89 ------- 102 files changed, 1122 insertions(+), 1589 deletions(-) delete mode 100644 .github/DISCUSSION_TEMPLATE/general.yml delete mode 100644 .github/DISCUSSION_TEMPLATE/q-a.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml delete mode 100644 .github/codeql/codeql-config.yml delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/stale.yml delete mode 100644 .github/workflows/style-lint.yml create mode 100644 .markdownlint.json create mode 100644 _data/media.yml create mode 100644 _includes/analytics/cloudflare.html create mode 100644 _includes/analytics/goatcounter.html create mode 100644 _includes/analytics/google.html create mode 100644 _includes/analytics/matomo.html create mode 100644 _includes/analytics/umami.html create mode 100644 _includes/embed/audio.html create mode 100644 _includes/embed/video.html delete mode 100644 _includes/goatcounter.html delete mode 100644 _includes/google-analytics.html rename _includes/{img-url.html => media-url.html} (59%) create mode 100644 _includes/pageviews/goatcounter.html create mode 100644 _includes/post-description.html create mode 100644 _javascript/pwa/_frontmatter rename {assets/js => _javascript}/pwa/app.js (60%) rename {assets/js => _javascript}/pwa/sw.js (71%) create mode 100644 _sass/dist/bootstrap.css create mode 100644 _sass/main.bundle.scss create mode 100644 assets/js/data/mathjax.js create mode 100644 assets/js/dist/app.min.js create mode 100644 assets/js/dist/sw.min.js create mode 100644 purgecss.config.js delete mode 100755 tools/init delete mode 100755 tools/release delete mode 100755 tools/run delete mode 100755 tools/test diff --git a/.github/DISCUSSION_TEMPLATE/general.yml b/.github/DISCUSSION_TEMPLATE/general.yml deleted file mode 100644 index 4e879f95049..00000000000 --- a/.github/DISCUSSION_TEMPLATE/general.yml +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index a2e2aa150c0..00000000000 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ /dev/null @@ -1,40 +0,0 @@ -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.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 7b513fb5841..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,64 +0,0 @@ -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.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index 79570359f17..00000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,38 +0,0 @@ -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/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml deleted file mode 100644 index 1439beb5c5e..00000000000 --- a/.github/codeql/codeql-config.yml +++ /dev/null @@ -1,2 +0,0 @@ -paths-ignore: - - "assets/js" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index c7b1f5a692a..00000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: "CI" -on: - push: - branches-ignore: - - "production" - - "docs" - paths-ignore: - - ".github/**" - - "!.github/workflows/ci.yml" - - ".gitignore" - - "docs/**" - - "README.md" - - "LICENSE" - pull_request: - paths: - - "**" - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - ruby: ["3.0", "3.1", "3.2"] - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # for posts's lastmod - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - - name: Setup Node - uses: actions/setup-node@v4 - - - name: Build Assets - run: npm i && npm run build - - - name: Test Site - run: bash tools/test diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index b09590d4830..00000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: "CodeQL" - -on: - push: - paths: ["_javascript/**/*.js"] - pull_request: - paths: ["_javascript/**/*.js"] - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: ["javascript"] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: "${{ matrix.language }}" - config-file: .github/codeql/codeql-config.yml - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/pages-deploy.yml b/.github/workflows/pages-deploy.yml index c33b2a6b889..cc28f99fd25 100644 --- a/.github/workflows/pages-deploy.yml +++ b/.github/workflows/pages-deploy.yml @@ -42,7 +42,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2 + ruby-version: 3.3 bundler-cache: true - name: Build site @@ -53,7 +53,7 @@ jobs: - name: Test site run: | bundle exec htmlproofer _site \ - \-\-disable-external=true \ + \-\-disable-external \ \-\-ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/" - name: Upload site artifact diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index bcf425ae604..00000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: "Close stale issues and PRs" - -on: - schedule: - - cron: "0 0 * * *" # every day at 00:00 UTC - -permissions: - issues: write - pull-requests: write - -env: - STALE_LABEL: stale - EXEMPT_LABELS: "pending,planning,in progress" - MESSAGE: > - This conversation has been automatically marked as stale because it has not had recent activity. - It will be closed if no further activity occurs. - Thank you for your contributions. - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - # 60 days before marking issues/PRs stale - days-before-close: -1 # does not close automatically - stale-issue-label: ${{ env.STALE_LABEL }} - exempt-issue-labels: ${{ env.EXEMPT_LABELS }} - stale-issue-message: ${{ env.MESSAGE }} - stale-pr-label: ${{ env.STALE_LABEL }} - exempt-pr-labels: ${{ env.EXEMPT_LABELS }} - stale-pr-message: ${{ env.MESSAGE }} diff --git a/.github/workflows/style-lint.yml b/.github/workflows/style-lint.yml deleted file mode 100644 index f7aa54db344..00000000000 --- a/.github/workflows/style-lint.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "Style Lint" - -on: - push: - branches-ignore: - - "production" - - "docs" - paths: - - "_sass/**/*.scss" - pull_request: - paths: - - "_sass/**/*.scss" - -jobs: - stylelint: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - - run: npm i - - run: npm test diff --git a/.gitignore b/.gitignore index 859686b2ef3..d6bf5096400 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ Gemfile.lock # Jekyll cache .jekyll-cache +.jekyll-metadata _site # RubyGems @@ -16,5 +17,10 @@ package-lock.json # IDE configurations .idea +.vscode +!.vscode/settings.json +!.vscode/extensions.json # Misc +_sass/dist +assets/js/dist diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000000..831991edaef --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,8 @@ +{ + "commands-show-output": false, + "blanks-around-fences": false, + "line-length": false, + "no-inline-html": { + "allowed_elements": ["kbd", "sub"] + } +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 6927cd1106d..52bd6fbd046 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -7,6 +7,7 @@ // Common formatter "esbenp.prettier-vscode", "foxundermoon.shell-format", - "stylelint.vscode-stylelint" + "stylelint.vscode-stylelint", + "yzhang.markdown-all-in-one" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 4fcded4583b..b0e2e099dc0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,9 @@ "files.associations": { "*.html": "liquid" }, + "[markdown]": { + "editor.defaultFormatter": "yzhang.markdown-all-in-one" + }, // Formatter "[html][liquid]": { "editor.defaultFormatter": "Shopify.theme-check-vscode" diff --git a/Gemfile b/Gemfile index 043b28eec7a..672e9e4b6a5 100644 --- a/Gemfile +++ b/Gemfile @@ -5,19 +5,5 @@ source "https://rubygems.org" gemspec group :test do - gem "html-proofer", "~> 4.4" + gem "html-proofer", "~> 5.0" end - -# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem -# and associated library. -platforms :mingw, :x64_mingw, :mswin, :jruby do - gem "tzinfo", ">= 1", "< 3" - gem "tzinfo-data" -end - -# Performance-booster for watching directories on Windows -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] diff --git a/README.md b/README.md index 0e074cf8fc6..747b8bc1dd3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ +
+ # Chirpy Jekyll Theme A minimal, responsive, and feature-rich Jekyll theme for technical writing. @@ -18,7 +20,7 @@ ## Features -- Dark / Light Theme Mode +- Dark Theme - Localized UI language - Pinned Posts on Home Page - Hierarchical Categories @@ -28,13 +30,13 @@ - Syntax Highlighting - Mathematical Expressions - Mermaid Diagrams & Flowcharts -- Dark / Light Mode Images -- Embed Videos -- Disqus / Giscus / Utterances Comments +- Dark Mode Images +- Embed Media +- Comment Systems - Built-in Search - Atom Feeds - PWA -- Google Analytics / GoatCounter +- Web Analytics - SEO & Performance Optimization ## Documentation @@ -54,7 +56,7 @@ For details, see the "[Contributing Guidelines][contribute-guide]". Thanks to [all the contributors][contributors] involved in the development of the project! [![all-contributors](https://contrib.rocks/image?repo=cotes2020/jekyll-theme-chirpy&columns=16)][contributors] - —— Made with [contrib.rocks](https://contrib.rocks) + — Made with [contrib.rocks](https://contrib.rocks) ### Third-Party Assets diff --git a/_config.yml b/_config.yml index 20ad49f255e..966a2094aea 100644 --- a/_config.yml +++ b/_config.yml @@ -45,16 +45,36 @@ social: # - https://www.facebook.com/username # - https://www.linkedin.com/in/username -google_site_verification: # fill in to your verification string +# Site Verification Settings +webmaster_verifications: + google: # fill in your Google verification code + bing: # fill in your Bing verification code + alexa: # fill in your Alexa verification code + yandex: # fill in your Yandex verification code + baidu: # fill in your Baidu verification code + facebook: # fill in your Facebook verification code # ↑ -------------------------- # The end of `jekyll-seo-tag` settings -google_analytics: - id: # fill in your Google Analytics ID - -goatcounter: - id: # fill in your Goatcounter ID +# Web Analytics Settings +analytics: + google: + id: # fill in your Google Analytics ID + goatcounter: + id: # fill in your GoatCounter ID + umami: + id: # fill in your Umami ID + domain: # fill in your Umami domain + matomo: + id: # fill in your Matomo ID + domain: # fill in your Matomo domain + cloudflare: + id: # fill in your Cloudflare Web Analytics token + +# Pageviews settings +pageviews: + provider: # now only supports 'goatcounter' # Prefer color scheme setting. # @@ -69,12 +89,12 @@ goatcounter: # theme_mode: # [light | dark] -# The CDN endpoint for images. +# The CDN endpoint for media resources. # Notice that once it is assigned, the CDN url -# will be added to all image (site avatar & posts' images) paths starting with '/' +# will be added to all media resources (site avatar, posts' images, audio and video files) paths starting with '/' # # e.g. 'https://cdn.com' -img_cdn: +cdn: "" # the avatar on sidebar, support local or CORS resources avatar: "/assets/img/bio-photo.jpg" @@ -87,8 +107,9 @@ social_preview_image: # string, local or CORS resources toc: true comments: - active: giscus # The global switch for posts comments, e.g., 'disqus'. Keep it empty means disable - # The active options are as follows: + # Global switch for the post comment system. Keeping it empty means disabled. + provider: giscus # [disqus | utterances | giscus] + # The provider options are as follows: disqus: shortname: # fill with the Disqus shortname. › https://help.disqus.com/en/articles/1717111-what-s-a-shortname # utterances settings › https://utteranc.es/ @@ -102,6 +123,7 @@ comments: category: "Announcements" category_id: "DIC_kwDOKAq6oM4CYL-h" mapping: # optional, default to 'pathname' + strict: # optional, default to '0' input_position: # optional, default to 'bottom' lang: # optional, default to the value of `site.lang` reactions_enabled: # optional, default to the value of `1` @@ -132,6 +154,7 @@ baseurl: "" # ------------ The following options are not recommended to be modified ------------------ kramdown: + footnote_backlink: "↩︎" syntax_highlighter: rouge syntax_highlighter_opts: # Rouge Options › https://github.com/jneen/rouge#full-options css_class: highlight @@ -192,7 +215,7 @@ exclude: - tools - README.md - LICENSE - - rollup.config.js + - "*.config.js" - package*.json jekyll-archives: diff --git a/_data/media.yml b/_data/media.yml new file mode 100644 index 00000000000..9cd69b4ce95 --- /dev/null +++ b/_data/media.yml @@ -0,0 +1,18 @@ +- extension: mp3 + mime_type: mpeg +- extension: mov + mime_type: quicktime +- extension: avi + mime_type: x-msvideo +- extension: mkv + mime_type: x-matroska +- extension: ogv + mime_type: ogg +- extension: weba + mime_type: webm +- extension: 3gp + mime_type: 3gpp +- extension: 3g2 + mime_type: 3gpp2 +- extension: mid + mime_type: midi diff --git a/_data/origin/basic.yml b/_data/origin/basic.yml index ed99ea850a6..9027e6e4e82 100644 --- a/_data/origin/basic.yml +++ b/_data/origin/basic.yml @@ -4,13 +4,6 @@ webfonts: /assets/lib/fonts/main.css # Libraries -jquery: - js: /assets/lib/jquery/jquery.min.js - -bootstrap: - css: /assets/lib/bootstrap/bootstrap.min.css - js: /assets/lib/bootstrap/bootstrap.bundle.min.js - toc: css: /assets/lib/tocbot/tocbot.min.css js: /assets/lib/tocbot/tocbot.min.js @@ -31,9 +24,9 @@ dayjs: relativeTime: /assets/lib/dayjs/plugin/relativeTime.min.js localizedFormat: /assets/lib/dayjs/plugin/localizedFormat.min.js -magnific-popup: - css: /assets/lib/magnific-popup/magnific-popup.css - js: /assets/lib/magnific-popup/jquery.magnific-popup.min.js +glightbox: + css: /assets/lib/glightbox/glightbox.min.css + js: /assets/lib/glightbox/glightbox.min.js lazy-polyfill: css: /assets/lib/loading-attribute-polyfill/loading-attribute-polyfill.min.css diff --git a/_data/origin/cors.yml b/_data/origin/cors.yml index b6c8674205f..18806665698 100644 --- a/_data/origin/cors.yml +++ b/_data/origin/cors.yml @@ -1,52 +1,47 @@ -# CDNs - -cdns: - # Google Fonts +# Resource Hints +resource_hints: - url: https://fonts.googleapis.com + links: + - rel: preconnect + - rel: dns-prefetch - url: https://fonts.gstatic.com - args: crossorigin - - url: https://fonts.googleapis.com - # jsDelivr CDN + links: + - rel: preconnect + opts: [crossorigin] + - rel: dns-prefetch - url: https://cdn.jsdelivr.net - # polyfill.io for math (cdnjs.cloudflare.com/polyfill) - - url: https://cdnjs.cloudflare.com - -# fonts + links: + - rel: preconnect + - rel: dns-prefetch -webfonts: https://fonts.googleapis.com/css2?family=Lato&family=Source+Sans+Pro:wght@400;600;700;900&display=swap +# Web Fonts +webfonts: https://fonts.googleapis.com/css2?family=Lato:wght@300;400&family=Source+Sans+Pro:wght@400;600;700;900&display=swap # Libraries -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.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.25.0/dist/tocbot.min.css - js: https://cdn.jsdelivr.net/npm/tocbot@4.25.0/dist/tocbot.min.js + css: https://cdn.jsdelivr.net/npm/tocbot@4.27.20/dist/tocbot.min.css + js: https://cdn.jsdelivr.net/npm/tocbot@4.27.20/dist/tocbot.min.js fontawesome: - css: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/css/all.min.css + css: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.2/css/all.min.css 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.8.0/dist/mermaid.min.js + js: https://cdn.jsdelivr.net/npm/mermaid@10.9.0/dist/mermaid.min.js dayjs: 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 + common: https://cdn.jsdelivr.net/npm/dayjs@1.11.11/dayjs.min.js + locale: https://cdn.jsdelivr.net/npm/dayjs@1.11.11/locale/:LOCALE.min.js + relativeTime: https://cdn.jsdelivr.net/npm/dayjs@1.11.11/plugin/relativeTime.min.js + localizedFormat: https://cdn.jsdelivr.net/npm/dayjs@1.11.11/plugin/localizedFormat.min.js + +glightbox: + css: https://cdn.jsdelivr.net/npm/glightbox@3.3.0/dist/css/glightbox.min.css + js: https://cdn.jsdelivr.net/npm/glightbox@3.3.0/dist/js/glightbox.min.js lazy-polyfill: css: https://cdn.jsdelivr.net/npm/loading-attribute-polyfill@2.1.1/dist/loading-attribute-polyfill.min.css diff --git a/_data/share.yml b/_data/share.yml index d572e6dcb39..b1d077dcaaa 100644 --- a/_data/share.yml +++ b/_data/share.yml @@ -22,7 +22,7 @@ platforms: # # - type: Weibo # icon: "fab fa-weibo" - # link: "http://service.weibo.com/share/share.php?title=TITLE&url=URL" + # link: "https://service.weibo.com/share/share.php?title=TITLE&url=URL" # # - type: Mastodon # icon: "fa-brands fa-mastodon" diff --git a/_includes/analytics/cloudflare.html b/_includes/analytics/cloudflare.html new file mode 100644 index 00000000000..1eeb1a924ff --- /dev/null +++ b/_includes/analytics/cloudflare.html @@ -0,0 +1,7 @@ + + + diff --git a/_includes/analytics/goatcounter.html b/_includes/analytics/goatcounter.html new file mode 100644 index 00000000000..3867fdba95b --- /dev/null +++ b/_includes/analytics/goatcounter.html @@ -0,0 +1,6 @@ + + diff --git a/_includes/analytics/google.html b/_includes/analytics/google.html new file mode 100644 index 00000000000..d0aac651c22 --- /dev/null +++ b/_includes/analytics/google.html @@ -0,0 +1,13 @@ + + + diff --git a/_includes/analytics/matomo.html b/_includes/analytics/matomo.html new file mode 100644 index 00000000000..72b2c463cfa --- /dev/null +++ b/_includes/analytics/matomo.html @@ -0,0 +1,14 @@ + + + diff --git a/_includes/analytics/umami.html b/_includes/analytics/umami.html new file mode 100644 index 00000000000..bfcb1d09ff6 --- /dev/null +++ b/_includes/analytics/umami.html @@ -0,0 +1,6 @@ + + diff --git a/_includes/comments.html b/_includes/comments.html index 39e521facbb..fef135f0b2f 100644 --- a/_includes/comments.html +++ b/_includes/comments.html @@ -1,5 +1,5 @@ - -{% if page.comments and site.comments.active %} - {% capture path %}comments/{{ site.comments.active }}.html{% endcapture %} + +{% if page.comments and site.comments.provider %} + {% capture path %}comments/{{ site.comments.provider }}.html{% endcapture %} {% include {{ path }} %} {% endif %} diff --git a/_includes/comments/disqus.html b/_includes/comments/disqus.html index e59ed37dd2b..2b889a4e051 100644 --- a/_includes/comments/disqus.html +++ b/_includes/comments/disqus.html @@ -10,7 +10,7 @@ this.page.identifier = '{{ page.url }}'; }; - /* Lazy loading */ + {%- comment -%} Lazy loading {%- endcomment -%} var disqus_observer = new IntersectionObserver( function (entries) { if (entries[0].isIntersecting) { @@ -28,12 +28,12 @@ { threshold: [0] } ); - disqus_observer.observe(document.querySelector('#disqus_thread')); + disqus_observer.observe(document.getElementById('disqus_thread')); - /* Auto switch theme */ + {%- comment -%} Auto switch theme {%- endcomment -%} function reloadDisqus() { if (event.source === window && event.data && event.data.direction === ModeToggle.ID) { - /* Disqus hasn't been loaded */ + {%- comment -%} Disqus hasn't been loaded {%- endcomment -%} if (typeof DISQUS === 'undefined') { return; } @@ -44,7 +44,7 @@ } } - if (document.querySelector('.mode-toggle')) { + if (document.getElementById('mode-toggle')) { window.addEventListener('message', reloadDisqus); } diff --git a/_includes/comments/giscus.html b/_includes/comments/giscus.html index 8f042468e62..c8d48e67d41 100644 --- a/_includes/comments/giscus.html +++ b/_includes/comments/giscus.html @@ -2,7 +2,6 @@ - diff --git a/_includes/google-analytics.html b/_includes/google-analytics.html deleted file mode 100644 index e5e5119e555..00000000000 --- a/_includes/google-analytics.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/_includes/head.html b/_includes/head.html index f3137151d3c..ec443d03c74 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -1,123 +1,88 @@ - - - - - + + + + + {%- capture seo_tags -%} - {% seo title=false %} + {% seo title=false %} {%- endcapture -%} {% if page.image %} - {% assign src = page.image.path | default: page.image %} + {% assign src = page.image.path | default: page.image %} - {% unless src contains '://' %} - {%- capture img_url -%} - {% include img-url.html src=src img_path=page.img_path absolute=true %} - {%- endcapture -%} + {% unless src contains '://' %} + {%- capture img_url -%} + {% include media-url.html src=src subpath=page.media_subpath absolute=true %} + {%- endcapture -%} - {%- capture old_url -%}{{ src | absolute_url }}{%- endcapture -%} - {%- capture new_url -%}{{ img_url }}{%- endcapture -%} + {%- capture old_url -%}{{ src | absolute_url }}{%- endcapture -%} + {%- capture new_url -%}{{ img_url }}{%- endcapture -%} - {% assign seo_tags = seo_tags | replace: old_url, new_url %} - {% endunless %} + {% assign seo_tags = seo_tags | replace: old_url, new_url %} + {% endunless %} {% elsif site.social_preview_image %} - {%- capture img_url -%} - {% include img-url.html src=site.social_preview_image absolute=true %} - {%- endcapture -%} - - {%- capture og_image -%} - - {%- endcapture -%} - - {%- capture twitter_image -%} - - - {%- endcapture -%} - - {% assign old_meta_clip = '' %} - {% assign new_meta_clip = og_image | append: twitter_image %} - {% assign seo_tags = seo_tags | replace: old_meta_clip, new_meta_clip %} + {%- capture img_url -%} + {% include media-url.html src=site.social_preview_image absolute=true %} + {%- endcapture -%} + + {%- capture og_image -%} + + {%- endcapture -%} + + {%- capture twitter_image -%} + + + {%- endcapture -%} + + {% assign old_meta_clip = '' %} + {% assign new_meta_clip = og_image | append: twitter_image %} + {% assign seo_tags = seo_tags | replace: old_meta_clip, new_meta_clip %} {% endif %} {{ seo_tags }} - {%- unless page.layout == 'home' -%} {{ page.title | append: ' | ' }} {%- - endunless -%} {{ site.title }} + {%- unless page.layout == 'home' -%} + {{ page.title | append: ' | ' }} + {%- endunless -%} + {{ site.title }} - {% include_cached favicons.html %} {% if site.resources.ignore_env != - jekyll.environment and site.resources.self_hosted %} - + {% include_cached favicons.html %} - {% else %} {% for cdn in site.data.origin[type].cdns %} - - + + {% unless site.assets.self_host.enabled %} + {% for hint in site.data.origin.cors.resource_hints %} + {% for link in hint.links %} + {% endfor %} + {% endfor %} + {% endunless %} - - {% endif %} - - - {% if jekyll.environment == 'production' and site.google_analytics.id != empty - and site.google_analytics.id %} - - + + {% unless jekyll.environment == 'production' %} + + {% endunless %} - - - {% endif %} + + - - + + - - + + - + {% if site.toc and page.toc %} - - {% endif %} {% if page.layout == 'post' or page.layout == 'page' or - page.layout == 'home' %} - - {% endif %} {% if page.layout == 'page' or page.layout == 'post' %} - - + + {% endif %} + + {% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %} + + {% endif %} + + {% if page.layout == 'page' or page.layout == 'post' %} + + {% endif %} - {% unless site.theme_mode %} {% include mode-toggle.html %} {% endunless %} {% - include metadata-hook.html %} + {% unless site.theme_mode %} + {% include mode-toggle.html %} + {% endunless %} + + {% include metadata-hook.html %} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 1fd408a6938..b229b70d738 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -2,12 +2,7 @@ -{% assign urls = site.data.origin[type].jquery.js - | append: ',' - | append: site.data.origin[type].bootstrap.js - | append: ',' - | append: site.data.origin[type].search.js -%} +{% assign urls = site.data.origin[type].search.js %} @@ -20,7 +15,7 @@ {% assign urls = urls | append: ',' - | append: site.data.origin[type]['magnific-popup'].js + | append: site.data.origin[type].glightbox.js | append: ',' | append: site.data.origin[type].clipboard.js %} @@ -33,7 +28,7 @@ or page.layout == 'category' or page.layout == 'tag' %} - {% assign locale = site.lang | split: '-' | first %} + {% assign locale = include.lang | split: '-' | first %} {% assign urls = urls | append: ',' @@ -68,46 +63,45 @@ {% endcase %} {% capture script %}{{ js_dist }}{{ js }}.min.js{% endcapture %} - + {% if page.math %} - + {% endif %} + +{% if page.layout == 'post' %} + {% assign provider = site.pageviews.provider %} + + {% if provider and provider != empty %} + {% case provider %} + {% when 'goatcounter' %} + {% if site.analytics[provider].id != empty and site.analytics[provider].id %} + {% include pageviews/{{ provider }}.html %} + {% endif %} + {% endcase %} + {% endif %} +{% endif %} + +{% if page.mermaid %} + {% include mermaid.html %} +{% endif %} + {% if jekyll.environment == 'production' %} {% if site.pwa.enabled %} {% endif %} - - {% if site.google_analytics.id != empty and site.google_analytics.id %} - {% include google-analytics.html %} - {% endif %} - - - {% if site.goatcounter.id != empty and site.goatcounter.id %} - {% include goatcounter.html %} - {% endif %} + + {% for analytics in site.analytics %} + {% capture str %}{{ analytics }}{% endcapture %} + {% assign type = str | split: '{' | first %} + {% if site.analytics[type].id and site.analytics[type].id != empty %} + {% include analytics/{{ type }}.html %} + {% endif %} + {% endfor %} {% endif %} diff --git a/_includes/lang.html b/_includes/lang.html index 19558a074cd..34b50dfaab8 100644 --- a/_includes/lang.html +++ b/_includes/lang.html @@ -1,7 +1,9 @@ {% comment %} Detect appearance language and return it through variable "lang" {% endcomment %} -{% if site.data.locales[site.lang] %} +{% if site.data.locales[page.lang] %} + {% assign lang = page.lang %} +{% elsif site.data.locales[site.lang] %} {% assign lang = site.lang %} {% else %} {% assign lang = 'en' %} diff --git a/_includes/img-url.html b/_includes/media-url.html similarity index 59% rename from _includes/img-url.html rename to _includes/media-url.html index bb4758c72d3..ea410750268 100644 --- a/_includes/img-url.html +++ b/_includes/media-url.html @@ -1,25 +1,25 @@ {%- comment -%} - Generate image final URL based on `site.img_cdn`, `page.img_path` + Generate media resource final URL based on `site.cdn`, `page.media_subpath` Arguments: - src - required, basic image path - img_path - optional, relative path of image + src - required, basic media resources path + subpath - optional, relative path of media resources absolute - optional, boolean, if true, generate absolute URL Return: - image URL + media resources URL {%- endcomment -%} {% assign url = include.src %} {%- if url -%} {% unless url contains ':' %} - {%- comment -%} Add page image path prefix {%- endcomment -%} - {% assign url = include.img_path | default: '' | append: '/' | append: url %} + {%- comment -%} Add media resources subpath prefix {%- endcomment -%} + {% assign url = include.subpath | default: '' | append: '/' | append: url %} {%- comment -%} Prepend CND URL {%- endcomment -%} - {% if site.img_cdn %} - {% assign url = site.img_cdn | append: '/' | append: url %} + {% if site.cdn %} + {% assign url = site.cdn | append: '/' | append: url %} {% endif %} {% assign url = url | replace: '///', '/' | replace: '//', '/' | replace: ':/', '://' %} diff --git a/_includes/mermaid.html b/_includes/mermaid.html index 967cfb431a3..a3a83edbdc4 100644 --- a/_includes/mermaid.html +++ b/_includes/mermaid.html @@ -1,29 +1,33 @@ diff --git a/_includes/mode-toggle.html b/_includes/mode-toggle.html index a347750f8b1..113ec375467 100644 --- a/_includes/mode-toggle.html +++ b/_includes/mode-toggle.html @@ -19,45 +19,32 @@ } constructor() { - if (this.hasMode) { - if (this.isDarkMode) { - if (!this.isSysDarkPrefer) { - this.setDark(); - } - } else { - if (this.isSysDarkPrefer) { - this.setLight(); - } - } - } - let self = this; - /* always follow the system prefers */ + {%- comment -%} always follow the system prefers {%- endcomment -%} this.sysDarkPrefers.addEventListener('change', () => { if (self.hasMode) { - if (self.isDarkMode) { - if (!self.isSysDarkPrefer) { - self.setDark(); - } - } else { - if (self.isSysDarkPrefer) { - self.setLight(); - } - } - self.clearMode(); } - self.notify(); }); - } /* constructor() */ + + if (!this.hasMode) { + return; + } + + if (this.isDarkMode) { + this.setDark(); + } else { + this.setLight(); + } + } get sysDarkPrefers() { return window.matchMedia('(prefers-color-scheme: dark)'); } - get isSysDarkPrefer() { + get isPreferDark() { return this.sysDarkPrefers.matches; } @@ -65,10 +52,6 @@ return this.mode === ModeToggle.DARK_MODE; } - get isLightMode() { - return this.mode === ModeToggle.LIGHT_MODE; - } - get hasMode() { return this.mode != null; } @@ -77,12 +60,12 @@ return sessionStorage.getItem(ModeToggle.MODE_KEY); } - /* get the current mode on screen */ + {%- comment -%} get the current mode on screen {%- endcomment -%} get modeStatus() { - if (this.isDarkMode || (!this.hasMode && this.isSysDarkPrefer)) { - return ModeToggle.DARK_MODE; + if (this.hasMode) { + return this.mode; } else { - return ModeToggle.LIGHT_MODE; + return this.isPreferDark ? ModeToggle.DARK_MODE : ModeToggle.LIGHT_MODE; } } @@ -101,7 +84,9 @@ sessionStorage.removeItem(ModeToggle.MODE_KEY); } - /* Notify another plugins that the theme mode has changed */ + {%- comment -%} + Notify another plugins that the theme mode has changed + {%- endcomment -%} notify() { window.postMessage( { @@ -114,21 +99,9 @@ flipMode() { if (this.hasMode) { - if (this.isSysDarkPrefer) { - if (this.isLightMode) { - this.clearMode(); - } else { - this.setLight(); - } - } else { - if (this.isDarkMode) { - this.clearMode(); - } else { - this.setDark(); - } - } + this.clearMode(); } else { - if (this.isSysDarkPrefer) { + if (this.isPreferDark) { this.setLight(); } else { this.setDark(); @@ -136,8 +109,8 @@ } this.notify(); - } /* flipMode() */ - } /* ModeToggle */ + } + } const modeToggle = new ModeToggle(); diff --git a/_includes/pageviews/goatcounter.html b/_includes/pageviews/goatcounter.html new file mode 100644 index 00000000000..e62fd698d9b --- /dev/null +++ b/_includes/pageviews/goatcounter.html @@ -0,0 +1,19 @@ + + diff --git a/_includes/post-description.html b/_includes/post-description.html new file mode 100644 index 00000000000..6c400360bf3 --- /dev/null +++ b/_includes/post-description.html @@ -0,0 +1,16 @@ +{%- comment -%} + Get post description or generate it from the post content. +{%- endcomment -%} + +{%- assign max_length = include.max_length | default: 200 -%} + +{%- capture description -%} +{%- if post.description -%} + {{- post.description -}} +{%- else -%} + {%- include no-linenos.html content=post.content -%} + {{- content | markdownify | strip_html -}} +{%- endif -%} +{%- endcapture -%} + +{{- description | strip | truncate: max_length | escape -}} diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index e4abcbc2a51..8d298cde6c0 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -97,7 +97,7 @@ {% assign _lazyload = true %} {%- capture _img_url -%} - {% include img-url.html src=_src img_path=page.img_path %} + {% include media-url.html src=_src subpath=page.media_subpath %} {%- endcapture -%} {% assign _path_prefix = _img_url | remove: _src %} diff --git a/_includes/related-posts.html b/_includes/related-posts.html index 1ba2f322008..37a295bdc29 100644 --- a/_includes/related-posts.html +++ b/_includes/related-posts.html @@ -21,6 +21,7 @@ {% assign match_posts = match_posts | push: site.tags[tag] | uniq %} {% endfor %} +{% assign match_posts = match_posts | reverse %} {% assign last_index = match_posts.size | minus: 1 %} {% assign score_list = '' | split: '' %} @@ -81,10 +82,7 @@

{{ post.title }}

-

- {% include no-linenos.html content=post.content %} - {{ content | markdownify | strip_html | truncate: 200 | escape }} -

+

{% include post-description.html %}

diff --git a/_includes/search-loader.html b/_includes/search-loader.html index be3ca8a69f5..2582580a91b 100644 --- a/_includes/search-loader.html +++ b/_includes/search-loader.html @@ -19,7 +19,7 @@

{title}

{% capture not_found %}

{{ site.data.locales[include.lang].search.no_results }}

{% endcapture %}