all repos — site @ 96e7f1a23be53f6cdc8b9ecf353794f2f9f9c494

source for my site, found at icyphox.sh

bin/plaintext.sh (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
#!/bin/sh 

# from the pure sh bible; see: 
# https://github.com/dylanaraps/pure-sh-bible#get-the-base-name-of-a-file-path
basename() {
    dir=${1%${1##*[!/]}}
    dir=${dir##*/}
    dir=${dir%"$2"}
    base="${dir:-/}"
}

# prepare the '_redirects' file
printf 'http://icyphox.netlify.com/* http://icyphox.sh/:splat 301!\n' > build/_redirects
for p in pages/blog/*.md; do
    basename "$p"
    no_ext="${base%.*}"
    [ "$base" != "_index.md" ] && {
        pandoc --quiet -s -f "markdown+gutenberg" \
            "$p" -o "pages/txt/$no_ext.txt"
            printf '%s\n' "/txt/$no_ext.txt /txt/$no_ext 301" >> build/_redirects
    }
done