better backlinks
This commit is contained in:
@@ -2,23 +2,14 @@
|
||||
|
||||
CSS=$(cat ./styles.css)
|
||||
|
||||
HTML_BEGIN="<!DOCTYPE html>
|
||||
<html lang=\"en\">
|
||||
<head>
|
||||
<meta charset=\"utf-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||
<style>$CSS</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav><a href=\"../\">← Parent Directory</a></nav>
|
||||
<hr>"
|
||||
|
||||
HTML_END="
|
||||
</body>
|
||||
</html>"
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
ROOT_DIR="$(pwd)"
|
||||
|
||||
find . -type f -name "*.md" -print0 | while IFS= read -r -d '' mdfile; do
|
||||
dir=$(dirname "$mdfile")
|
||||
base=$(basename "$mdfile" .md)
|
||||
@@ -34,6 +25,37 @@ find . -type f -name "*.md" -print0 | while IFS= read -r -d '' mdfile; do
|
||||
|
||||
pandoc "$mdfile" -t html -o "$html_raw"
|
||||
|
||||
abs_dir="$(cd "$dir" && pwd)"
|
||||
rel_depth="${abs_dir#$ROOT_DIR}"
|
||||
rel_depth="${rel_depth#/}"
|
||||
|
||||
nav=""
|
||||
if [[ -z "$rel_depth" ]]; then
|
||||
if [[ "$out_base" != "index" ]]; then
|
||||
nav='<nav><a href="./index.html"><- Index</a></nav>'
|
||||
fi
|
||||
else
|
||||
if [[ "$out_base" == "index" ]]; then
|
||||
nav='<nav><a href="../index.html"><- Home</a></nav>'
|
||||
else
|
||||
nav='<nav><a href="./index.html"><- Index</a> | <a href="../index.html"><- Home</a></nav>'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$nav" ]]; then
|
||||
nav="$nav<hr>"
|
||||
fi
|
||||
|
||||
HTML_BEGIN="<!DOCTYPE html>
|
||||
<html lang=\"en\">
|
||||
<head>
|
||||
<meta charset=\"utf-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||
<style>$CSS</style>
|
||||
</head>
|
||||
<body>
|
||||
$nav"
|
||||
|
||||
{
|
||||
echo "$HTML_BEGIN"
|
||||
sed -E 's/href="(\.\/[^.]+)"/href="\1\/"/g' "$html_raw" | \
|
||||
|
||||
Reference in New Issue
Block a user