Add meta-tags to blog posts
This commit is contained in:
parent
4bfafac774
commit
5e5d9a597b
4 changed files with 51 additions and 39 deletions
2
Makefile
2
Makefile
|
@ -27,7 +27,7 @@ $(ODIR)/posts/%/index.html: content/posts/%/note.md
|
||||||
cat "$<" | ./bin/mdpage.sh > "$@"
|
cat "$<" | ./bin/mdpage.sh > "$@"
|
||||||
|
|
||||||
$(ODIR)/posts/index.html: $(POSTS_SRC)
|
$(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)
|
$(ODIR)/rss.xml: $(POSTS_SRC)
|
||||||
./bin/rss.sh content/posts "https://knazarov.com" "/posts" > "$@"
|
./bin/rss.sh content/posts "https://knazarov.com" "/posts" > "$@"
|
||||||
|
|
|
@ -3,37 +3,40 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
NOTITLE="$1"
|
NOTITLE="$1"
|
||||||
LASTLINE=""
|
LASTLINE=""
|
||||||
TITLE=""
|
TITLE=""
|
||||||
|
|
||||||
while read -r line ; do
|
while read -r line ; do
|
||||||
if [[ "$line" =~ ^Subject:\ .*$ ]]; then
|
if [[ "$line" =~ ^Subject:\ .*$ ]]; then
|
||||||
TITLE="${line#* }"
|
TITLE="${line#* }"
|
||||||
fi
|
fi
|
||||||
if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then
|
if [[ "$line" =~ ^X-Date:\ .*$ ]]; then
|
||||||
LASTLINE="$line"
|
DATE="${line#* }"
|
||||||
break
|
fi
|
||||||
fi
|
if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then
|
||||||
done
|
LASTLINE="$line"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
{
|
{
|
||||||
[ "$NOTITLE" == "0" ] && echo "# $TITLE";
|
[ "$NOTITLE" == "0" ] && echo "# $TITLE";
|
||||||
echo "$LASTLINE";
|
echo "$LASTLINE";
|
||||||
cat
|
cat
|
||||||
} | awk -f ./bin/markdown.awk | ./bin/page.sh "$TITLE"
|
} | awk -f ./bin/markdown.awk | ./bin/page.sh "$TITLE" "$DATE"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NOTITLE=0
|
NOTITLE=0
|
||||||
|
|
||||||
if [ "$1" == "--notitle" ]; then
|
if [ "$1" == "--notitle" ]; then
|
||||||
NOTITLE=1
|
NOTITLE=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -t 0 ]; then
|
if [ -t 0 ]; then
|
||||||
echo "Missing Markdown body"
|
echo "Missing Markdown body"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
render "$NOTITLE"
|
render "$NOTITLE"
|
||||||
|
|
43
bin/page.sh
43
bin/page.sh
|
@ -2,22 +2,31 @@
|
||||||
|
|
||||||
expand() {
|
expand() {
|
||||||
TITLE="$1"
|
TITLE="$1"
|
||||||
|
DATE="$2"
|
||||||
cat <<-"EOF"
|
cat <<-"EOF"
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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">
|
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||||
<title>
|
<title>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo " $TITLE"
|
echo " $TITLE"
|
||||||
|
|
||||||
cat <<-"EOF"
|
cat <<-"EOF"
|
||||||
</title>
|
</title>
|
||||||
<link rel="alternate" type="application/rss+xml"
|
<link rel="alternate" type="application/rss+xml"
|
||||||
title="RSS Feed for knazarov.com" href="/rss.xml" />
|
title="RSS Feed for knazarov.com" href="/rss.xml" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
|
@ -31,29 +40,29 @@ expand() {
|
||||||
<a href="/contact">contact</a>
|
<a href="/contact">contact</a>
|
||||||
<a href="/rss.xml"><img src="/rss.png" style="height: 15px; width: auto; vertical-align:middle;"></img></a>
|
<a href="/rss.xml"><img src="/rss.png" style="height: 15px; width: auto; vertical-align:middle;"></img></a>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
EOF
|
EOF
|
||||||
cat
|
cat
|
||||||
cat <<-"EOF"
|
cat <<-"EOF"
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Missing page title"
|
echo "Missing page title"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$2" ] && [ -t 0 ]; then
|
if [ -z "$2" ] && [ -t 0 ]; then
|
||||||
echo "Missing page body"
|
echo "Missing page body"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -t 0 ]; then
|
if [ ! -t 0 ]; then
|
||||||
expand "$1"
|
expand "$1" "$2"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
expand "$1" < "$2"
|
expand "$1" "$2" < "$3"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
X-Date: 2023-08-17T23:00:00Z
|
X-Date: 2023-08-17T23:00:00Z
|
||||||
X-Note-Id: cc2f05b8-6a95-452a-875b-887fde269c35
|
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
|
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
|
I didn't know this before, but you can actually set a special toggle in your operating system
|
||||||
|
|
Loading…
Reference in a new issue