Reutilizar código de markdown en index
This commit is contained in:
parent
a36c69108e
commit
ca21ed158b
1 changed files with 9 additions and 5 deletions
14
build.sh
14
build.sh
|
@ -18,6 +18,13 @@ template () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
markdown () {
|
||||||
|
# TODO: hacky
|
||||||
|
cmark --unsafe "$1" \
|
||||||
|
| sed "s/<a /<a rel='noopener noreferrer' /gi" \
|
||||||
|
| sed 's/\[\[\(.*\)\]\]/<a href="\1.html">\1<\/a>/g'
|
||||||
|
}
|
||||||
|
|
||||||
outdir=build
|
outdir=build
|
||||||
mkdir -p $outdir
|
mkdir -p $outdir
|
||||||
# Autocopiarnos :)
|
# Autocopiarnos :)
|
||||||
|
@ -25,7 +32,7 @@ cp ./*.sh ./*.md ./*.css ./*.png ./*.mp4 "$outdir"
|
||||||
|
|
||||||
index="$outdir/index.html"
|
index="$outdir/index.html"
|
||||||
inicio=true header=false template "nulo.in" > "$index"
|
inicio=true header=false template "nulo.in" > "$index"
|
||||||
cmark --unsafe index.md >> "$index"
|
markdown index.md >> "$index"
|
||||||
echo "<h2>Lista de páginas</h2><ul>" >> "$index"
|
echo "<h2>Lista de páginas</h2><ul>" >> "$index"
|
||||||
|
|
||||||
for file in *.md; do
|
for file in *.md; do
|
||||||
|
@ -33,10 +40,7 @@ for file in *.md; do
|
||||||
title="$(basename "$file" .md)"
|
title="$(basename "$file" .md)"
|
||||||
outfile="$outdir/$title.html"
|
outfile="$outdir/$title.html"
|
||||||
template "$title" "$file" > "$outfile"
|
template "$title" "$file" > "$outfile"
|
||||||
cmark --unsafe "$file" >> "$outfile"
|
markdown "$file" >> "$outfile"
|
||||||
# TODO: hacky
|
|
||||||
sed -i "s/<a /<a rel='noopener noreferrer' /gi" "$outfile"
|
|
||||||
sed -i 's/\[\[\(.*\)\]\]/<a href="\1.html">\1<\/a>/g' "$outfile"
|
|
||||||
echo "<li><a href='$title.html'>$title</a></li>" >> "$index"
|
echo "<li><a href='$title.html'>$title</a></li>" >> "$index"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Reference in a new issue