~zenomat/tinywiki

0dac8299ff5fe12f2b1a7dc70c8dd765d4ad03ad — zeno a month ago b297a95
fix toc in subfolders not using relative path from their dir
1 files changed, 6 insertions(+), 1 deletions(-)

M build.sh
M build.sh => build.sh +6 -1
@@ 20,10 20,15 @@ find . -name "*.md" | while read -r file; do
	path=$(dirname $file)
	name=$(basename $file | cut -f 1 -d '.')
	title=$(grep title "$file" | cut -d":" -f 2- | cut -b 2-)
	path_to_root=$(realpath --relative-to="$outdir/$path" "$outdir")
	escaped_path_to_root=$(printf '%s\n' "$path_to_root" | sed -e 's/[\/&]/\\&/g')
	if [ "$title" = "" ]; then
		title="$name"
	fi
	echo "["$title"]("$path/$name".html)" >> "$outdir/tmp/toc.md"
	# TODO(zeno): Make this webserver ready
	# only works on local machine, because absolute path,
	# on webserver with domain, we shoudl support basepath
	echo "["$title"]("$outdir/$path/$name".html)" >> "$outdir/tmp/toc.md"
done

find . -name "*.md" ! -name "toc.md" | while read -r file; do