mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 18:06:07 +01:00
- Every page now has a shortlink - Shortlinks can be manually overridden with the shortlink frontmatter param - A single "index.redirects" file is created at build time - A "redirects" tool splits that one file into multiple `_redirects` files, as would be needed on a site like byjp.fyi
16 lines
381 B
Bash
Executable file
16 lines
381 B
Bash
Executable file
#!/bin/bash
|
|
|
|
rm **/_redirects
|
|
|
|
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 $outdir
|
|
echo $line | cut -c $((${#outdir}+2))- >> "./$outdir/_redirects"
|
|
else
|
|
echo $line >> "_redirects"
|
|
fi
|
|
done < "${1:-/dev/stdin}"
|