Add meta-tags to blog posts

This commit is contained in:
Konstantin Nazarov 2023-08-17 23:59:22 +01:00
parent 4bfafac774
commit 5e5d9a597b
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
4 changed files with 51 additions and 39 deletions

View file

@ -27,7 +27,7 @@ $(ODIR)/posts/%/index.html: content/posts/%/note.md
cat "$<" | ./bin/mdpage.sh > "$@"
$(ODIR)/posts/index.html: $(POSTS_SRC)
./bin/toc.sh content/posts "/posts" | awk -f ./bin/markdown.awk | ./bin/page.sh Posts > "$@"
./bin/toc.sh content/posts "/posts" | awk -f ./bin/markdown.awk | ./bin/page.sh Posts "" > "$@"
$(ODIR)/rss.xml: $(POSTS_SRC)
./bin/rss.sh content/posts "https://knazarov.com" "/posts" > "$@"

View file

@ -11,6 +11,9 @@ render() {
if [[ "$line" =~ ^Subject:\ .*$ ]]; then
TITLE="${line#* }"
fi
if [[ "$line" =~ ^X-Date:\ .*$ ]]; then
DATE="${line#* }"
fi
if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then
LASTLINE="$line"
break
@ -21,7 +24,7 @@ render() {
[ "$NOTITLE" == "0" ] && echo "# $TITLE";
echo "$LASTLINE";
cat
} | awk -f ./bin/markdown.awk | ./bin/page.sh "$TITLE"
} | awk -f ./bin/markdown.awk | ./bin/page.sh "$TITLE" "$DATE"
}

View file

@ -2,15 +2,24 @@
expand() {
TITLE="$1"
DATE="$2"
cat <<-"EOF"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
EOF
if [ "$DATE" != "" ]; then
echo " <meta property=\"og:type\" content=\"article\">"
echo " <meta property=\"og:title\" content=\"$TITLE\">"
echo " <meta property=\"article:published_time\" content=\"$DATE\"/>"
fi
cat <<-"EOF"
<link rel="stylesheet" type="text/css" href="/style.css">
<title>
EOF
EOF
echo " $TITLE"
@ -38,7 +47,7 @@ EOF
</div>
</body>
</html>
EOF
EOF
}
if [ -z "$1" ]; then
@ -52,8 +61,8 @@ if [ -z "$2" ] && [ -t 0 ]; then
fi
if [ ! -t 0 ]; then
expand "$1"
expand "$1" "$2"
exit 0
fi
expand "$1" < "$2"
expand "$1" "$2" < "$3"

View file

@ -1,6 +1,6 @@
X-Date: 2023-08-17T23:00:00Z
X-Note-Id: cc2f05b8-6a95-452a-875b-887fde269c35
Subject: Enjoing internet with prefers-reduced-motion
Subject: Enjoying internet with prefers-reduced-motion
X-Slug: enjoying_internet_with_prefers_reduced_motion
I didn't know this before, but you can actually set a special toggle in your operating system