From b70b3a4b515e588e2b9d5107a6a5377b6c0063a5 Mon Sep 17 00:00:00 2001 From: developer Date: Sat, 9 Nov 2024 15:14:52 +0800 Subject: [PATCH] init --- .github/DISCUSSION_TEMPLATE/general.yml | 17 - .github/DISCUSSION_TEMPLATE/ideas.yml | 7 - .github/DISCUSSION_TEMPLATE/q-a.yml | 40 -- .github/FUNDING.yml | 2 - .github/ISSUE_TEMPLATE/bug_report.yml | 64 --- .github/ISSUE_TEMPLATE/config.yml | 5 - .github/ISSUE_TEMPLATE/feature_request.yml | 38 -- .github/PULL_REQUEST_TEMPLATE.md | 17 - .github/codeql/codeql-config.yml | 2 - .github/dependabot.yml | 28 - .github/workflows/cd.yml | 40 -- .github/workflows/ci.yml | 45 -- .github/workflows/codeql.yml | 44 -- .github/workflows/commitlint.yml | 9 - .../workflows/{starter => }/pages-deploy.yml | 0 .github/workflows/publish.yml | 22 - .github/workflows/stale.yml | 32 -- .github/workflows/style-lint.yml | 23 - _config.yml | 6 +- _posts/2019-08-08-text-and-typography.md | 200 ------- _posts/2019-08-08-write-a-new-post.md | 505 ------------------ _posts/2019-08-09-getting-started.md | 151 ------ _posts/2019-08-11-customize-the-favicon.md | 37 -- tools/init.sh | 130 ----- tools/release.sh | 186 ------- 25 files changed, 3 insertions(+), 1647 deletions(-) delete mode 100644 .github/DISCUSSION_TEMPLATE/general.yml delete mode 100644 .github/DISCUSSION_TEMPLATE/ideas.yml delete mode 100644 .github/DISCUSSION_TEMPLATE/q-a.yml delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/codeql/codeql-config.yml delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/cd.yml delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/commitlint.yml rename .github/workflows/{starter => }/pages-deploy.yml (100%) delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/stale.yml delete mode 100644 .github/workflows/style-lint.yml delete mode 100644 _posts/2019-08-08-text-and-typography.md delete mode 100644 _posts/2019-08-08-write-a-new-post.md delete mode 100644 _posts/2019-08-09-getting-started.md delete mode 100644 _posts/2019-08-11-customize-the-favicon.md delete mode 100755 tools/init.sh delete mode 100755 tools/release.sh diff --git a/.github/DISCUSSION_TEMPLATE/general.yml b/.github/DISCUSSION_TEMPLATE/general.yml deleted file mode 100644 index 18d0f8585fb..00000000000 --- a/.github/DISCUSSION_TEMPLATE/general.yml +++ /dev/null @@ -1,17 +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: textarea - attributes: - label: Description - description: Please describe in detail what you want to share. - validations: - required: true diff --git a/.github/DISCUSSION_TEMPLATE/ideas.yml b/.github/DISCUSSION_TEMPLATE/ideas.yml deleted file mode 100644 index e4c987d794e..00000000000 --- a/.github/DISCUSSION_TEMPLATE/ideas.yml +++ /dev/null @@ -1,7 +0,0 @@ -body: - - 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/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index f22921b7049..00000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -ko_fi: coteschung -custom: https://sponsor.cotes.page 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/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 1dfb2b26dd0..00000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Ask the community for help - url: https://github.com/cotes2020/jekyll-theme-chirpy/discussions - about: Please ask and answer questions here. 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/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0ff984a75d4..00000000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,17 +0,0 @@ -## Type of change - -- [ ] Bug fix (non-breaking change which fixes an issue) -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Improvement (refactoring and improving code) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) -- [ ] Documentation update - -## Description - - -## Additional context - 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/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index a51f37eb0eb..00000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,28 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "bundler" - directory: "/" - schedule: - interval: "weekly" - - package-ecosystem: "npm" - directory: "/" - versioning-strategy: increase - groups: - prod-deps: - dependency-type: production - dev-deps: - dependency-type: development - schedule: - interval: "weekly" - - package-ecosystem: "github-actions" - directory: "/" - groups: - gh-actions: - update-types: - - "major" - schedule: - interval: "weekly" - - package-ecosystem: "devcontainers" - directory: "/" - schedule: - interval: weekly diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index 4f2da0e3683..00000000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CD - -on: - push: - branches: - - production - tags-ignore: - - "**" - -jobs: - release: - permissions: - contents: write - issues: write - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.3 - bundler-cache: true - - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - - run: npm install - - run: npx semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} - - publish: - needs: release - uses: ./.github/workflows/publish.yml - secrets: - GH_PAT: ${{ secrets.GH_PAT }} - BUILDER: ${{ secrets.BUILDER }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 50a158b10a9..00000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: "CI" -on: - push: - branches: - - "master" - - "hotfix/**" - paths-ignore: - - ".github/**" - - "!.github/workflows/ci.yml" - - ".gitignore" - - "docs/**" - - "README.md" - - "LICENSE" - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - ruby: ["3.1", "3.2", "3.3"] - - 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 - with: - node-version: lts/* - - - name: Build Assets - run: npm i && npm run build - - - name: Test Site - run: bash tools/test.sh diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 06feb7fd69a..00000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: ["master"] - 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/commitlint.yml b/.github/workflows/commitlint.yml deleted file mode 100644 index c9c48c33f97..00000000000 --- a/.github/workflows/commitlint.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: Lint Commit Messages -on: pull_request - -jobs: - commitlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: wagoid/commitlint-github-action@v6 diff --git a/.github/workflows/starter/pages-deploy.yml b/.github/workflows/pages-deploy.yml similarity index 100% rename from .github/workflows/starter/pages-deploy.yml rename to .github/workflows/pages-deploy.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 99114ea3cb6..00000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Publish - -on: - push: - branches: - - docs - workflow_call: - secrets: - GH_PAT: - required: true - BUILDER: - required: true - -jobs: - launch: - runs-on: ubuntu-latest - steps: - - run: | - curl -X POST -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GH_PAT }}" \ - https://api.github.com/repos/${{ secrets.BUILDER }}/dispatches \ - -d '{"event_type":"deploy", "client_payload":{"branch": "${{ github.ref_name }}"}}' 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 f84f3bcc432..00000000000 --- a/.github/workflows/style-lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: "Style Lint" - -on: - push: - branches: ["master", "hotfix/**"] - 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 - with: - node-version: lts/* - - run: npm i - - run: npm test diff --git a/_config.yml b/_config.yml index 7a9b11a37d7..9f75866fb9f 100644 --- a/_config.yml +++ b/_config.yml @@ -9,7 +9,7 @@ theme: jekyll-theme-chirpy lang: en # Change to your timezone › https://kevinnovak.github.io/Time-Zone-Picker -timezone: Asia/Shanghai +timezone: # jekyll-seo-tag settings › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/usage.md # ↓ -------------------------- @@ -95,10 +95,10 @@ theme_mode: # [light | dark] # will be added to all media resources (site avatar, posts' images, audio and video files) paths starting with '/' # # e.g. 'https://cdn.com' -cdn: "https://chirpy-img.netlify.app" +cdn: # the avatar on sidebar, support local or CORS resources -avatar: "/commons/avatar.jpg" +avatar: # 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. diff --git a/_posts/2019-08-08-text-and-typography.md b/_posts/2019-08-08-text-and-typography.md deleted file mode 100644 index a8db26a00ff..00000000000 --- a/_posts/2019-08-08-text-and-typography.md +++ /dev/null @@ -1,200 +0,0 @@ ---- -title: Text and Typography -description: Examples of text, typography, math equations, diagrams, flowcharts, pictures, videos, and more. -author: cotes -date: 2019-08-08 11:33:00 +0800 -categories: [Blogging, Demo] -tags: [typography] -pin: true -math: true -mermaid: true -image: - path: /commons/devices-mockup.png - lqip: data:image/webp;base64,UklGRpoAAABXRUJQVlA4WAoAAAAQAAAADwAABwAAQUxQSDIAAAARL0AmbZurmr57yyIiqE8oiG0bejIYEQTgqiDA9vqnsUSI6H+oAERp2HZ65qP/VIAWAFZQOCBCAAAA8AEAnQEqEAAIAAVAfCWkAALp8sF8rgRgAP7o9FDvMCkMde9PK7euH5M1m6VWoDXf2FkP3BqV0ZYbO6NA/VFIAAAA - alt: Responsive rendering of Chirpy theme on multiple devices. ---- - -## Headings - - - -# H1 — heading -{: .mt-4 .mb-0 } - -## H2 — heading -{: data-toc-skip='' .mt-4 .mb-0 } - -### H3 — heading -{: data-toc-skip='' .mt-4 .mb-0 } - -#### H4 — heading -{: data-toc-skip='' .mt-4 } - - -## Paragraph - -Quisque egestas convallis ipsum, ut sollicitudin risus tincidunt a. Maecenas interdum malesuada egestas. Duis consectetur porta risus, sit amet vulputate urna facilisis ac. Phasellus semper dui non purus ultrices sodales. Aliquam ante lorem, ornare a feugiat ac, finibus nec mauris. Vivamus ut tristique nisi. Sed vel leo vulputate, efficitur risus non, posuere mi. Nullam tincidunt bibendum rutrum. Proin commodo ornare sapien. Vivamus interdum diam sed sapien blandit, sit amet aliquam risus mattis. Nullam arcu turpis, mollis quis laoreet at, placerat id nibh. Suspendisse venenatis eros eros. - -## Lists - -### Ordered list - -1. Firstly -2. Secondly -3. Thirdly - -### Unordered list - -- Chapter - - Section - - Paragraph - -### ToDo list - -- [ ] Job - - [x] Step 1 - - [x] Step 2 - - [ ] Step 3 - -### Description list - -Sun -: the star around which the earth orbits - -Moon -: the natural satellite of the earth, visible by reflected light from the sun - -## Block Quote - -> This line shows the _block quote_. - -## Prompts - - - -> An example showing the `tip` type prompt. -{: .prompt-tip } - -> An example showing the `info` type prompt. -{: .prompt-info } - -> An example showing the `warning` type prompt. -{: .prompt-warning } - -> An example showing the `danger` type prompt. -{: .prompt-danger } - - -## Tables - -| Company | Contact | Country | -| :--------------------------- | :--------------- | ------: | -| Alfreds Futterkiste | Maria Anders | Germany | -| Island Trading | Helen Bennett | UK | -| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy | - -## Links - - - -## Footnote - -Click the hook will locate the footnote[^footnote], and here is another footnote[^fn-nth-2]. - -## Inline code - -This is an example of `Inline Code`. - -## Filepath - -Here is the `/path/to/the/file.extend`{: .filepath}. - -## Code blocks - -### Common - -```text -This is a common code snippet, without syntax highlight and line number. -``` - -### Specific Language - -```bash -if [ $? -ne 0 ]; then - echo "The command was not successful."; - #do the needful / exit -fi; -``` - -### Specific filename - -```sass -@import - "colors/light-typography", - "colors/dark-typography"; -``` -{: file='_sass/jekyll-theme-chirpy.scss'} - -## Mathematics - -The mathematics powered by [**MathJax**](https://www.mathjax.org/): - -$$ -\begin{equation} - \sum_{n=1}^\infty 1/n^2 = \frac{\pi^2}{6} - \label{eq:series} -\end{equation} -$$ - -We can reference the equation as \eqref{eq:series}. - -When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are - -$$ x = {-b \pm \sqrt{b^2-4ac} \over 2a} $$ - -## Mermaid SVG - -```mermaid - gantt - title Adding GANTT diagram functionality to mermaid - apple :a, 2017-07-20, 1w - banana :crit, b, 2017-07-23, 1d - cherry :active, c, after b a, 1d -``` - -## Images - -### Default (with caption) - -![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" } -_Full screen width and center alignment_ - -### Left aligned - -![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-75 .normal} - -### Float to left - -![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .left} -Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum. - -### Float to right - -![Desktop View](/posts/20190808/mockup.png){: width="972" height="589" .w-50 .right} -Praesent maximus aliquam sapien. Sed vel neque in dolor pulvinar auctor. Maecenas pharetra, sem sit amet interdum posuere, tellus lacus eleifend magna, ac lobortis felis ipsum id sapien. Proin ornare rutrum metus, ac convallis diam volutpat sit amet. Phasellus volutpat, elit sit amet tincidunt mollis, felis mi scelerisque mauris, ut facilisis leo magna accumsan sapien. In rutrum vehicula nisl eget tempor. Nullam maximus ullamcorper libero non maximus. Integer ultricies velit id convallis varius. Praesent eu nisl eu urna finibus ultrices id nec ex. Mauris ac mattis quam. Fusce aliquam est nec sapien bibendum, vitae malesuada ligula condimentum. - -### Dark/Light mode & Shadow - -The image below will toggle dark/light mode based on theme preference, notice it has shadows. - -![light mode only](/posts/20190808/devtools-light.png){: .light .w-75 .shadow .rounded-10 w='1212' h='668' } -![dark mode only](/posts/20190808/devtools-dark.png){: .dark .w-75 .shadow .rounded-10 w='1212' h='668' } - -## Video - -{% include embed/youtube.html id='Balreaj8Yqs' %} - -## Reverse Footnote - -[^footnote]: The footnote source -[^fn-nth-2]: The 2nd footnote source diff --git a/_posts/2019-08-08-write-a-new-post.md b/_posts/2019-08-08-write-a-new-post.md deleted file mode 100644 index 69eaf34acbe..00000000000 --- a/_posts/2019-08-08-write-a-new-post.md +++ /dev/null @@ -1,505 +0,0 @@ ---- -title: Writing a New Post -author: cotes -date: 2019-08-08 14:10:00 +0800 -categories: [Blogging, Tutorial] -tags: [writing] -render_with_liquid: false ---- - -This tutorial will guide you how to write a post in the _Chirpy_ template, and it's worth reading even if you've used Jekyll before, as many features require specific variables to be set. - -## Naming and Path - -Create a new file named `YYYY-MM-DD-TITLE.EXTENSION`{: .filepath} and put it in the `_posts`{: .filepath} of the root directory. Please note that the `EXTENSION`{: .filepath} must be one of `md`{: .filepath} and `markdown`{: .filepath}. If you want to save time of creating files, please consider using the plugin [`Jekyll-Compose`](https://github.com/jekyll/jekyll-compose) to accomplish this. - -## Front Matter - -Basically, you need to fill the [Front Matter](https://jekyllrb.com/docs/front-matter/) as below at the top of the post: - -```yaml ---- -title: TITLE -date: YYYY-MM-DD HH:MM:SS +/-TTTT -categories: [TOP_CATEGORIE, SUB_CATEGORIE] -tags: [TAG] # TAG names should always be lowercase ---- -``` - -> The posts' _layout_ has been set to `post` by default, so there is no need to add the variable _layout_ in the Front Matter block. -{: .prompt-tip } - -### Timezone of Date - -To accurately record the release date of a post, you should not only set up the `timezone` of `_config.yml`{: .filepath} but also provide the post's timezone in variable `date` of its Front Matter block. Format: `+/-TTTT`, e.g. `+0800`. - -### Categories and Tags - -The `categories` of each post are designed to contain up to two elements, and the number of elements in `tags` can be zero to infinity. For instance: - -```yaml ---- -categories: [Animal, Insect] -tags: [bee] ---- -``` - -### Author Information - -The author information of the post usually does not need to be filled in the _Front Matter_ , they will be obtained from variables `social.name` and the first entry of `social.links` of the configuration file by default. But you can also override it as follows: - -Adding author information in `_data/authors.yml` (If your website doesn't have this file, don't hesitate to create one). - -```yaml -: - name: - twitter: - url: -``` -{: file="_data/authors.yml" } - -And then use `author` to specify a single entry or `authors` to specify multiple entries: - -```yaml ---- -author: # for single entry -# or -authors: [, ] # for multiple entries ---- -``` - -Having said that, the key `author` can also identify multiple entries. - -> The benefit of reading the author information from the file `_data/authors.yml`{: .filepath } is that the page will have the meta tag `twitter:creator`, which enriches the [Twitter Cards](https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started#card-and-content-attribution) and is good for SEO. -{: .prompt-info } - -### Post Description - -By default, the first words of the post are used to display on the home page for a list of posts, in the _Further Reading_ section, and in the XML of the RSS feed. If you don't want to display the auto-generated description for the post, you can customize it using the `description` field in the _Front Matter_ as follows: - -```yaml ---- -description: Short summary of the post. ---- -``` - -Additionally, the `description` text will also be displayed under the post title on the post's page. - -## Table of Contents - -By default, the **T**able **o**f **C**ontents (TOC) is displayed on the right panel of the post. If you want to turn it off globally, go to `_config.yml`{: .filepath} and set the value of variable `toc` to `false`. If you want to turn off TOC for a specific post, add the following to the post's [Front Matter](https://jekyllrb.com/docs/front-matter/): - -```yaml ---- -toc: false ---- -``` - -## Comments - -The global switch of comments is defined by variable `comments.active` in the file `_config.yml`{: .filepath}. After selecting a comment system for this variable, comments will be turned on for all posts. - -If you want to close the comment for a specific post, add the following to the **Front Matter** of the post: - -```yaml ---- -comments: false ---- -``` - -## Media - -We refer to images, audio and video as media resources in _Chirpy_. - -### URL Prefix - -From time to time we have to define duplicate URL prefixes for multiple resources in a post, which is a boring task that you can avoid by setting two parameters. - -- If you are using a CDN to host media files, you can specify the `cdn` in `_config.yml`{: .filepath }. The URLs of media resources for site avatar and posts are then prefixed with the CDN domain name. - - ```yaml - cdn: https://cdn.com - ``` - {: file='_config.yml' .nolineno } - -- To specify the resource path prefix for the current post/page range, set `media_subpath` in the _front matter_ of the post: - - ```yaml - --- - media_subpath: /path/to/media/ - --- - ``` - {: .nolineno } - -The option `site.cdn` and `page.media_subpath` can be used individually or in combination to flexibly compose the final resource URL: `[site.cdn/][page.media_subpath/]file.ext` - -### Images - -#### Caption - -Add italics to the next line of an image, then it will become the caption and appear at the bottom of the image: - -```markdown -![img-description](/path/to/image) -_Image Caption_ -``` -{: .nolineno} - -#### Size - -To prevent the page content layout from shifting when the image is loaded, we should set the width and height for each image. - -```markdown -![Desktop View](/assets/img/sample/mockup.png){: width="700" height="400" } -``` -{: .nolineno} - -> For an SVG, you have to at least specify its _width_, otherwise it won't be rendered. -{: .prompt-info } - -Starting from _Chirpy v5.0.0_, `height` and `width` support abbreviations (`height` → `h`, `width` → `w`). The following example has the same effect as the above: - -```markdown -![Desktop View](/assets/img/sample/mockup.png){: w="700" h="400" } -``` -{: .nolineno} - -#### Position - -By default, the image is centered, but you can specify the position by using one of the classes `normal`, `left`, and `right`. - -> Once the position is specified, the image caption should not be added. -{: .prompt-warning } - -- **Normal position** - - Image will be left aligned in below sample: - - ```markdown - ![Desktop View](/assets/img/sample/mockup.png){: .normal } - ``` - {: .nolineno} - -- **Float to the left** - - ```markdown - ![Desktop View](/assets/img/sample/mockup.png){: .left } - ``` - {: .nolineno} - -- **Float to the right** - - ```markdown - ![Desktop View](/assets/img/sample/mockup.png){: .right } - ``` - {: .nolineno} - -#### Dark/Light mode - -You can make images follow theme preferences in dark/light mode. This requires you to prepare two images, one for dark mode and one for light mode, and then assign them a specific class (`dark` or `light`): - -```markdown -![Light mode only](/path/to/light-mode.png){: .light } -![Dark mode only](/path/to/dark-mode.png){: .dark } -``` - -#### Shadow - -The screenshots of the program window can be considered to show the shadow effect: - -```markdown -![Desktop View](/assets/img/sample/mockup.png){: .shadow } -``` -{: .nolineno} - -#### Preview Image - -If you want to add an image at the top of the post, please provide an image with a resolution of `1200 x 630`. Please note that if the image aspect ratio does not meet `1.91 : 1`, the image will be scaled and cropped. - -Knowing these prerequisites, you can start setting the image's attribute: - -```yaml ---- -image: - path: /path/to/image - alt: image alternative text ---- -``` - -Note that the [`media_subpath`](#url-prefix) can also be passed to the preview image, that is, when it has been set, the attribute `path` only needs the image file name. - -For simple use, you can also just use `image` to define the path. - -```yml ---- -image: /path/to/image ---- -``` - -#### LQIP - -For preview images: - -```yaml ---- -image: - lqip: /path/to/lqip-file # or base64 URI ---- -``` - -> You can observe LQIP in the preview image of post \"[Text and Typography](../text-and-typography/)\". - -For normal images: - -```markdown -![Image description](/path/to/image){: lqip="/path/to/lqip-file" } -``` -{: .nolineno } - -### Video - -#### Social Media Platform - -You can embed videos from social media platforms with the following syntax: - -```liquid -{% include embed/{Platform}.html id='{ID}' %} -``` - -Where `Platform` is the lowercase of the platform name, and `ID` is the video ID. - -The following table shows how to get the two parameters we need in a given video URL, and you can also know the currently supported video platforms. - -| Video URL | Platform | ID | -| -------------------------------------------------------------------------------------------------- | ---------- | :------------- | -| [https://www.**youtube**.com/watch?v=**H-B46URT4mg**](https://www.youtube.com/watch?v=H-B46URT4mg) | `youtube` | `H-B46URT4mg` | -| [https://www.**twitch**.tv/videos/**1634779211**](https://www.twitch.tv/videos/1634779211) | `twitch` | `1634779211` | -| [https://www.**bilibili**.com/video/**BV1Q44y1B7Wf**](https://www.bilibili.com/video/BV1Q44y1B7Wf) | `bilibili` | `BV1Q44y1B7Wf` | - -#### Video Files - -If you want to embed a video file directly, use the following syntax: - -```liquid -{% include embed/video.html src='{URL}' %} -``` - -Where `URL` is a URL to a video file e.g. `/path/to/sample/video.mp4`. - -You can also specify additional attributes for the embedded video file. Here is a full list of attributes allowed. - -- `poster='/path/to/poster.png'` — poster image for a video that is shown while video is downloading -- `title='Text'` — title for a video that appears below the video and looks same as for images -- `autoplay=true` — video automatically begins to play back as soon as it can -- `loop=true` — automatically seek back to the start upon reaching the end of the video -- `muted=true` — audio will be initially silenced -- `types` — specify the extensions of additional video formats separated by `|`. Ensure these files exist in the same directory as your primary video file. - -Consider an example using all of the above: - -```liquid -{% - include embed/video.html - src='/path/to/video.mp4' - types='ogg|mov' - poster='poster.png' - title='Demo video' - autoplay=true - loop=true - muted=true -%} -``` - -### Audios - -If you want to embed an audio file directly, use the following syntax: - -```liquid -{% include embed/audio.html src='{URL}' %} -``` - -Where `URL` is a URL to an audio file e.g. `/path/to/audio.mp3`. - -You can also specify additional attributes for the embedded audio file. Here is a full list of attributes allowed. - -- `title='Text'` — title for an audio that appears below the audio and looks same as for images -- `types` — specify the extensions of additional audio formats separated by `|`. Ensure these files exist in the same directory as your primary audio file. - -Consider an example using all of the above: - -```liquid -{% - include embed/audio.html - src='/path/to/audio.mp3' - types='ogg|wav|aac' - title='Demo audio' -%} -``` - -## Pinned Posts - -You can pin one or more posts to the top of the home page, and the fixed posts are sorted in reverse order according to their release date. Enable by: - -```yaml ---- -pin: true ---- -``` - -## Prompts - -There are several types of prompts: `tip`, `info`, `warning`, and `danger`. They can be generated by adding the class `prompt-{type}` to the blockquote. For example, define a prompt of type `info` as follows: - -```md -> Example line for prompt. -{: .prompt-info } -``` -{: .nolineno } - -## Syntax - -### Inline Code - -```md -`inline code part` -``` -{: .nolineno } - -### Filepath Highlight - -```md -`/path/to/a/file.extend`{: .filepath} -``` -{: .nolineno } - -### Code Block - -Markdown symbols ```` ``` ```` can easily create a code block as follows: - -````md -``` -This is a plaintext code snippet. -``` -```` - -#### Specifying Language - -Using ```` ```{language} ```` you will get a code block with syntax highlight: - -````markdown -```yaml -key: value -``` -```` - -> The Jekyll tag `{% highlight %}` is not compatible with this theme. -{: .prompt-danger } - -#### Line Number - -By default, all languages except `plaintext`, `console`, and `terminal` will display line numbers. When you want to hide the line number of a code block, add the class `nolineno` to it: - -````markdown -```shell -echo 'No more line numbers!' -``` -{: .nolineno } -```` - -#### Specifying the Filename - -You may have noticed that the code language will be displayed at the top of the code block. If you want to replace it with the file name, you can add the attribute `file` to achieve this: - -````markdown -```shell -# content -``` -{: file="path/to/file" } -```` - -#### Liquid Codes - -If you want to display the **Liquid** snippet, surround the liquid code with `{% raw %}` and `{% endraw %}`: - -````markdown -{% raw %} -```liquid -{% if product.title contains 'Pack' %} - This product's title contains the word Pack. -{% endif %} -``` -{% endraw %} -```` - -Or adding `render_with_liquid: false` (Requires Jekyll 4.0 or higher) to the post's YAML block. - -## Mathematics - -We use [**MathJax**][mathjax] to generate mathematics. For website performance reasons, the mathematical feature won't be loaded by default. But it can be enabled by: - -[mathjax]: https://www.mathjax.org/ - -```yaml ---- -math: true ---- -``` - -After enabling the mathematical feature, you can add math equations with the following syntax: - -- **Block math** should be added with `$$ math $$` with **mandatory** blank lines before and after `$$` - - **Inserting equation numbering** should be added with `$$\begin{equation} math \end{equation}$$` - - **Referencing equation numbering** should be done with `\label{eq:label_name}` in the equation block and `\eqref{eq:label_name}` inline with text (see example below) -- **Inline math** (in lines) should be added with `$$ math $$` without any blank line before or after `$$` -- **Inline math** (in lists) should be added with `\$$ math $$` - -```markdown - - -$$ -LaTeX_math_expression -$$ - - - -$$ -\begin{equation} - LaTeX_math_expression - \label{eq:label_name} -\end{equation} -$$ - -Can be referenced as \eqref{eq:label_name}. - - - -"Lorem ipsum dolor sit amet, $$ LaTeX_math_expression $$ consectetur adipiscing elit." - - - -1. \$$ LaTeX_math_expression $$ -2. \$$ LaTeX_math_expression $$ -3. \$$ LaTeX_math_expression $$ -``` - -> Starting with `v7.0.0`, configuration options for **MathJax** have been moved to file `assets/js/data/mathjax.js`{: .filepath }, and you can change the options as needed, such as adding [extensions][mathjax-exts]. -> If you are building the site via `chirpy-starter`, copy that file from the gem installation directory (check with command `bundle info --path jekyll-theme-chirpy`) to the same directory in your repository. -{: .prompt-tip } - -[mathjax-exts]: https://docs.mathjax.org/en/latest/input/tex/extensions/index.html - -## Mermaid - -[**Mermaid**](https://github.com/mermaid-js/mermaid) is a great diagram generation tool. To enable it on your post, add the following to the YAML block: - -```yaml ---- -mermaid: true ---- -``` - -Then you can use it like other markdown languages: surround the graph code with ```` ```mermaid ```` and ```` ``` ````. - -## Learn More - -For more knowledge about Jekyll posts, visit the [Jekyll Docs: Posts](https://jekyllrb.com/docs/posts/). diff --git a/_posts/2019-08-09-getting-started.md b/_posts/2019-08-09-getting-started.md deleted file mode 100644 index 3b41a3cabe4..00000000000 --- a/_posts/2019-08-09-getting-started.md +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: Getting Started -description: >- - Get started with Chirpy basics in this comprehensive overview. - You will learn how to install, configure, and use your first Chirpy-based website, as well as deploy it to a web server. -author: cotes -date: 2019-08-09 20:55:00 +0800 -categories: [Blogging, Tutorial] -tags: [getting started] -pin: true -media_subpath: '/posts/20180809' ---- - -## Creating a Site Repository - -When creating your site repository, you have two options depending on your needs: - -### Option 1. Using the Starter (Recommended) - -This approach simplifies upgrades, isolates unnecessary files, and is perfect for users who want to focus on writing with minimal configuration. - -1. Sign in to GitHub and navigate to the [**starter**][starter]. -2. Click the Use this template button and then select Create a new repository. -3. Name the new repository `.github.io`, replacing `username` with your lowercase GitHub username. - -### Option 2. Forking the Theme - -This approach is convenient for modifying features or UI design, but presents challenges during upgrades. So don't try this unless you are familiar with Jekyll and plan to heavily modify this theme. - -1. Sign in to GitHub. -2. [Fork the theme repository](https://github.com/cotes2020/jekyll-theme-chirpy/fork). -3. Name the new repository `.github.io`, replacing `username` with your lowercase GitHub username. - -## Setting up the Environment - -Once your repository is created, it's time to set up your development environment. There are two primary methods: - -### Using Dev Containers (Recommended for Windows) - -Dev Containers offer an isolated environment using Docker, which prevents conflicts with your system and ensures all dependencies are managed within the container. - -**Steps**: - -1. Install Docker: - - On Windows/macOS, install [Docker Desktop][docker-desktop]. - - On Linux, install [Docker Engine][docker-engine]. -2. Install [VS Code][vscode] and the [Dev Containers extension][dev-containers]. -3. Clone your repository: - - For Docker Desktop: Start VS Code and [clone your repo in a container volume][dc-clone-in-vol]. - - For Docker Engine: Clone your repo locally, then [open it in a container][dc-open-in-container] via VS Code. -4. Wait for the Dev Containers setup to complete. - -### Setting up Natively (Recommended for Unix-like OS) - -For Unix-like systems, you can set up the environment natively for optimal performance, though you can also use Dev Containers as an alternative. - -**Steps**: - -1. Follow the [Jekyll installation guide](https://jekyllrb.com/docs/installation/) to install Jekyll and ensure [Git](https://git-scm.com/) is installed. -2. Clone your repository to your local machine. -3. If you forked the theme, install [Node.js][nodejs] and run `bash tools/init.sh` in the root directory to initialize the repository. -4. Run command `bundle` in the root of your repository to install the dependencies. - -## Usage - -### Start the Jekyll Server - -To run the site locally, use the following command: - -```terminal -$ bundle exec jekyll s -``` - -> If you are using Dev Containers, you must run that command in the **VS Code** Terminal. -{: .prompt-info } - -After a few seconds, the local server will be available at . - -### Configuration - -Update the variables in `_config.yml`{: .filepath} as needed. Some typical options include: - -- `url` -- `avatar` -- `timezone` -- `lang` - -### Social Contact Options - -Social contact options are displayed at the bottom of the sidebar. You can enable or disable specific contacts in the `_data/contact.yml`{: .filepath} file. - -### Customizing the Stylesheet - -To customize the stylesheet, copy the theme's `assets/css/jekyll-theme-chirpy.scss`{: .filepath} file to the same path in your Jekyll site, and add your custom styles at the end of the file. - -Starting with version `6.2.0`, if you want to overwrite the SASS variables defined in `_sass/addon/variables.scss`{: .filepath}, copy the main SASS file `_sass/main.scss`{: .filepath} to the `_sass`{: .filepath} directory in your site's source, then create a new file `_sass/variables-hook.scss`{: .filepath} and assign your new values there. - -### Customizing Static Assets - -Static assets configuration was introduced in version `5.1.0`. The CDN of the static assets is defined in `_data/origin/cors.yml`{: .filepath }. You can replace some of them based on the network conditions in the region where your website is published. - -If you prefer to self-host the static assets, refer to the [_chirpy-static-assets_](https://github.com/cotes2020/chirpy-static-assets#readme) repository. - -## Deployment - -Before deploying, check the `_config.yml`{: .filepath} file and ensure the `url` is configured correctly. If you prefer a [**project site**](https://help.github.com/en/github/working-with-github-pages/about-github-pages#types-of-github-pages-sites) and don't use a custom domain, or if you want to visit your website with a base URL on a web server other than **GitHub Pages**, remember to set the `baseurl` to your project name, starting with a slash, e.g., `/project-name`. - -Now you can choose _ONE_ of the following methods to deploy your Jekyll site. - -### Deploy Using Github Actions - -Prepare the following: - -- If you're on the GitHub Free plan, keep your site repository public. -- If you have committed `Gemfile.lock`{: .filepath} to the repository, and your local machine is not running Linux, update the platform list of the lock file: - - ```console - $ bundle lock --add-platform x86_64-linux - ``` - -Next, configure the _Pages_ service: - -1. Go to your repository on GitHub. Select the _Settings_ tab, then click _Pages_ in the left navigation bar. In the **Source** section (under _Build and deployment_), select [**GitHub Actions**][pages-workflow-src] from the dropdown menu. - ![Build source](pages-source-light.png){: .light .border .normal w='375' h='140' } - ![Build source](pages-source-dark.png){: .dark .normal w='375' h='140' } - -2. Push any commits to GitHub to trigger the _Actions_ workflow. In the _Actions_ tab of your repository, you should see the workflow _Build and Deploy_ running. Once the build is complete and successful, the site will be deployed automatically. - -You can now visit the URL provided by GitHub to access your site. - -### Manual Build and Deployment - -For self-hosted servers, you will need to build the site on your local machine and then upload the site files to the server. - -Navigate to the root of the source project, and build your site with the following command: - -```console -$ JEKYLL_ENV=production bundle exec jekyll b -``` - -Unless you specified the output path, the generated site files will be placed in the `_site`{: .filepath} folder of the project's root directory. Upload these files to your target server. - -[nodejs]: https://nodejs.org/ -[starter]: https://github.com/cotes2020/chirpy-starter -[pages-workflow-src]: https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow -[docker-desktop]: https://www.docker.com/products/docker-desktop/ -[docker-engine]: https://docs.docker.com/engine/install/ -[vscode]: https://code.visualstudio.com/ -[dev-containers]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers -[dc-clone-in-vol]: https://code.visualstudio.com/docs/devcontainers/containers#_quick-start-open-a-git-repository-or-github-pr-in-an-isolated-container-volume -[dc-open-in-container]: https://code.visualstudio.com/docs/devcontainers/containers#_quick-start-open-an-existing-folder-in-a-container diff --git a/_posts/2019-08-11-customize-the-favicon.md b/_posts/2019-08-11-customize-the-favicon.md deleted file mode 100644 index a3278fa90eb..00000000000 --- a/_posts/2019-08-11-customize-the-favicon.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: Customize the Favicon -author: cotes -date: 2019-08-11 00:34:00 +0800 -categories: [Blogging, Tutorial] -tags: [favicon] ---- - -The [favicons](https://www.favicon-generator.org/about/) of [**Chirpy**](https://github.com/cotes2020/jekyll-theme-chirpy/) are placed in the directory `assets/img/favicons/`{: .filepath}. You may want to replace them with your own. The following sections will guide you to create and replace the default favicons. - -## Generate the favicon - -Prepare a square image (PNG, JPG, or SVG) with a size of 512x512 or more, and then go to the online tool [**Real Favicon Generator**](https://realfavicongenerator.net/) and click the button Select your Favicon image to upload your image file. - -In the next step, the webpage will show all usage scenarios. You can keep the default options, scroll to the bottom of the page, and click the button Generate your Favicons and HTML code to generate the favicon. - -## Download & Replace - -Download the generated package, unzip and delete the following two from the extracted files: - -- `browserconfig.xml`{: .filepath} -- `site.webmanifest`{: .filepath} - -And then copy the remaining image files (`.PNG`{: .filepath} and `.ICO`{: .filepath}) to cover the original files in the directory `assets/img/favicons/`{: .filepath} of your Jekyll site. If your Jekyll site doesn't have this directory yet, just create one. - -The following table will help you understand the changes to the favicon files: - -| File(s) | From Online Tool | From Chirpy | -|---------------------|:---------------------------------:|:-----------:| -| `*.PNG` | ✓ | ✗ | -| `*.ICO` | ✓ | ✗ | - - -> ✓ means keep, ✗ means delete. -{: .prompt-info } - -The next time you build the site, the favicon will be replaced with a customized edition. diff --git a/tools/init.sh b/tools/init.sh deleted file mode 100755 index 2ad72ab9bea..00000000000 --- a/tools/init.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env bash -# -# Init the environment for new user. - -set -eu - -# CLI Dependencies -CLI=("git" "npm") - -ACTIONS_WORKFLOW=pages-deploy.yml - -RELEASE_HASH=$(git log --grep="chore(release):" -1 --pretty="%H") - -# temporary file suffixes that make `sed -i` compatible with BSD and Linux -TEMP_SUFFIX="to-delete" - -_no_gh=false - -help() { - echo "Usage:" - echo - echo " bash /path/to/init [options]" - echo - echo "Options:" - echo " --no-gh Do not deploy to Github." - echo " -h, --help Print this help information." -} - -# BSD and GNU compatible sed -_sedi() { - regex=$1 - file=$2 - sed -i.$TEMP_SUFFIX -E "$regex" "$file" - rm -f "$file".$TEMP_SUFFIX -} - -_check_cli() { - for i in "${!CLI[@]}"; do - cli="${CLI[$i]}" - if ! command -v "$cli" &>/dev/null; then - echo "Command '$cli' not found! Hint: you should install it." - exit 1 - fi - done -} - -_check_status() { - if [[ -n $(git status . -s) ]]; then - echo "Error: Commit unstaged files first, and then run this tool again." - exit 1 - fi -} - -_check_init() { - if [[ $(git rev-parse HEAD^1) == "$RELEASE_HASH" ]]; then - echo "Already initialized." - exit 0 - fi -} - -check_env() { - _check_cli - _check_status - _check_init -} - -reset_latest() { - git reset --hard "$RELEASE_HASH" - git clean -fd - git submodule update --init --recursive -} - -init_files() { - if $_no_gh; then - rm -rf .github - else - ## Change the files of `.github/` - temp="$(mktemp -d)" - find .github/workflows -type f -name "*$ACTIONS_WORKFLOW*" -exec mv {} "$temp/$ACTIONS_WORKFLOW" \; - rm -rf .github && mkdir -p .github/workflows - mv "$temp/$ACTIONS_WORKFLOW" .github/workflows/"$ACTIONS_WORKFLOW" - rm -rf "$temp" - fi - - # Cleanup image settings in site config - _sedi "s/(^timezone:).*/\1/;s/(^.*cdn:).*/\1/;s/(^avatar:).*/\1/" _config.yml - - # remove the other files - rm -rf tools/init.sh tools/release.sh _posts/* - - # build assets - npm i && npm run build - - # track the CSS/JS output - _sedi "/.*\/dist$/d" .gitignore -} - -commit() { - git add -A - git commit -m "chore: initialize the environment" -q - echo -e "\n> Initialization successful!\n" -} - -main() { - check_env - reset_latest - init_files - commit -} - -while (($#)); do - opt="$1" - case $opt in - --no-gh) - _no_gh=true - shift - ;; - -h | --help) - help - exit 0 - ;; - *) - # unknown option - help - exit 1 - ;; - esac -done - -main diff --git a/tools/release.sh b/tools/release.sh deleted file mode 100755 index 522c892c827..00000000000 --- a/tools/release.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env bash -# -# Requires: Git, NPM and RubyGems - -set -eu - -opt_pre=false # option for bump gem version -opt_pkg=false # option for building gem package - -MAIN_BRANCH="master" -RELEASE_BRANCH="production" - -GEM_SPEC="jekyll-theme-chirpy.gemspec" -NODE_SPEC="package.json" -CHANGELOG="docs/CHANGELOG.md" -CONFIG="_config.yml" - -CSS_DIST="_sass/dist" -JS_DIST="assets/js/dist" - -FILES=( - "$GEM_SPEC" - "$NODE_SPEC" - "$CHANGELOG" - "$CONFIG" -) - -TOOLS=( - "git" - "npm" - "gem" -) - -help() { - echo -e "A tool to release new version Chirpy gem.\nThis tool will:" - echo " 1. Build a new gem and publish it to RubyGems.org" - echo " 2. Merge the release branch into the default branch" - echo - echo "Usage:" - echo " bash $0 [options]" - echo - echo "Options:" - echo " --prepare Preparation for release" - echo " -p, --package Build a gem package only, for local packaging in case of auto-publishing failure" - echo " -h, --help Display this help message" -} - -_check_cli() { - for i in "${!TOOLS[@]}"; do - cli="${TOOLS[$i]}" - if ! command -v "$cli" &>/dev/null; then - echo "> Command '$cli' not found!" - exit 1 - fi - done -} - -_check_git() { - $opt_pre || ( - # ensure that changes have been committed - if [[ -n $(git status . -s) ]]; then - echo "> Abort: Commit the staged files first, and then run this tool again." - exit 1 - fi - ) - - $opt_pkg || ( - if [[ "$(git branch --show-current)" != "$RELEASE_BRANCH" ]]; then - echo "> Abort: Please run the tool in the '$RELEASE_BRANCH' branch." - exit 1 - fi - ) -} - -_check_src() { - for i in "${!FILES[@]}"; do - _src="${FILES[$i]}" - if [[ ! -f $_src && ! -d $_src ]]; then - echo -e "> Error: Missing file \"$_src\"!\n" - exit 1 - fi - done -} - -init() { - _check_cli - _check_git - _check_src - echo -e "> npm install\n" - npm i -} - -## Bump new version to gem-spec file -_bump_version() { - _version="$(grep '"version":' "$NODE_SPEC" | sed 's/.*: "//;s/".*//')" - sed -i "s/[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+/$_version/" "$GEM_SPEC" - echo "> Bump gem version to $_version" -} - -_improve_changelog() { - # Replace multiple empty lines with a single empty line - sed -i '/^$/N;/^\n$/D' "$CHANGELOG" - # Escape left angle brackets of HTML tag in the changelog as they break the markdown structure. e.g., '
' - sed -i -E 's/\s(<[a-z])/ \\\1/g' "$CHANGELOG" -} - -prepare() { - _bump_version - _improve_changelog -} - -## Build a Gem package -build_gem() { - # Remove unnecessary theme settings - sed -i -E "s/(^timezone:).*/\1/;s/(^cdn:).*/\1/;s/(^avatar:).*/\1/" $CONFIG - rm -f ./*.gem - - npm run build - # add CSS/JS distribution files to gem package - git add "$CSS_DIST" "$JS_DIST" -f - - echo -e "\n> gem build $GEM_SPEC\n" - gem build "$GEM_SPEC" - - echo -e "\n> Resume file changes ...\n" - git reset - git checkout . -} - -# Push the gem to RubyGems.org (using $GEM_HOST_API_KEY) -push_gem() { - gem push ./*.gem -} - -## Merge the release branch into the default branch -merge() { - git fetch origin "$MAIN_BRANCH" - git checkout -b "$MAIN_BRANCH" origin/"$MAIN_BRANCH" - - git merge --no-ff --no-edit "$RELEASE_BRANCH" || ( - git merge --abort - echo -e "\n> Conflict detected. Aborting merge.\n" - exit 0 - ) - - git push origin "$MAIN_BRANCH" -} - -main() { - init - - if $opt_pre; then - prepare - exit 0 - fi - - build_gem - $opt_pkg && exit 0 - push_gem - merge -} - -while (($#)); do - opt="$1" - case $opt in - --prepare) - opt_pre=true - shift - ;; - -p | --package) - opt_pkg=true - shift - ;; - -h | --help) - help - exit 0 - ;; - *) - # unknown option - help - exit 1 - ;; - esac -done - -main