forked from kageru/mdb
add proper index generation with pandoc and multiple markdown files
This commit is contained in:
parent
3d3f5ee506
commit
ddf569e46f
|
@ -3,7 +3,11 @@
|
|||
blog_domain='https://lucy.moe/'
|
||||
|
||||
output() {
|
||||
echo "$1" >> index.html
|
||||
echo "$1" >> index-alt.html
|
||||
}
|
||||
|
||||
output_entrylist() {
|
||||
echo "$1" >> entry_list.md
|
||||
}
|
||||
|
||||
output_rss() {
|
||||
|
@ -12,6 +16,8 @@ output_rss() {
|
|||
|
||||
add_header() {
|
||||
output '<h1>posts</h1><table id="linklist">'
|
||||
output_entrylist "title| date
|
||||
----|----:"
|
||||
output_rss '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
|
||||
<author><name>Lucy</name></author>
|
||||
|
@ -33,6 +39,7 @@ html_entry() {
|
|||
title="$3"
|
||||
output "<td class=\"first\"><a href=\"$path\">$title</a></td>"
|
||||
output "<td class=\"second\">$time</td></tr>"
|
||||
output_entrylist "[$title]($path)|$time"
|
||||
}
|
||||
|
||||
rss_entry() {
|
||||
|
@ -54,11 +61,11 @@ create_entry() {
|
|||
path="$9"
|
||||
outpath="$(basename "$path" .md).html"
|
||||
# convert new markdown posts to html
|
||||
pandoc -s --css=sakura-vader.css "$path" -t html5 -f markdown -o "$outpath"
|
||||
pandoc -s --css=sakura-vader.css "$path" footer.md -t html5 -f markdown -o "$outpath"
|
||||
# then add it to the index
|
||||
title="$(grep -h '^title: ' "$path" | sed 's/title: //g')"
|
||||
created=$(grep -h '^date: ' "$path" | sed 's/date: //g')
|
||||
html_entry "$outpath" "created on $created" "$title"
|
||||
html_entry "$outpath" "$created" "$title"
|
||||
rss_entry "$title" "$outpath"
|
||||
}
|
||||
|
||||
|
@ -74,7 +81,9 @@ has_updates() {
|
|||
|
||||
cd /home/lucy/blog-content/
|
||||
rm -f index.html
|
||||
rm -f entry_list.md
|
||||
rm -f rss.xml
|
||||
add_header
|
||||
ls -ltu src/*.md | tail -n+1 | while read f; do create_entry $f; done
|
||||
add_footer
|
||||
pandoc -s --css=sakura-vader.css index_header.md entry_list.md after-entry-list.md footer.md -o index.html
|
||||
|
|
Loading…
Reference in New Issue
Block a user