Skip to content

Commit

Permalink
Merge branch "main" at upstream "welpo/tabi"
Browse files Browse the repository at this point in the history
  • Loading branch information
Smtbook committed Mar 1, 2024
2 parents a54110a + 4aaa234 commit 324b7d6
Show file tree
Hide file tree
Showing 348 changed files with 17,937 additions and 1,177 deletions.
25 changes: 25 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Commit-msg hook generated by git-sumi.
# For more information and documentation, visit: https://sumi.rs

set -e # Exit on any error.

# Get the current branch name.
current_branch=$(git rev-parse --abbrev-ref HEAD)

# Check if the current branch is 'main'.
if [ "$current_branch" != "main" ]; then
exit 0 # Exit successfully without running git-sumi.
fi

# Check if git-sumi is installed.
if ! command -v git-sumi &> /dev/null
then
echo "git-sumi is not installed. Please install it. See https://sumi.rs for instructions."
echo "Alternatively, edit or remove the commit-msg hook in .git/hooks/commit-msg."
exit 1
fi

# Run git-sumi on the commit message if on the 'main' branch.
git-sumi -- "$(cat $1)" # Exit with error if linting fails.
36 changes: 25 additions & 11 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Updates the "updated" field in the front matter of .md files. #
# Compresses PNG files with either oxipng or optipng if available. #
# Runs subset_font if config.toml has been modified. #
# Updates the README if the line numbers for the language section have changed. #
# #
# Stops you from commiting: #
# - a draft .md file #
Expand Down Expand Up @@ -75,12 +74,12 @@ function generate_and_commit_card {
echo "Failed to update social media card for $file"
exit 1
}

git add "$social_media_card" || {
echo "Failed to add social media card $social_media_card"
exit 1
}

git add "$file" || {
echo "Failed to add $file"
exit 1
Expand All @@ -98,21 +97,27 @@ function has_minified_version() {

function is_minified() {
local file="$1"


# Check if terser and uglifyjs are installed.
if ! command -v terser &> /dev/null || ! command -v uglifyjs &> /dev/null; then
echo "Either terser or uglifyjs is not installed. Skipping minification check."
return 0
fi

# Original file size.
local original_size=$(wc -c < "$file")

# File size after compression with terser.
local terser_size=$(terser --compress --mangle -- "$file" | wc -c)

# File size after compression with uglifyjs.
local uglifyjs_size=$(uglifyjs --compress --mangle -- "$file" | wc -c)

# Check if the file is already as small as or smaller than both minified versions.
if (( original_size <= terser_size && original_size <= uglifyjs_size )); then
return 0
fi

# If the file isn't as small as it can be, suggest the better compressor in the error message
if (( terser_size < uglifyjs_size )); then
error_exit "Minified JS file $file isn't as small as it can be! Try using terser for better compression."
Expand Down Expand Up @@ -146,10 +151,13 @@ fi
# Get the newly added and modified files.
all_changed_files=$(git diff --cached --name-only --diff-filter=AM)

script_name=$(basename "$0")
# Loop through all newly added or modified files.
for file in $all_changed_files; do
# Ignore this script.
if [[ "$file" == "$0" ]]; then
file_name=$(basename "$file")

# Ignore this script and the changelog.
if [[ "$file_name" == "$script_name" ]] || [[ "$file_name" == "CHANGELOG.md" ]]; then
continue
fi

Expand Down Expand Up @@ -250,14 +258,20 @@ done
# Use `social-cards-zola` to create/update the social media card for Markdown files.
# See https://osc.garden/blog/automating-social-media-cards-zola/ for context.
# Use parallel to create the social media cards in parallel and commit them.
echo "$modified_md_files" | parallel -j 8 generate_and_commit_card
# echo "$modified_md_files" | parallel -j 8 generate_and_commit_card

#########################################################
# Run subset_font if config.toml has been modified. #
# https://welpo.github.io/tabi/blog/custom-font-subset/ #
#########################################################
if git diff --cached --name-only | grep -q "config.toml"; then
echo "config.toml modified. Running subset_font…"
echo "config.toml modified. Attempting to run subset_font…"

# Check if subset_font is available and exit early if not.
if ! command -v subset_font &> /dev/null; then
echo "subset_font command not found. Skipping this step."
exit 0
fi

# Call the subset_font script.
~/bin/subset_font -c config.toml -f static/fonts/Inter4.woff2 -o static/
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @welpo
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assignees: ''
## Environment

Zola version:
tabi commit:
tabi version or commit:

## Expected Behavior
Tell us what should have happened.
Expand Down
66 changes: 66 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!--
Thank you for contributing to tabi!
This template is designed to guide you through the pull request process.
Please fill out the sections below as applicable.
Don't worry if your PR is not complete or you're unsure about something;
feel free to submit it and ask for feedback. We appreciate all contributions, big or small!
Feel free to remove any section or checklist item that does not apply to your changes.
If it's a quick fix (for example, fixing a typo), a Summary is enough.
-->

## Summary

<!-- Please provide a brief description of the changes made in this PR -->

### Related issue

<!-- Mention any relevant issues like #123 -->

## Changes

<!-- Please provide some more detail regarding the changes.
Add any additional information, configuration, or data that might be necessary for the review -->

### Accessibility

<!-- Have you taken steps to make your changes accessible? This could include:
- Semantic HTML
- ARIA attributes
- Keyboard navigation
- Voiceover or screen reader compatibility
- Colour contrast
Please elaborate on the actions taken.
If you need help, please ask! -->

### Screenshots

<!-- If applicable, add screenshots to help explain the changes made. Consider if a before/after is helpful -->

### Type of change

<!-- Mark the relevant option with an `x` like so: `[x]` (no spaces) -->

- [ ] Bug fix (fixes an issue without altering functionality)
- [ ] New feature (adds non-breaking functionality)
- [ ] Breaking change (alters existing functionality)
- [ ] UI/UX improvement (enhances user interface without altering functionality)
- [ ] Refactor (improves code quality without altering functionality)
- [ ] Documentation update
- [ ] Other (please describe below)

---

## Checklist

- [ ] I have verified the accessibility of my changes
- [ ] I have tested all possible scenarios for this change
- [ ] I have updated `theme.toml` with a sane default for the feature
- [ ] I have made corresponding changes to the documentation:
- [ ] Updated `config.toml` comments
- [ ] Updated `theme.toml` comments
- [ ] Updated "Mastering tabi" post in English
- [ ] (Optional) Updated "Mastering tabi" post in Spanish
- [ ] (Optional) Updated "Mastering tabi" post in Catalan
21 changes: 21 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended", ":automergeMinor", ":disableDependencyDashboard"],
"commitMessageAction": "chore(deps): update",
"commitMessagePrefix": "⬆️",
"labels": ["dependencies"],
"packageRules": [
{
"updateTypes": ["pin"],
"commitMessagePrefix": "📌"
},
{
"updateTypes": ["major", "minor", "patch", "digest", "bump"],
"commitMessagePrefix": "⬆️"
},
{
"updateTypes": ["rollback"],
"commitMessagePrefix": "⬇️"
}
]
}
36 changes: 36 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Continuous Deployment

on:
push:
tags:
- 'v*.*.*'

jobs:
deploy:
name: Deploy and release
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate the changelog
uses: orhun/git-cliff-action@main
id: git-cliff
with:
config: cliff.toml
args: --latest --strip all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OUTPUT: CHANGES.md

- name: Create GitHub release
run: |
gh release create ${{ github.ref_name }} \
--title "Release ${{ github.ref_name }}" \
--notes "${{ steps.git-cliff.outputs.content }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Site

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check_and_build_pr:
name: Check and Build for Pull Requests
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Zola Build
uses: shalzz/[email protected]
env:
BUILD_ONLY: true

- name: Zola Check
uses: shalzz/[email protected]
env:
BUILD_ONLY: true
CHECK_LINKS: true

build_and_deploy:
name: Build and Deploy on Main Push
runs-on: ubuntu-22.04
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Build and Deploy
uses: shalzz/[email protected]
env:
PAGES_BRANCH: gh-pages
TOKEN: ${{ secrets.TOKEN }}
BUILD_THEMES: false
21 changes: 21 additions & 0 deletions .github/workflows/git-sumi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint pull request title

on:
pull_request:
types:
- opened
- edited
- synchronize
- ready_for_review

permissions:
pull-requests: read

jobs:
main:
name: Run git-sumi
runs-on: ubuntu-latest
steps:
- uses: welpo/git-sumi-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 0 additions & 18 deletions .github/workflows/zolatogithubpages.yml

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.min.*
11 changes: 11 additions & 0 deletions .prettierrc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
semi = true
trailingComma = "es5"
singleQuote = true
printWidth = 88
tabWidth = 4
useTabs = false
arrowParens = "always"
bracketSpacing = true
jsxBracketSameLine = false
jsxSingleQuote = true
endOfLine = "lf"
Loading

0 comments on commit 324b7d6

Please sign in to comment.