diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..39c428d --- /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 0000000..a4bc282 --- /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/.github/workflows/pages-deploy.yml b/.github/workflows/pages-deploy.yml index c33b2a6..cc28f99 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/.gitignore b/.gitignore index 0124b68..7dd7cef 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ Gemfile.lock # Jekyll cache .jekyll-cache +.jekyll-metadata _site # RubyGems @@ -16,7 +17,11 @@ package-lock.json # IDE configurations .idea -.vscode +.vscode/* +!.vscode/settings.json +!.vscode/extensions.json +!.vscode/tasks.json # Misc +_sass/vendors assets/js/dist diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..082bc94 --- /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 0000000..5e8a04f --- /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 0000000..7f0fdb8 --- /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 62d6fe4..7835d7d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,23 +2,13 @@ source "https://rubygems.org" -gem "jekyll-theme-chirpy", "~> 6.5", ">= 6.5.5" -gem 'jekyll-compose', group: [:jekyll_plugins] +gem "jekyll-theme-chirpy", "~> 7.2", ">= 7.2.4" -group :test do - gem "html-proofer", "~> 4.4" -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. 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] +gem "wdm", "~> 0.2.0", :platforms => [:mingw, :x64_mingw, :mswin] diff --git a/README.md b/README.md index 9b4e987..793cd08 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,18 @@ -# Chirpy Starter [![Gem Version](https://img.shields.io/gem/v/jekyll-theme-chirpy)](https://rubygems.org/gems/jekyll-theme-chirpy) [![GitHub license](https://img.shields.io/github/license/cotes2020/chirpy-starter.svg?color=blue)][mit] +# Chirpy Starter -When installing the [**Chirpy**][chirpy] theme through [RubyGems.org][gem], Jekyll can only read files in the folders `/_data`, `/_layouts`, `/_includes`, `/_sass` and `/assets`, as well as a small part of options of the `/_config.yml` file from the theme's gem. If you have ever installed this theme gem, you can use the command `bundle info --path jekyll-theme-chirpy` to locate these files. +[![Gem Version](https://img.shields.io/gem/v/jekyll-theme-chirpy)][gem]  +[![GitHub license](https://img.shields.io/github/license/cotes2020/chirpy-starter.svg?color=blue)][mit] -The Jekyll team claims that this is to leave the ball in the user’s court, but this also results in users not being able to enjoy the out-of-the-box experience when using feature-rich themes. +When installing the [**Chirpy**][chirpy] theme through [RubyGems.org][gem], Jekyll can only read files in the folders +`_data`, `_layouts`, `_includes`, `_sass` and `assets`, as well as a small part of options of the `_config.yml` file +from the theme's gem. If you have ever installed this theme gem, you can use the command +`bundle info --path jekyll-theme-chirpy` to locate these files. -To fully use all the features of **Chirpy**, you need to copy the other critical files from the theme's gem to your Jekyll site. The following is a list of targets: +The Jekyll team claims that this is to leave the ball in the user’s court, but this also results in users not being +able to enjoy the out-of-the-box experience when using feature-rich themes. + +To fully use all the features of **Chirpy**, you need to copy the other critical files from the theme's gem to your +Jekyll site. The following is a list of targets: ```shell . @@ -14,25 +22,16 @@ To fully use all the features of **Chirpy**, you need to copy the other critical └── index.html ``` -To save you time, and also in case you lose some files while copying, we extract those files/configurations of the latest version of the **Chirpy** theme and the [CD][CD] workflow to here, so that you can start writing in minutes. - -## Prerequisites - -Follow the instructions in the [Jekyll Docs](https://jekyllrb.com/docs/installation/) to complete the installation of the basic environment. [Git](https://git-scm.com/) also needs to be installed. - -## Installation - -Sign in to GitHub and [**use this template**][use-template] to generate a brand new repository and name it `USERNAME.github.io`, where `USERNAME` represents your GitHub username. - -Then clone it to your local machine and run: - -``` -$ bundle -``` +To save you time, and also in case you lose some files while copying, we extract those files/configurations of the +latest version of the **Chirpy** theme and the [CD][CD] workflow to here, so that you can start writing in minutes. ## Usage -Please see the [theme's docs](https://github.com/cotes2020/jekyll-theme-chirpy#documentation). +Check out the [theme's docs](https://github.com/cotes2020/jekyll-theme-chirpy/wiki). + +## Contributing + +This repository is automatically updated with new releases from the theme repository. If you encounter any issues or want to contribute to its improvement, please visit the [theme repository][chirpy] to provide feedback. ## License @@ -40,6 +39,5 @@ This work is published under [MIT][mit] License. [gem]: https://rubygems.org/gems/jekyll-theme-chirpy [chirpy]: https://github.com/cotes2020/jekyll-theme-chirpy/ -[use-template]: https://github.com/cotes2020/chirpy-starter/generate [CD]: https://en.wikipedia.org/wiki/Continuous_deployment [mit]: https://github.com/cotes2020/chirpy-starter/blob/master/LICENSE diff --git a/_data/contact.yml b/_data/contact.yml index d584334..138ec08 100644 --- a/_data/contact.yml +++ b/_data/contact.yml @@ -4,7 +4,7 @@ icon: "fab fa-github" - type: twitter - icon: "fab fa-twitter" + icon: "fa-brands fa-x-twitter" - type: email icon: "fas fa-envelope" @@ -26,3 +26,15 @@ # - type: stack-overflow # icon: 'fab fa-stack-overflow' # url: '' # Fill with your stackoverflow homepage +# +# - type: bluesky +# icon: 'fa-brands fa-bluesky' +# url: '' # Fill with your Bluesky profile link +# +# - type: reddit +# icon: 'fa-brands fa-reddit' +# url: '' # Fill with your Reddit profile link +# +# - type: threads +# icon: 'fa-brands fa-threads' +# url: '' # Fill with your Threads profile link diff --git a/_data/share.yml b/_data/share.yml index 330fb6d..de1d3e8 100644 --- a/_data/share.yml +++ b/_data/share.yml @@ -15,11 +15,15 @@ platforms: link: "https://t.me/share/url?url=URL&text=TITLE" # Uncomment below if you need to. - # + - type: Linkedin icon: "fab fa-linkedin" link: "https://www.linkedin.com/sharing/share-offsite/?url=URL" - + + - type: Weibo + icon: "fab fa-weibo" + link: "https://service.weibo.com/share/share.php?title=TITLE&url=URL" + - type: Mastodon icon: "fa-brands fa-mastodon" # See: https://github.com/justinribeiro/share-to-mastodon#properties @@ -32,11 +36,15 @@ platforms: link: "https://fosstodon.org/" - label: photog.social link: "https://photog.social/" - - label: infosec.exchange - link: "https://infosec.exchange/" - - # - # - type: Weibo - # icon: "fab fa-weibo" - # link: "http://service.weibo.com/share/share.php?title=TITLE&url=URL" - # + + - type: Bluesky + icon: "fa-brands fa-bluesky" + link: "https://bsky.app/intent/compose?text=TITLE%20URL" + + - type: Reddit + icon: "fa-brands fa-square-reddit" + link: "https://www.reddit.com/submit?url=URL&title=TITLE" + + - type: Threads + icon: "fa-brands fa-square-threads" + link: "https://www.threads.net/intent/post?text=TITLE%20URL" diff --git a/tools/run.sh b/tools/run.sh new file mode 100755 index 0000000..0efc452 --- /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 0000000..331de1c --- /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