diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..01867e18f Binary files /dev/null and b/.DS_Store differ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..39c428df4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,29 @@ +{ + "name": "Jekyll", + "image": "mcr.microsoft.com/devcontainers/jekyll:2-bullseye", + "onCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}", + "postCreateCommand": "bash .devcontainer/post-create.sh", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "zsh" + }, + "extensions": [ + // Liquid tags auto-complete + "killalau.vscode-liquid-snippets", + // Liquid syntax highlighting and formatting + "Shopify.theme-check-vscode", + // Shell + "timonwong.shellcheck", + "mkhl.shfmt", + // Common formatter + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "stylelint.vscode-stylelint", + "yzhang.markdown-all-in-one", + // Git + "mhutchie.git-graph" + ] + } + } +} diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 000000000..a4bc28257 --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +if [ -f package.json ]; then + bash -i -c "nvm install --lts && nvm install-latest-npm" + npm i + npm run build +fi + +# Install dependencies for shfmt extension +curl -sS https://webi.sh/shfmt | sh &>/dev/null + +# Add OMZ plugins +git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting +git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions +sed -i -E "s/^(plugins=\()(git)(\))/\1\2 zsh-syntax-highlighting zsh-autosuggestions\3/" ~/.zshrc + +# Avoid git log use less +echo -e "\nunset LESS" >>~/.zshrc diff --git a/.editorconfig b/.editorconfig index cdded4641..2b740bfd2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,10 +2,18 @@ root = true [*] charset = utf-8 -# 2 space indentation indent_style = space indent_size = 2 trim_trailing_whitespace = true # Unix-style newlines with a newline ending every file end_of_line = lf insert_final_newline = true + +[*.{js,css,scss}] +quote_type = single + +[*.{yml,yaml}] +quote_type = double + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore index 3a9a8a6ad..7dd7cefd9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,27 @@ -# hidden files -.* -!.git* -!.editorconfig -!.nojekyll -!.travis.yml +# Bundler cache +.bundle +vendor +Gemfile.lock -# bundler cache +# Jekyll cache +.jekyll-cache +.jekyll-metadata _site -vendor -# rubygem +# RubyGems *.gem -# npm dependencies +# NPM dependencies node_modules package-lock.json + +# IDE configurations +.idea +.vscode/* +!.vscode/settings.json +!.vscode/extensions.json +!.vscode/tasks.json + +# Misc +_sass/vendors +assets/js/dist diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 000000000..ff365e06b --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.1.3 diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..082bc94c0 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["ms-vscode-remote.remote-containers"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..5e8a04f39 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,30 @@ +{ + // Prettier + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + // Shopify Liquid + "files.associations": { + "*.html": "liquid" + }, + "[markdown]": { + "editor.defaultFormatter": "yzhang.markdown-all-in-one" + }, + // Formatter + "[html][liquid]": { + "editor.defaultFormatter": "Shopify.theme-check-vscode" + }, + "[shellscript]": { + "editor.defaultFormatter": "mkhl.shfmt" + }, + // Disable vscode built-in stylelint + "css.validate": false, + "scss.validate": false, + "less.validate": false, + // Stylint extension settings + "stylelint.snippet": ["css", "scss"], + "stylelint.validate": ["css", "scss"], + // Run tasks in macOS + "terminal.integrated.profiles.osx": { + "zsh": { "path": "/bin/zsh", "args": ["-l", "-i"] } + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..7f0fdb8ed --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,26 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Run Jekyll Server", + "type": "shell", + "command": "./tools/run.sh", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "detail": "Runs the Jekyll server with live reload." + }, + { + "label": "Build Jekyll Site", + "type": "shell", + "command": "./tools/test.sh", + "group": { + "kind": "build" + }, + "problemMatcher": [], + "detail": "Build the Jekyll site for production." + } + ] +} diff --git a/Gemfile b/Gemfile index 1409a1a97..7835d7d8c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,21 +2,13 @@ source "https://rubygems.org" -gem "jekyll-theme-chirpy", "~> 6.1" +gem "jekyll-theme-chirpy", "~> 7.2", ">= 7.2.4" -group :test do - gem "html-proofer", "~> 3.18" -end +gem "html-proofer", "~> 5.0", group: :test -# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem -# and associated library. -install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do - gem "tzinfo", "~> 1.2" +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", :install_if => Gem.win_platform? - -# Jekyll <= 4.2.0 compatibility with Ruby 3.0 -gem "webrick", "~> 1.7" +gem "wdm", "~> 0.2.0", :platforms => [:mingw, :x64_mingw, :mswin] diff --git a/Gemfile.lock b/Gemfile.lock index bac14444f..cba738fcb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,32 +1,51 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.8.5) - public_suffix (>= 2.0.2, < 6.0) + Ascii85 (2.0.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + afm (0.2.2) + async (2.21.1) + console (~> 1.29) + fiber-annotation + io-event (~> 1.6, >= 1.6.5) + bigdecimal (3.1.9) colorator (1.1.0) - concurrent-ruby (1.2.2) + concurrent-ruby (1.3.4) + console (1.29.2) + fiber-annotation + fiber-local (~> 1.1) + json em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - ethon (0.15.0) + ethon (0.16.0) ffi (>= 1.15.0) eventmachine (1.2.7) - ffi (1.15.5) + ffi (1.17.1-arm64-darwin) + fiber-annotation (0.2.0) + fiber-local (1.1.0) + fiber-storage + fiber-storage (1.0.0) forwardable-extended (2.6.0) - google-protobuf (3.23.4) - google-protobuf (3.23.4-x86_64-linux) - html-proofer (3.19.4) + google-protobuf (4.29.3-arm64-darwin) + bigdecimal + rake (>= 13) + hashery (2.1.2) + html-proofer (5.0.9) addressable (~> 2.3) - mercenary (~> 0.3) + async (~> 2.1) nokogiri (~> 1.13) - parallel (~> 1.10) + pdf-reader (~> 2.11) rainbow (~> 3.0) typhoeus (~> 1.3) yell (~> 2.0) + zeitwerk (~> 2.5) http_parser.rb (0.8.0) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) - jekyll (4.3.2) + io-event (1.7.5) + jekyll (4.3.4) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) @@ -42,7 +61,7 @@ GEM safe_yaml (~> 1.0) terminal-table (>= 1.8, < 4.0) webrick (~> 1.7) - jekyll-archives (2.2.1) + jekyll-archives (2.3.0) jekyll (>= 3.6, < 5.0) jekyll-include-cache (0.2.1) jekyll (>= 3.7, < 5.0) @@ -55,72 +74,69 @@ GEM jekyll (>= 3.8, < 5.0) jekyll-sitemap (1.4.0) jekyll (>= 3.7, < 5.0) - jekyll-theme-chirpy (6.1.0) + jekyll-theme-chirpy (7.2.4) jekyll (~> 4.3) jekyll-archives (~> 2.2) jekyll-include-cache (~> 0.2) jekyll-paginate (~> 1.1) jekyll-redirect-from (~> 0.16) - jekyll-seo-tag (~> 2.7) + jekyll-seo-tag (~> 2.8) jekyll-sitemap (~> 1.4) jekyll-watch (2.2.1) listen (~> 3.0) - kramdown (2.4.0) - rexml + json (2.9.1) + kramdown (2.5.1) + rexml (>= 3.3.9) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) liquid (4.0.4) - listen (3.8.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.4.0) - mini_portile2 (2.8.0) - nokogiri (1.13.6) - mini_portile2 (~> 2.8.0) + nokogiri (1.18.1-arm64-darwin) racc (~> 1.4) - nokogiri (1.13.6-x86_64-linux) - racc (~> 1.4) - parallel (1.22.1) pathutil (0.16.2) forwardable-extended (~> 2.6) - public_suffix (5.0.3) - racc (1.6.0) + pdf-reader (2.13.0) + Ascii85 (>= 1.0, < 3.0, != 2.0.0) + afm (~> 0.2.1) + hashery (~> 2.0) + ruby-rc4 + ttfunk + public_suffix (6.0.1) + racc (1.8.1) rainbow (3.1.1) - rake (13.0.6) + rake (13.2.1) rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) - rexml (3.2.6) - rouge (3.30.0) + rexml (3.4.0) + rouge (4.5.1) + ruby-rc4 (0.1.5) safe_yaml (1.0.5) - sass-embedded (1.58.3) - google-protobuf (~> 3.21) - rake (>= 10.0.0) + sass-embedded (1.83.1-arm64-darwin) + google-protobuf (~> 4.29) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - thread_safe (0.3.6) - typhoeus (1.4.0) + ttfunk (1.8.0) + bigdecimal (~> 3.1) + typhoeus (1.4.1) ethon (>= 0.9.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) - tzinfo-data (1.2022.1) - tzinfo (>= 1.0.0) - unicode-display_width (2.4.2) - wdm (0.1.1) - webrick (1.8.1) + unicode-display_width (2.6.0) + webrick (1.9.1) yell (2.2.2) + zeitwerk (2.6.18) PLATFORMS - ruby - x86_64-linux + arm64-darwin-24 DEPENDENCIES - html-proofer (~> 3.18) - jekyll-theme-chirpy (~> 6.1) - tzinfo (~> 1.2) + html-proofer (~> 5.0) + jekyll-theme-chirpy (~> 7.2, >= 7.2.4) + tzinfo (>= 1, < 3) tzinfo-data - wdm (~> 0.1.1) - webrick (~> 1.7) + wdm (~> 0.2.0) BUNDLED WITH - 2.3.24 + 2.3.26 diff --git a/_config.yml b/_config.yml index 5a614f9ec..abe4413de 100644 --- a/_config.yml +++ b/_config.yml @@ -3,30 +3,26 @@ # 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'. lang: en -# Change to your timezone › http://www.timezoneconverter.com/cgi-bin/findzone/findzone +# Change to your timezone › https://kevinnovak.github.io/Time-Zone-Picker timezone: Asia/Taipei # jekyll-seo-tag settings › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/usage.md # ↓ -------------------------- -title: ZhgChgLi # the main title +title: ZhgChgLi (Harry Li) # the main title -tagline: >- - Live a life you will remember. - +tagline: An iOS, web, and automation developer from Taiwan 🇹🇼 who also loves sharing, traveling, and writing. # it will display as the subtitle description: >- # used by seo meta and the atom feed - ZhgChgLi iOS Developer 求知若渴 教學相長 更愛電影/美劇/西音/運動/生活 -# fill in the protocol & hostname for your site, e.g., 'https://username.github.io' + An iOS, web, and automation developer from Taiwan 🇹🇼 who also loves sharing, traveling, and writing. + +# Fill in the protocol & hostname for your site. +# E.g. 'https://username.github.io', note that it does not end with a '/'. url: "https://zhgchg.li" github: @@ -46,17 +42,38 @@ social: - https://github.com/ZhgChgLi - https://www.linkedin.com/in/zhgchgli -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: G-6WZJENT8WR - # Google Analytics pageviews report settings - pv: - proxy_endpoint: # fill in the Google Analytics superProxy endpoint of Google App Engine - cache_path: # the local PV cache data, friendly to visitors from GFW region +# Web Analytics Settings +analytics: + google: + id: G-6WZJENT8WR + 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 + fathom: + id: # fill in your Fathom Site ID + +# Page views settings +pageviews: + provider: # now only supports 'goatcounter' # Prefer color scheme setting. # @@ -66,27 +83,32 @@ google_analytics: # # Available options: # -# light - Use the light color scheme -# dark - Use the dark color scheme +# light — Use the light color scheme +# dark — Use the dark color scheme # -theme_mode: # [light|dark] +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/images/zhgchgli.jpg" +# The URL of the site-wide social preview image used in SEO `og:image` meta tag. +# It can be overridden by a customized `page.image` in front matter. +social_preview_image: # string, local or CORS resources + # boolean type, the global switch for TOC in posts. 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: disqus # [disqus | utterances | giscus] + # The provider options are as follows: disqus: shortname: zhgchgli # fill with the Disqus shortname. › https://help.disqus.com/en/articles/1717111-what-s-a-shortname # utterances settings › https://utteranc.es/ @@ -100,6 +122,7 @@ comments: category: Q&A category_id: DIC_kwDOHdowL84CU-q6 mapping: url # 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` @@ -110,16 +133,27 @@ assets: enabled: # boolean, keep empty means false # specify the Jekyll environment, empty means both # only works if `assets.self_host.enabled` is 'true' - env: # [development|production] + env: # [development | production] pwa: - enabled: true # the option for PWA feature + enabled: true # The option for PWA feature (installable) + cache: + enabled: true # The option for PWA offline cache + # Paths defined here will be excluded from the PWA cache. + # Usually its value is the `baseurl` of another website that + # shares the same domain name as the current website. + deny_paths: + # - "/example" # URLs match `/example/*` will not be cached by the PWA paginate: 10 +# The base URL of your site +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 @@ -146,6 +180,7 @@ defaults: # DO NOT modify the following parameter unless you are confident enough # to update the code of all other post links in this project. permalink: /posts/:title/ + author: ZhgChgLi - scope: path: _drafts values: @@ -156,14 +191,6 @@ defaults: values: layout: page permalink: /:title/ - - scope: - path: assets/img/favicons - values: - swcache: true - - scope: - path: assets/js/dist - values: - swcache: true sass: style: compressed @@ -180,13 +207,13 @@ compress_html: exclude: - "*.gem" - "*.gemspec" + - docs - tools - README.md - - CHANGELOG.md - LICENSE + - purgecss.js - rollup.config.js - - node_modules - - package*.json + - "package*.json" jekyll-archives: enabled: [categories, tags] diff --git a/_data/.DS_Store b/_data/.DS_Store new file mode 100644 index 000000000..77b9bdf69 Binary files /dev/null and b/_data/.DS_Store differ diff --git a/_data/assets/cross_origin.yml b/_data/assets/cross_origin.yml deleted file mode 100644 index 13e37cf95..000000000 --- a/_data/assets/cross_origin.yml +++ /dev/null @@ -1,62 +0,0 @@ -# CDNs - -cdns: - # Google Fonts - - url: https://fonts.googleapis.com - - url: https://fonts.gstatic.com - args: crossorigin - - url: https://fonts.googleapis.com - # jsDelivr CDN - - url: https://cdn.jsdelivr.net - -# fonts - -webfonts: https://fonts.googleapis.com/css2?family=Lato&family=Source+Sans+Pro:wght@400;600;700;900&display=swap - -# Libraries - -jquery: - js: https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js - -bootstrap: - css: https://cdn.jsdelivr.net/npm/bootstrap@4/dist/css/bootstrap.min.css - js: https://cdn.jsdelivr.net/npm/bootstrap@4/dist/js/bootstrap.bundle.min.js - -bootstrap-toc: - css: https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@1.0.1/dist/bootstrap-toc.min.css - js: https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@1.0.1/dist/bootstrap-toc.min.js - -fontawesome: - css: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.11.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@8/dist/mermaid.min.js - -dayjs: - js: - common: https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js - locale: https://cdn.jsdelivr.net/npm/dayjs@1/locale/:LOCALE.min.js - relativeTime: https://cdn.jsdelivr.net/npm/dayjs@1/plugin/relativeTime.min.js - localizedFormat: https://cdn.jsdelivr.net/npm/dayjs@1/plugin/localizedFormat.min.js - -countup: - js: https://cdn.jsdelivr.net/npm/countup.js@1.9.3/dist/countUp.min.js - -magnific-popup: - css: https://cdn.jsdelivr.net/npm/magnific-popup@1/dist/magnific-popup.min.css - js: https://cdn.jsdelivr.net/npm/magnific-popup@1/dist/jquery.magnific-popup.min.js - -lozad: - js: https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js - -clipboard: - js: https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js - -polyfill: - js: https://polyfill.io/v3/polyfill.min.js?features=es6 - -mathjax: - js: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js diff --git a/_data/assets/self_host.yml b/_data/assets/self_host.yml deleted file mode 100644 index ae5a399cd..000000000 --- a/_data/assets/self_host.yml +++ /dev/null @@ -1,51 +0,0 @@ -# fonts - -webfonts: /assets/lib/fonts/main.css - -# Libraries - -jquery: - js: /assets/lib/jquery-3.6.0/jquery.min.js - -bootstrap: - css: /assets/lib/bootstrap-4.6.1/bootstrap.min.css - js: /assets/lib/bootstrap-4.6.1/bootstrap.bundle.min.js - -bootstrap-toc: - css: /assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.css - js: /assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.js - -fontawesome: - css: /assets/lib/fontawesome-free-5.15.4/css/all.min.css - -search: - js: /assets/lib/simple-jekyll-search-1.10.0/simple-jekyll-search.min.js - -mermaid: - js: /assets/lib/mermaid-8.13.10/mermaid.min.js - -dayjs: - js: - common: /assets/lib/dayjs-1.10.7/dayjs.min.js - locale: /assets/lib/dayjs-1.10.7/locale/en.min.js - relativeTime: /assets/lib/dayjs-1.10.7/plugin/relativeTime.min.js - localizedFormat: /assets/lib/dayjs-1.10.7/plugin/localizedFormat.min.js - -countup: - js: /assets/lib/countup.js-1.9.3/countUp.min.js - -magnific-popup: - css: /assets/lib/magnific-popup-1.1.0/magnific-popup.css - js: /assets/lib/magnific-popup-1.1.0/jquery.magnific-popup.min.js - -lozad: - js: /assets/lib/lozad-1.16.0/lozad.min.js - -clipboard: - js: /assets/lib/clipboard-2.0.9/clipboard.min.js - -polyfill: - js: /assets/lib/polyfill-v3-es6/polyfill.min.js - -mathjax: - js: /assets/lib/mathjax-3.2.0/tex-chtml.js diff --git a/_data/authors.yml b/_data/authors.yml new file mode 100644 index 000000000..c66938d54 --- /dev/null +++ b/_data/authors.yml @@ -0,0 +1,12 @@ +## 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} +# ------------------------------------- + +ZhgChgLi: + name: ZhgChgLi + twitter: zhgchgli + url: https://medium.com/zhgchgli/ diff --git a/_data/locales/.DS_Store b/_data/locales/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/_data/locales/.DS_Store differ diff --git a/_data/locales/en.yml b/_data/locales/en.yml index 24636dad6..2b8325dac 100644 --- a/_data/locales/en.yml +++ b/_data/locales/en.yml @@ -20,7 +20,7 @@ tabs: search: hint: search cancel: Cancel - no_results: Oops! No result founds. + no_results: Oops! No results found. panel: lastmod: Recently Updated @@ -40,16 +40,16 @@ 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
- English Version of ZhgChg.Li
- Powered by ZMediumToMarkdown. +meta: >- + Using the :THEME theme for :PLATFORM.
+ All Medium articles were converted using ZMediumToMarkdown. not_found: - statment: Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. - hint_template: :HEAD_BAK to try finding it again, or search for it on the :ARCHIVES_PAGE. - head_back: Head back Home - archives_page: Archives page + statement: Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. + +notification: + update_found: A new version of content is available. + update: Update # ----- Posts related labels ----- @@ -72,10 +72,22 @@ post: share_link: title: Copy link succeed: Link copied successfully! - # pinned prompt of posts list on homepage - pin_prompt: Pinned + +# Date time format. +# See: , +df: + post: + strftime: "%b %e, %Y" + dayjs: "ll" + archives: + strftime: "%b" + dayjs: "MMM" # categories page categories: - category_measure: categories - post_measure: posts + category_measure: + singular: category + plural: categories + post_measure: + singular: post + plural: posts diff --git a/_data/locales/id-ID.yml b/_data/locales/id-ID.yml deleted file mode 100644 index 37ad8eae6..000000000 --- a/_data/locales/id-ID.yml +++ /dev/null @@ -1,78 +0,0 @@ -# The layout text of site - -# ----- Commons label ----- - -layout: - post: Postingan - category: Kategori - tag: Tagar - -# The tabs of sidebar -tabs: - # format: : - home: Beranda - categories: Kategori - tags: Tagar - archives: Arsip - about: Tentang - -# the text displayed in the search bar & search results -search: - hint: Cari - cancel: Batal - no_results: Ups! Tidak ada hasil yang ditemukan. - -panel: - lastmod: Postingan Terbaru - trending_tags: Tagar Terpopuler - toc: Konten - -copyright: - # Shown at the bottom of the post - license: - template: Postingan ini dilisensikan di bawah :LICENSE_NAME oleh penulis. - name: CC BY 4.0 - link: https://creativecommons.org/licenses/by/4.0/ - - # Displayed in the footer - brief: Sebagian konten dilindungi. - verbose: >- - Kecuali jika dinyatakan, Postingan blog di situs ini dilisensikan - di bawah Lisensi Creative Commons Attribution 4.0 International (CC BY 4.0) oleh penulis. - -meta: Didukung oleh :PLATFORM dengan tema :THEME. - -not_found: - statment: Maaf, kami gagal menemukan URL itu atau memang mengarah ke sesuatu yang tidak ada. - hint_template: :HEAD_BAK untuk mencoba mencari kembali, atau cari di :ARCHIVES_PAGE. - head_back: Kembali ke Beranda - archives_page: Halaman Arsip - -# ----- Posts related labels ----- - -post: - written_by: Oleh - posted: Diterbitkan - updated: Diperbarui - words: kata - pageview_measure: dilihat - read_time: - unit: menit - prompt: baca - relate_posts: Postingan Lainya - share: Bagikan - button: - next: Terbaru - previous: Terlama - copy_code: - succeed: Disalin! - share_link: - title: Salin tautan - succeed: Tautan berhasil disalin! - # pinned prompt of posts list on homepage - pin_prompt: Disematkan - -# categories page -categories: - category_measure: kategori - post_measure: Postingan diff --git a/_data/locales/ko-KR.yml b/_data/locales/ko-KR.yml deleted file mode 100644 index 4bfd31819..000000000 --- a/_data/locales/ko-KR.yml +++ /dev/null @@ -1,78 +0,0 @@ -# The layout text of site - -# ----- Commons label ----- - -layout: - post: 포스트 - category: 카테고리 - tag: 태그 - -# The tabs of sidebar -tabs: - # format: : - home: 홈 - categories: 카테고리 - tags: 태그 - archives: 아카이브 - about: 정보 - -# the text displayed in the search bar & search results -search: - hint: 검색 - cancel: 취소 - no_results: 검색 결과가 없습니다. - -panel: - lastmod: 최근 업데이트 - trending_tags: 인기 태그 - toc: 바로가기 - -copyright: - # Shown at the bottom of the post - license: - 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) 라이선스에 따라 사용이 허가되었습니다. - -meta: Powered by :PLATFORM with :THEME theme. - -not_found: - statment: 해당 URL은 존재하지 않습니다. - hint_template: :HEAD_BAK을 눌러 다시 찾거나 :ARCHIVES_PAGE에서 검색해 주세요. - head_back: 홈으로 돌아가기 - archives_page: 아카이브 페이지 - -# ----- Posts related labels ----- - -post: - written_by: By - posted: 게시 - updated: 업데이트 - words: 단어 - pageview_measure: 조회 - read_time: - unit: 분 - prompt: 읽는 시간 - relate_posts: 관련된 글 - share: 공유하기 - button: - next: 다음 글 - previous: 이전 글 - copy_code: - succeed: 복사되었습니다! - share_link: - title: 링크 복사하기 - succeed: 링크가 복사되었습니다! - # pinned prompt of posts list on homepage - pin_prompt: 핀 - -# categories page -categories: - category_measure: 카테고리 - post_measure: 포스트 diff --git a/_data/locales/my-MM.yml b/_data/locales/my-MM.yml deleted file mode 100644 index 6ad9e2818..000000000 --- a/_data/locales/my-MM.yml +++ /dev/null @@ -1,78 +0,0 @@ -# The layout text of site - -# ----- Commons label ----- - -layout: - post: ပို့စ် - category: ကဏ္ဍ - tag: နာမ(တက်ဂ်) - -# The tabs of sidebar -tabs: - # format: : - home: အဓိကစာမျက်နှာ - categories: ကဏ္ဍများ - tags: နာမ(တက်ဂ်)များ - archives: မှတ်တမ်း​တိုက် - about: အကြောင်းအရာ - -# the text displayed in the search bar & search results -search: - hint: ရှာဖွေမည် - cancel: ဖျက်သိမ်းမည် - no_results: အိုး! ဘာမှမရှိပါ - -panel: - lastmod: မကြာသေးမီကမွမ်းမံထားသည် - trending_tags: ခေတ်စားနေသည့်တက်ဂ်များ - toc: အကြောင်းအရာများ - -copyright: - # Shown at the bottom of the post - license: - 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) အောက်တွင် လိုင်စင်ရထားပါသည်။ - -meta: Powered by :PLATFORM with :THEME theme. - -not_found: - statment: ဝမ်းနည်းပါသည်၊ ကျွန်ုပ်တို့သည် အဆိုပါ URL ကို မှားယွင်းစွာ နေရာချထားခြင်း သို့မဟုတ် ၎င်းသည် မရှိသောအရာကို ညွှန်ပြနေပါသည်။ - hint_template: ၎င်းကို ထပ်မံရှာဖွေရန် :HEAD_BAK , သို့မဟုတ် :ARCHIVES_PAGE တွင်ရှာပါ။ - head_back: အဓိကစာမျက်နှာသို့ပြန်သွားပါ။ - archives_page: မှတ်တမ်း​တိုက် စာမျက်နှာ။ - -# ----- Posts related labels ----- - -post: - written_by: ကရေးသားခဲ့သည်။ - posted: တင်ထားခဲ့သည်။ - updated: မွမ်းမံထားခဲ့သည်။ - words: စကားလုံးများ - pageview_measure: အမြင်များ - read_time: - unit: မိနစ် - prompt: ဖတ်ပါမည် - relate_posts: နောက်ထပ်ဖတ်ရန် - share: မျှဝေရန် - button: - next: အသစ်များ - previous: အဟောင်းများ - copy_code: - succeed: ကူးယူလိုက်ပြီ။ - share_link: - title: လင့်ခ်ကို ကူးယူရန် - succeed: လင့်ခ်ကို ကူးယူလိုက်ပြီ။ - # pinned prompt of posts list on homepage - pin_prompt: ချိတ်ထားသည်။ - -# categories page -categories: - category_measure: ကဏ္ဍများ - post_measure: ပို့စ်များ diff --git a/_data/locales/ru-RU.yml b/_data/locales/ru-RU.yml deleted file mode 100644 index 1a538fe6c..000000000 --- a/_data/locales/ru-RU.yml +++ /dev/null @@ -1,78 +0,0 @@ -# The layout text of site - -# ----- Commons label ----- - -layout: - post: Публикация - category: Категория - tag: Тег - -# The tabs of sidebar -tabs: - # format: : - home: Домашняя страница - categories: Категории - tags: Теги - archives: Архив - about: О сайте - -# the text displayed in the search bar & search results -search: - hint: поиск - cancel: Отменить - no_results: Ох! Ничего не найдено. - -panel: - lastmod: Недавно обновлено - trending_tags: Популярные теги - toc: Содержание - -copyright: - # Shown at the bottom of the post - license: - 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), - если в тексте публикации не указано иное. - -meta: Powered by :PLATFORM with :THEME theme. - -not_found: - statment: Извините, эта ссылка указывает на ресурс который не существует. - hint_template: :HEAD_BAK чтобы снова осуществить поиск, или поищите :ARCHIVES_PAGE. - head_back: Вернитесь на домашнюю страницу - archives_page: архиве - -# ----- Posts related labels ----- - -post: - written_by: Автор - posted: Время публикации - updated: Обновлено - words: слов - pageview_measure: просмотров - read_time: - unit: минут - prompt: чтения - relate_posts: Вам также может быть интересно - share: Поделиться - button: - next: Предыдущая публикация - previous: Следующая публикация - copy_code: - succeed: Скопировано успешно! - share_link: - title: Скопировать ссылку - succeed: Ссылка успешно скопирована! - # pinned prompt of posts list on homepage - pin_prompt: Закреплено - -# categories page -categories: - category_measure: категории - post_measure: публикации diff --git a/_data/locales/uk-UA.yml b/_data/locales/uk-UA.yml deleted file mode 100644 index c06faaf31..000000000 --- a/_data/locales/uk-UA.yml +++ /dev/null @@ -1,78 +0,0 @@ -# The layout text of site - -# ----- Commons label ----- - -layout: - post: Публікація - category: Категорія - tag: Тег - -# The tabs of sidebar -tabs: - # format: : - home: Домашня сторінка - categories: Категорії - tags: Теги - archives: Архів - about: Про сайт - -# the text displayed in the search bar & search results -search: - hint: пошук - cancel: Скасувати - no_results: Ох! Нічого не знайдено. - -panel: - lastmod: Нещодавно оновлено - trending_tags: Популярні теги - toc: Зміст - -copyright: - # Shown at the bottom of the post - license: - 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), - якщо інше не вказано в тексті. - -meta: Powered by :PLATFORM with :THEME theme. - -not_found: - statment: Вибачте, це посилання вказує на ресурс, що не існує. - hint_template: :HEAD_BAK аби здійснити пошук, або пошукайте в :ARCHIVES_PAGE. - head_back: Поверніться на домашню сторінку - archives_page: архіві - -# ----- Posts related labels ----- - -post: - written_by: Автор - posted: Час публікації - updated: Оновлено - words: слів - pageview_measure: переглядів - read_time: - unit: хвилин - prompt: читання - relate_posts: Вас також може зацікавити - share: Поділитися - button: - next: Попередня публікація - previous: Наступна публікація - copy_code: - succeed: Успішно скопійовано! - share_link: - title: Скопіювати посилання - succeed: Посилання успішно скопійовано! - # pinned prompt of posts list on homepage - pin_prompt: Закріплено - -# categories page -categories: - category_measure: категорії - post_measure: публікації diff --git a/_data/locales/zh-CN.yml b/_data/locales/zh-CN.yml deleted file mode 100644 index 880a47ee9..000000000 --- a/_data/locales/zh-CN.yml +++ /dev/null @@ -1,77 +0,0 @@ -# The layout text of site - -# ----- Commons label ----- - -layout: - post: 文章 - category: 分类 - tag: 标签 - -# The tabs of sidebar -tabs: - # format: : - home: 首页 - categories: 分类 - tags: 标签 - archives: 归档 - about: 关于 - -# the text displayed in the search bar & search results -search: - hint: 搜索 - cancel: 取消 - no_results: 搜索结果为空 - -panel: - lastmod: 最近更新 - trending_tags: 热门标签 - toc: 文章内容 - -copyright: - # Shown at the bottom of the post - license: - template: 本文由作者按照 :LICENSE_NAME 进行授权 - name: CC BY 4.0 - link: https://creativecommons.org/licenses/by/4.0/ - - # Displayed in the footer - brief: 保留部分权利。 - verbose: >- - 除非另有说明,本网站上的博客文章均由作者按照知识共享署名 4.0 国际 (CC BY 4.0) 许可协议进行授权。 - -meta: 本站由 :PLATFORM 生成,采用 :THEME 主题。 - -not_found: - statment: 抱歉,我们放错了该 URL,或者它指向了不存在的内容。 - hint_template: :HEAD_BAK尝试再次查找它,或在:ARCHIVES_PAGE上搜索它。 - head_back: 返回主页 - archives_page: 归档页面 - -# ----- Posts related labels ----- - -post: - written_by: 作者 - posted: 发表于 - updated: 更新于 - words: 字 - pageview_measure: 次浏览 - read_time: - unit: 分钟 - prompt: 阅读 - relate_posts: 相关文章 - share: 分享 - button: - next: 下一篇 - previous: 上一篇 - copy_code: - succeed: 已复制! - share_link: - title: 分享链接 - succeed: 链接已复制! - # pinned prompt of posts list on homepage - pin_prompt: 顶置 - -# categories page -categories: - category_measure: 个分类 - post_measure: 篇文章 diff --git a/_includes/advertisements.html b/_includes/advertisements.html deleted file mode 100644 index ee5578c41..000000000 --- a/_includes/advertisements.html +++ /dev/null @@ -1,3 +0,0 @@ -

KKday 商品推薦

- - \ No newline at end of file diff --git a/_includes/buymeacoffee.html b/_includes/buymeacoffee.html deleted file mode 100644 index 6e5b3e05f..000000000 --- a/_includes/buymeacoffee.html +++ /dev/null @@ -1,3 +0,0 @@ - -
- \ No newline at end of file diff --git a/_includes/post-footer.html b/_includes/post-footer.html deleted file mode 100644 index a7e62e2d4..000000000 --- a/_includes/post-footer.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/_includes/post-header.html b/_includes/post-header.html deleted file mode 100644 index 3844633da..000000000 --- a/_includes/post-header.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/_layouts/page.html b/_layouts/page.html deleted file mode 100644 index d147e96f2..000000000 --- a/_layouts/page.html +++ /dev/null @@ -1,70 +0,0 @@ ---- -layout: default -tail_includes: - - comments ---- - -{% include lang.html %} -{% include origin-type.html %} - -{% if layout.tail_includes %} - {% assign has_tail = true %} -{% endif %} - -
- -
- {% capture padding %} - {% unless page.layout == 'home' %}px-1{% endunless %} - {% endcapture %} - -
- {% capture _content %} - {% if layout.refactor or page.layout == 'page' %} - {% include refactor-content.html content=content lang=lang %} - {% else %} - {{ content }} - {% endif %} - {% endcapture %} - - {% if page.layout == 'page' or page.collection == 'tabs' %} - {% assign tab_key = page.title | downcase %} - {% assign title = site.data.locales[lang].tabs[tab_key] | default: page.title %} -

- {{ title }} -

-
- {{ _content }} -
- {% else %} - {{ _content }} - {% endif %} -
-
- - - -
-
- {% include_cached update-list.html lang=lang %} - {% include_cached trending-tags.html lang=lang %} -
- - {% for _include in layout.panel_includes %} - {% assign _include_path = _include | append: '.html' %} - {% include {{ _include_path }} lang=lang %} - {% endfor %} -
-
- - -{% if has_tail %} -
-
- {% for _include in layout.tail_includes %} - {% assign _include_path = _include | append: '.html' %} - {% include {{ _include_path }} lang=lang %} - {% endfor %} -
-
-{% endif %} \ No newline at end of file diff --git a/_layouts/post.html b/_layouts/post.html deleted file mode 100644 index e2ae9c883..000000000 --- a/_layouts/post.html +++ /dev/null @@ -1,141 +0,0 @@ ---- -layout: page -refactor: true -panel_includes: - - toc -tail_includes: - - related-posts - - post-nav - - comments ---- - -{% include lang.html %} - -

{{ page.title }}

- - - -
- {% include post-header.html %} - {{ content }} - {% include post-footer.html %} -
- -
- -{% include buymeacoffee.html %} - -{% include advertisements.html %} - -
- - - {% if page.categories.size > 0 %} - - {% endif %} - - - {% if page.tags.size > 0 %} - - {% endif %} - -
-
- - {% if site.data.locales[lang].copyright.license.template %} - - {% capture _replacement %} - - {{ site.data.locales[lang].copyright.license.name }} - - {% endcapture %} - - {{ site.data.locales[lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }} - - {% endif %} -
- - {% include post-sharing.html lang=lang %} - -
- -
\ No newline at end of file diff --git a/_plugins/posts-remove-medium-footer-hook.rb b/_plugins/posts-remove-medium-footer-hook.rb new file mode 100644 index 000000000..e0562e902 --- /dev/null +++ b/_plugins/posts-remove-medium-footer-hook.rb @@ -0,0 +1,77 @@ +#!/usr/bin/env ruby +# +require 'net/http' +require 'nokogiri' +require 'uri' + + +def load_medium_followers(url, limit = 10) + return 0 if limit.zero? + + uri = URI(url) + response = Net::HTTP.get_response(uri) + case response + when Net::HTTPSuccess then + document = Nokogiri::HTML(response.body) + + follower_count_element = document.at('span.pw-follower-count > a') + follower_count = follower_count_element&.text&.split(' ')&.first + + return follower_count || 0 + when Net::HTTPRedirection then + location = response['location'] + return load_medium_followers(location, limit - 1) + else + return 0 + end +end + +$medium_url = "https://medium.com/@zhgchgli" +$medium_followers = load_medium_followers($medium_url) + +$medium_followers = 1000 if $medium_followers == 0 +$medium_followers = $medium_followers.to_s.reverse.scan(/\d{1,3}/).join(',').reverse + +Jekyll::Hooks.register :posts, :pre_render do |post| + slug = post.data['slug'] + post.content = post.content.gsub(/(_\[Post\])(.*)(converted from Medium by \[ZMediumToMarkdown\])(.*)(\._)/, '') + + headerHTML = <<-HTML + + HTML + + footerHTML = <<-HTML + \r\n\r\n=== + \r\n\r\n本文首次發表於 Medium ➡️ [**前往查看**](https://medium.com/p/#{slug}){:target=\"_blank\"}\r\n + + HTML + + if post.data['categories'].any? { |category| category.match(/遊記/) } + footerHTML += <<-HTML + 如果這篇文章對您有幫助,歡迎使用我的 推廣連結 選購 KKday 商品、行程,我將獲得部分收益,持續更多旅遊創作,謝謝: + + + HTML + end + + footerHTML += <<-HTML + + + + HTML + + + post.content = headerHTML + post.content + footerHTML +end + +Jekyll::Hooks.register :site, :pre_render do |site| + + tagline = site.config['tagline'] + + followMe = <<-HTML + #{$medium_followers}+ Followers on Medium + HTML + + site.config['tagline'] = "#{followMe}" + site.config['tagline'] += tagline +end \ No newline at end of file diff --git a/_posts/.DS_Store b/_posts/.DS_Store new file mode 100644 index 000000000..4a7e9a249 Binary files /dev/null and b/_posts/.DS_Store differ diff --git a/_tabs/about.md b/_tabs/about.md index 7736ac3f2..463563fab 100644 --- a/_tabs/about.md +++ b/_tabs/about.md @@ -1,10 +1,10 @@ --- -title: About +# the default layout is 'page' icon: fas fa-info-circle -comments: true order: 4 --- + ## Harry Li (ZhgChg Li) ![](/assets/images/zhgchgli.jpg){: width="250" } @@ -77,3 +77,4 @@ ZReviewTender is a tool for fetching app reviews from the App Store and Google P - More tools: [ZRealm](https://github.com/ZhgChgLi) + diff --git a/_tabs/archives.md b/_tabs/archives.md index f969f92f2..c3abc5944 100644 --- a/_tabs/archives.md +++ b/_tabs/archives.md @@ -1,7 +1,5 @@ --- layout: archives -title: Archives icon: fas fa-archive order: 3 --- - diff --git a/_tabs/categories.md b/_tabs/categories.md index 3a23c2951..2d241be92 100644 --- a/_tabs/categories.md +++ b/_tabs/categories.md @@ -1,6 +1,5 @@ --- layout: categories -title: Categories icon: fas fa-stream order: 1 --- diff --git a/_tabs/tags.md b/_tabs/tags.md index 2108d24a0..ded3adc15 100644 --- a/_tabs/tags.md +++ b/_tabs/tags.md @@ -1,6 +1,5 @@ --- layout: tags -title: Tags -icon: fas fa-tag +icon: fas fa-tags order: 2 --- diff --git a/ads.txt b/ads.txt deleted file mode 100644 index 1807916c7..000000000 --- a/ads.txt +++ /dev/null @@ -1,5 +0,0 @@ ---- -layout: null -sitemap: false ---- -google.com, pub-3184248473087645, DIRECT, f08c47fec0942fa0 diff --git a/assets/.DS_Store b/assets/.DS_Store new file mode 100644 index 000000000..ab5541536 Binary files /dev/null and b/assets/.DS_Store differ diff --git a/assets/404.html b/assets/404.html deleted file mode 100644 index 110d66835..000000000 --- a/assets/404.html +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: page -title: "404: Page not found" -permalink: /404.html - -redirect_from: - - /norobots/ - - /assets/ - - /posts/ ---- - -
-

{{site.data.locales[site.lang].not_found.statment }}

-
- - \ No newline at end of file diff --git a/assets/images/.DS_Store b/assets/images/.DS_Store new file mode 100644 index 000000000..331dd0126 Binary files /dev/null and b/assets/images/.DS_Store differ diff --git a/assets/img/.DS_Store b/assets/img/.DS_Store new file mode 100644 index 000000000..532566ffd Binary files /dev/null and b/assets/img/.DS_Store differ diff --git a/posts-lastmod-hook 2.rb b/posts-lastmod-hook 2.rb new file mode 100644 index 000000000..1fd6ecf9d --- /dev/null +++ b/posts-lastmod-hook 2.rb @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +# +# Check for changed posts + +Jekyll::Hooks.register :posts, :post_init do |post| + + commit_num = `git rev-list --count HEAD "#{ post.path }"` + + if commit_num.to_i > 1 + lastmod_date = `git log -1 --pretty="%ad" --date=iso "#{ post.path }"` + post.data['last_modified_at'] = lastmod_date + end + +end diff --git a/posts-lastmod-hook.rb b/posts-lastmod-hook.rb new file mode 100644 index 000000000..1fd6ecf9d --- /dev/null +++ b/posts-lastmod-hook.rb @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby +# +# Check for changed posts + +Jekyll::Hooks.register :posts, :post_init do |post| + + commit_num = `git rev-list --count HEAD "#{ post.path }"` + + if commit_num.to_i > 1 + lastmod_date = `git log -1 --pretty="%ad" --date=iso "#{ post.path }"` + post.data['last_modified_at'] = lastmod_date + end + +end diff --git a/tools/deploy.sh b/tools/deploy.sh deleted file mode 100755 index 1a4ee49e8..000000000 --- a/tools/deploy.sh +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env bash -# -# Build, test and then deploy the site content to 'origin/' -# -# Requirement: html-proofer, jekyll -# -# Usage: See help information - -set -eu - -PAGES_BRANCH="gh-pages" - -SITE_DIR="_site" - -_opt_dry_run=false - -_config="_config.yml" - -_no_pages_branch=false - -_backup_dir="$(mktemp -d)" - -_baseurl="" - -help() { - echo "Build, test and then deploy the site content to 'origin/'" - echo - echo "Usage:" - echo - echo " bash ./tools/deploy.sh [options]" - echo - echo "Options:" - echo ' -c, --config "" Specify config file(s)' - echo " --dry-run Build site and test, but not deploy" - echo " -h, --help Print this information." -} - -init() { - if [[ -z ${GITHUB_ACTION+x} && $_opt_dry_run == 'false' ]]; then - echo "ERROR: It is not allowed to deploy outside of the GitHub Action envrionment." - echo "Type option '-h' to see the help information." - exit -1 - fi - - _baseurl="$(grep '^baseurl:' _config.yml | sed "s/.*: *//;s/['\"]//g;s/#.*//")" -} - -build() { - # clean up - if [[ -d $SITE_DIR ]]; then - rm -rf "$SITE_DIR" - fi - - # run optimzie markdown - bundle exec ruby "tools/zhgchgli_optimize_footer.rb" - - # build - JEKYLL_ENV=production bundle exec jekyll b -d "$SITE_DIR$_baseurl" --config "$_config" - - git checkout -- "_posts/*.md" -} - -test() { - bundle exec htmlproofer \ - --disable-external \ - --check-html \ - --allow_hash_href \ - "$SITE_DIR" -} - -resume_site_dir() { - if [[ -n $_baseurl ]]; then - # Move the site file to the regular directory '_site' - mv "$SITE_DIR$_baseurl" "${SITE_DIR}-rename" - rm -rf "$SITE_DIR" - mv "${SITE_DIR}-rename" "$SITE_DIR" - fi -} - -setup_gh() { - if [[ -z $(git branch -av | grep "$PAGES_BRANCH") ]]; then - _no_pages_branch=true - git checkout -b "$PAGES_BRANCH" - else - git checkout "$PAGES_BRANCH" - fi -} - -backup() { - mv "$SITE_DIR"/* "$_backup_dir" - mv .git "$_backup_dir" - - # When adding custom domain from Github website, - # the CANME only exist on `gh-pages` branch - if [[ -f CNAME ]]; then - mv CNAME "$_backup_dir" - fi -} - -flush() { - rm -rf ./* - rm -rf .[^.] .??* - - shopt -s dotglob nullglob - mv "$_backup_dir"/* . - [[ -f ".nojekyll" ]] || echo "" >".nojekyll" -} - -deploy() { - git config --global user.name "GitHub Actions" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - - git update-ref -d HEAD - git add -A - git commit -m "[Automation] Site update No.${GITHUB_RUN_NUMBER}" - - if $_no_pages_branch; then - git push -u origin "$PAGES_BRANCH" - else - git push -f - fi -} - -main() { - init - build - test - resume_site_dir - - if $_opt_dry_run; then - exit 0 - fi - - setup_gh - backup - flush - deploy -} - -while (($#)); do - opt="$1" - case $opt in - -c | --config) - _config="$2" - shift - shift - ;; - --dry-run) - # build & test, but not deploy - _opt_dry_run=true - shift - ;; - -h | --help) - help - exit 0 - ;; - *) - # unknown option - help - exit 1 - ;; - esac -done - -main diff --git a/tools/run.sh b/tools/run.sh new file mode 100755 index 000000000..0efc452d3 --- /dev/null +++ b/tools/run.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# +# Run jekyll serve and then launch the site + +prod=false +command="bundle exec jekyll s -l" +host="127.0.0.1" + +help() { + echo "Usage:" + echo + echo " bash /path/to/run [options]" + echo + echo "Options:" + echo " -H, --host [HOST] Host to bind to." + echo " -p, --production Run Jekyll in 'production' mode." + echo " -h, --help Print this help information." +} + +while (($#)); do + opt="$1" + case $opt in + -H | --host) + host="$2" + shift 2 + ;; + -p | --production) + prod=true + shift + ;; + -h | --help) + help + exit 0 + ;; + *) + echo -e "> Unknown option: '$opt'\n" + help + exit 1 + ;; + esac +done + +command="$command -H $host" + +if $prod; then + command="JEKYLL_ENV=production $command" +fi + +if [ -e /proc/1/cgroup ] && grep -q docker /proc/1/cgroup; then + command="$command --force_polling" +fi + +echo -e "\n> $command\n" +eval "$command" diff --git a/tools/test.sh b/tools/test.sh new file mode 100755 index 000000000..331de1c34 --- /dev/null +++ b/tools/test.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# +# Build and test the site content +# +# Requirement: html-proofer, jekyll +# +# Usage: See help information + +set -eu + +SITE_DIR="_site" + +_config="_config.yml" + +_baseurl="" + +help() { + echo "Build and test the site content" + echo + echo "Usage:" + echo + echo " bash $0 [options]" + echo + echo "Options:" + echo ' -c, --config "" Specify config file(s)' + echo " -h, --help Print this information." +} + +read_baseurl() { + if [[ $_config == *","* ]]; then + # multiple config + IFS="," + read -ra config_array <<<"$_config" + + # reverse loop the config files + for ((i = ${#config_array[@]} - 1; i >= 0; i--)); do + _tmp_baseurl="$(grep '^baseurl:' "${config_array[i]}" | sed "s/.*: *//;s/['\"]//g;s/#.*//")" + + if [[ -n $_tmp_baseurl ]]; then + _baseurl="$_tmp_baseurl" + break + fi + done + + else + # single config + _baseurl="$(grep '^baseurl:' "$_config" | sed "s/.*: *//;s/['\"]//g;s/#.*//")" + fi +} + +main() { + # clean up + if [[ -d $SITE_DIR ]]; then + rm -rf "$SITE_DIR" + fi + + read_baseurl + + # build + JEKYLL_ENV=production bundle exec jekyll b \ + -d "$SITE_DIR$_baseurl" -c "$_config" + + # test + bundle exec htmlproofer "$SITE_DIR" \ + --disable-external \ + --ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/" +} + +while (($#)); do + opt="$1" + case $opt in + -c | --config) + _config="$2" + shift + shift + ;; + -h | --help) + help + exit 0 + ;; + *) + # unknown option + help + exit 1 + ;; + esac +done + +main diff --git a/tools/zhgchgli_optimize_footer.rb b/tools/zhgchgli_optimize_footer.rb deleted file mode 100644 index 9c9491704..000000000 --- a/tools/zhgchgli_optimize_footer.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'net/http' -require 'uri' - -class Main - def run() - files = Dir['_posts/zmediumtomarkdown/*.md'] - files.each do |file| - id = file.split("-").last.split(".").first - - lines = File.readlines(file) - newLines = [] - - en_url = "https://en.zhgchg.li/posts/#{id}/" - en_url_exists = url_exists(en_url) - en_text = "\r\n[View the English version of this article here.](#{en_url}){:target=\"_blank\"}\r\n" - - lines.each do |line| - if line.include? "延伸閱讀" or line.include? "本文同步發表於" or line.include? "Like Z Realm" or line.include? "有任何問題及指教歡迎與我聯絡。" or line.include? "converted from Medium by [ZMediumToMarkdown]" - - newLines.append("\r\n\r\n===") - if en_url_exists - newLines.append("\r\n\r\n#{en_text}") - end - newLines.append("\r\n\r\n本文首次發表於 Medium ➡️ [**前往查看**](https://medium.com/p/#{id}){:target=\"_blank\"}\r\n") - - - break - end - newLines.append(line) - end - - File.open(file, 'w') { |f| f.write(newLines.join) } - - puts "#{file} Optimze Done!" - end - - puts "Optimze Markdown Footer Success!" - end - - def url_exists(url) - uri = URI.parse(url) - request = Net::HTTP.new(uri.host, uri.port) - request.use_ssl = (uri.scheme == 'https') - - path = uri.path.empty? ? '/' : uri.path - response = request.request_head(path) - - response.code.to_i != 404 - end -end - -main = Main.new() -main.run()