Skip to content

Commit

Permalink
add HTML minification step
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Aug 2, 2024
1 parent 57e6443 commit 84131a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
7 changes: 6 additions & 1 deletion content/blog/updating-site-with-webhook/index.ca.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Automatitzant l'actualització de la meva web amb un webhook"
date = 2023-08-28
updated = 2023-12-02
updated = 2024-08-02
description= "Com que els fitxers d'aquesta web estan a GitHub, vaig pensar que seria bona idea actualitzar-la automàticament amb cada canvi al repositori."

[taxonomies]
Expand Down Expand Up @@ -314,6 +314,11 @@ git submodule update || notify_failure "Git submodule update ha fallat"
echo "Construint el lloc…"
zola build --output-dir "$temp_dir" --force || notify_failure "Zola build ha fallat"
# Minifica l'HTML amb https://github.com/terser/html-minifier-terser
# La minificació nativa de Zola elimina les cometes necessàries perquè les targetes de xarxes socials funcionin de forma consistent a WhatsApp.
echo "Minificant HTML…"
find "$temp_dir" -name '*.html' -exec html-minifier-terser --collapse-whitespace --conservative-collapse --remove-comments --remove-optional-tags --use-short-doctype -o {} {} \; || notify_failure "Minification failed"
# Sincronitza els arxius al directori final.
echo "Sincronitzant els arxius…"
rsync -a --delete "$temp_dir/" "$live_dir/" || notify_failure "rsync ha fallat"
Expand Down
11 changes: 8 additions & 3 deletions content/blog/updating-site-with-webhook/index.es.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Automatizando la actualización de mi web con un webhook"
date = 2023-08-28
updated = 2023-12-02
updated = 2024-08-02
description = "Como los archivos de esta web están en GitHub, pensé que sería buena idea actualizarla automáticamente con cada cambio en el repositorio."

[taxonomies]
Expand Down Expand Up @@ -306,14 +306,19 @@ trap 'trap_cleanup' EXIT
echo "Actualizando el repositorio…"
cd "$repo"
git fetch || notify_failure "Git fetch ha fallado"
git reset --hard origin || notify_failure "Git reset ha fallado"
git pull || notify_failure "Git pull ha fallado"
git reset --hard origin || notify_failure "Git reset ha fallado"
git pull || notify_failure "Git pull ha fallado"
git submodule update || notify_failure "Git submodule update ha fallado"
# Build site in temporary directory.
echo "Construyendo el sitio…"
zola build --output-dir "$temp_dir" --force || notify_failure "Zola build ha fallado"
# Minifica el HTML con https://github.com/terser/html-minifier-terser
# La minificación nativa de Zola elimina las comillas necesarias para que las tarjetas de redes sociales funcionen de forma consistente en WhatsApp.
echo "Minificando HTML…"
find "$temp_dir" -name '*.html' -exec html-minifier-terser --collapse-whitespace --conservative-collapse --remove-comments --remove-optional-tags --use-short-doctype -o {} {} \; || notify_failure "Minification failed"
# Sincroniza los archivos al directorio final.
echo "Sincronizando los archivos…"
rsync -a --delete "$temp_dir/" "$live_dir/" || notify_failure "rsync ha fallado"
Expand Down
11 changes: 8 additions & 3 deletions content/blog/updating-site-with-webhook/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
+++
title = "Automatically Updating My Zola Site Using a Webhook"
date = 2023-08-28
updated = 2023-12-02
updated = 2024-08-02
description = "Since this site's files are on GitHub, I thought it would be a nice idea to automatically update it whenever the repository is modified."

[taxonomies]
Expand Down Expand Up @@ -306,14 +306,19 @@ trap 'trap_cleanup' EXIT
echo "Updating repository…"
cd "$repo"
git fetch || notify_failure "Git fetch failed"
git reset --hard origin || notify_failure "Git reset failed"
git pull || notify_failure "Git pull failed"
git reset --hard origin || notify_failure "Git reset failed"
git pull || notify_failure "Git pull failed"
git submodule update || notify_failure "Git submodule update failed"
# Build site in temporary directory.
echo "Running Zola build…"
zola build --output-dir "$temp_dir" --force || notify_failure "Zola build failed"
# Minify HTML with https://github.com/terser/html-minifier-terser
# Native Zola minification strips quotes needed for social media cards to work consistently on WhatsApp.
echo "Minifying HTML…"
find "$temp_dir" -name '*.html' -exec html-minifier-terser --collapse-whitespace --conservative-collapse --remove-comments --remove-optional-tags --use-short-doctype -o {} {} \; || notify_failure "Minification failed"
# Sync files to the live directory.
echo "Syncing files…"
rsync -a --delete "$temp_dir/" "$live_dir/" || notify_failure "rsync failed"
Expand Down

0 comments on commit 84131a6

Please sign in to comment.