mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 22:16:07 +01:00
Put all redirects in one file
IPFS _redirects files have to be at the root — so put them all in the same place!
This commit is contained in:
parent
dfbb18617f
commit
6a9d43e5ea
2 changed files with 2 additions and 16 deletions
|
@ -7,6 +7,7 @@ summary: A list of the many curious things I've made over the years.
|
|||
sitemap:
|
||||
changefreq: weekly
|
||||
priority: 0.8
|
||||
shortlink: curiosities
|
||||
---
|
||||
I'm a thoroughly [miriscient](https://www.miriscient.org) chap, and this often ends up in me creating toys, trinkets, projects and other artistic things. I've listed some out below.
|
||||
|
||||
|
|
|
@ -18,28 +18,13 @@ cd $gitRoot
|
|||
mv public/_redirects public/_redirects.previous
|
||||
find public -type f -iname "_redirects" -delete
|
||||
|
||||
# Create local _redirects files
|
||||
echo "Sorting shortlinks into different directory _redirects files…"
|
||||
|
||||
while IFS=$'\n' read -r line
|
||||
do
|
||||
# Extract the absolute file path
|
||||
outdir=$(dirname $(echo "$line" | cut -d " " -f1) | cut -d "/" -f2)
|
||||
|
||||
if [[ -n "$outdir" ]]; then
|
||||
[[ ! -d $outdir ]] && mkdir -p "public/$outdir"
|
||||
echo $line | cut -c $((${#outdir}+2))- >> "public/$outdir/_redirects"
|
||||
else
|
||||
echo $line >> "public/_redirects"
|
||||
fi
|
||||
done < /dev/stdin
|
||||
|
||||
# Combine new (root) _redirects and _redirects.previous
|
||||
echo "Merging with existing links…"
|
||||
|
||||
start_line=$(awk '/^# From blog/{print NR; exit}' public/_redirects.previous)
|
||||
end_line=$(awk 'NR > '"$start_line"' && /^#/{print NR; exit}' public/_redirects.previous)
|
||||
|
||||
cp /dev/stdin public/_redirects
|
||||
sed "$((start_line + 1)),$((end_line - 2))d" public/_redirects.previous > old_removed.txt
|
||||
awk 'NR=='"$((start_line + 1))"'{system("cat public/_redirects")} 1' old_removed.txt > public/_redirects.new
|
||||
|
||||
|
|
Loading…
Reference in a new issue