📝 Added new scripts, aliases, etc.

This commit is contained in:
z3rOR0ne 2023-06-20 01:11:01 -07:00
parent f67d7b627e
commit 99dac59d82
5 changed files with 76 additions and 0 deletions

View file

@ -241,6 +241,7 @@ alias duuid="dbus-uuidgen"
# generate unique ids from cli, example for no special characters:
alias manoid="nanoid --alphabet 'abcdefghijklmnopqrstuvwxyz' --size 40"
alias nanoid="npx nanoid"
alias uglifyhtml="html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true"
# autoprefixes css files
# requires installation:
# npm install -g postcss postcss-cli autoprefixer

20
robots_examples.txt Normal file
View file

@ -0,0 +1,20 @@
# Allows all:
User-agent: *
Disallow:
# Disallow all (you don't want ANY site traffic here...):
User-agent: *
Disallow: /
# Disallow specific files and folders
User-agent: *
Disallow: /topsy/
Disallow: /crets/
Disallow: /hidden/file.html
# Disallow Specific Bots
User-agent: Bingbot
Disallow: /
User-agent: *
Disallow:

41
scripts/minify Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Function to minify HTML files
minify_html() {
html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true "$1" -o "$1"
}
# Function to minify CSS files
minify_css() {
uglifycss "$1" >"$1.tmp" && mv "$1.tmp" "$1"
}
# Function to minify JS files
minify_js() {
uglifyjs --no-annotations "$1" -o "$1" -c -m
}
# Backup dist directory
if [[ -d "dist_bak" ]]; then
sudo rm -r dist_bak
fi
cp -r ./dist dist_bak
# Store HTML file paths in an array
mapfile -t html_files < <(find ./dist -type f -name "*.html")
mapfile -t css_files < <(find ./dist -type f -name "*.css")
mapfile -t js_files < <(find ./dist -type f -name "*.js")
# Loop over HTML files and minify them
for file in "${html_files[@]}"; do
minify_html "$file"
done
# Loop over CSS files and minify them
for file in "${css_files[@]}"; do
minify_html "$file"
done
# Loop over JS files and minify them
for file in "${js_files[@]}"; do
minify_html "$file"
done

8
scripts/uglify Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
if [[ -d "dist_bak" ]]; then
sudo rm -r dist
mv dist_bak dist
else
echo "no dist_bak directory"
fi

View file

@ -256,3 +256,9 @@ doas npm i -g typescript
Install rome in nvim to get proper linting
:Mason
select rome
06/19/2023
Install nginx and html-minifier (and uglifycss and uglifyjs if not already)
doas pacman -S nginx nginx-runit
doas sv ln -s /etc/runit/sv/nginx /run/runit/service/
doas npm install -g html-minifier uglifyjs uglifycss