~chambln/cosine.blue

bf2cfbaf10451de7322e161dc5ae627fa7db567f — Gregory Chamberlain 2 months ago d68fba2
Provide a canonical path for each page
1 files changed, 29 insertions(+), 5 deletions(-)

M bin/make
M bin/make => bin/make +29 -5
@@ 40,6 40,14 @@ html() {

            # Link to the RSS feed.
            echo '<link type="application/rss+xml" rel="alternate" href="/rss.xml" title="cosine.blue" />'

            # Link to the canonical path for this page, removing any
            # final ‘index.html’ segment.
            case $canonical in
                index.html) canonical='' ;;
                *) canonical=${canonical%/index.html} ;;
            esac
            printf '<link rel="canonical" href="%s">\n' https://cosine.blue/"$canonical"
        } | x head
        {
            x small < share/header.html | x header


@@ 133,15 141,31 @@ for src in src/* src/*/*; do [ -f "$src" ] && (
    bn=${src##*/}
    # shellcheck disable=SC1090
    [ -e env/"$bn".sh ] && . env/"$bn".sh
    unset canonical
    case $src in
        */article/*.md)
            cmark < "$src" | article | html > www/"${bn%.md}.html" ;;
        src/article/*.html) article < "$src" | html > www/"$bn" ;;
        *.md) cmark < "$src" | html > www/"${bn%.md}.html" ;;
        *.html.sh) sh < "$src" | html > www/"${bn%.sh}" ;;
        *.html) html < "$src" > www/"$bn" ;;
            canonical=${bn%.md}.html
            cmark < "$src" | article | html > www/"$canonical"
            ;;
        src/article/*.html)
            canonical=$bn
            article < "$src" | html > www/"$bn"
            ;;
        *.md)
            canonical=${bn%.md}.html
            cmark < "$src" | html > www/"${bn%.md}.html"
            ;;
        *.html.sh)
            canonical=${bn%.sh}
            sh < "$src" | html > www/"$canonical"
            ;;
        *.html)
            canonical=$bn
            html < "$src" > www/"$canonical"
            ;;
        *) cp -f "$src" www
    esac

    case $src in
        src/photos/*)
            mkdir -p www/thumbnail