knazarov.com/page.sh

53 lines
801 B
Bash
Raw Normal View History

2021-08-08 09:37:53 +00:00
#!/bin/bash
expand() {
TITLE="$1"
cat <<-"EOF"
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2021-08-08 17:47:34 +00:00
<link rel="stylesheet" type="text/css" href="style.css">
2021-08-08 09:37:53 +00:00
<title>
EOF
echo " $TITLE"
cat <<-"EOF"
</title>
</head>
<body>
<div id="header">
<a href="/">Konstantin Nazarov</a>
</div>
<div id="menu">
<a href="/">home</a>
<a href="/">posts</a>
<a href="/">projects</a>
<a href="/">about</a>
<a href="/">contact</a>
</div>
EOF
cat
cat <<-"EOF"
</body>
</html>
EOF
}
if [ -z "$1" ]; then
echo "Missing page title"
exit 1
fi
if [ -z "$2" ] && [ -t 0 ]; then
echo "Missing page body"
exit 1
fi
if [ ! -t 0 ]; then
expand "$1"
exit 0
fi
expand "$1" < "$2"