@@ -167,6 +167,7 @@ extracttitle() {
167
167
# Convert a markdown file to HTML and store it in the docs directory
168
168
md2html () {
169
169
local file=$1
170
+ local title=$2
170
171
[[ $file == * .md ]] || die " not a markdown file: $file "
171
172
172
173
echo " Building $file ..." >&2
@@ -181,7 +182,7 @@ md2html() {
181
182
" --lua-filter=dotgraph.lua"
182
183
" --metadata=document-css:true"
183
184
" --metadata=lang:$( getlang) "
184
- " --metadata=title:$( extracttitle " $file " | pandoc --to plain) "
185
+ " --metadata=title:$( pandoc --to plain <<< " $title " ) "
185
186
" --metadata-file=.metadata.yml"
186
187
" --output=docs/${file/% .md/ .html} "
187
188
" --standalone"
@@ -287,17 +288,17 @@ build() {
287
288
288
289
# Build index file and convert posts
289
290
{
290
- printf ' %s\n' " # All posts"
291
- local f
291
+ local f title
292
292
for f in ???? -?? -?? -* .md; do
293
+ title=$( extracttitle " $f " )
293
294
printf -- ' :::\n[%s](%s)\n:::index-title\n\n:::\n%s\n:::index-date\n\n' \
294
- " $( extracttitle " $f " ) " " ${f/% .md/ .html} " " ${f: 0: 10} "
295
- md2html " $f "
295
+ " $title " " ${f/% .md/ .html} " " ${f: 0: 10} "
296
+ md2html " $f " " $title "
296
297
done | tac
297
298
} > index.md
298
299
299
300
# Convert index file
300
- md2html index.md
301
+ md2html index.md ' All posts '
301
302
302
303
rm index.md
303
304
cp " $cssfile " docs
@@ -330,7 +331,7 @@ serve() {
330
331
case $fname in
331
332
./* .md)
332
333
echo " Rebuilding $fname ..."
333
- md2html " ${fname# ./ } "
334
+ md2html " ${fname# ./ } " " $( extracttitle " $fname " ) "
334
335
;;
335
336
./images/* )
336
337
echo " Copying $fname to images..."
0 commit comments