Generating better homepages

Generating better homepages

I have improved the homepages generated by mdsh - they now list posts in full, including title, date, tags and the full body content.

There are still some improvements to be made - a link at the bottom to the archive page, so users can find all posts (not only the most recent).

Currently the number of posts on the homepage is limited to some hard-coded value (18, I think), this should be improved in future.

Pagination may also be useful, but implementing that might in a nice way might take some thought.

The homepages are generated using the function print_post_preview:

function print_post_preview {
[ ! "$1" ] && return 1

# $1 is the mdsh file
set_post_info "$1"

# exit if we are not building a blog post
[ "$post_slug" = "" ] && return 0

echo '<div class="post-preview">'
echo '<h2><a href="'"${post_url}"'">'"${post_title}"'</a></h2> <datetime>'"${post_created}"'</datetime>'
echo '<ul class="post-meta">'
echo '<li>'"${post_time_to_read}"'</li>'
echo '<li>'"${post_created}"'</li>'
echo '<li>'"${post_author}"'</li>'
echo '<li>'"${post_twitter}"'</li>'
echo '<li><a href="'${blog_url}'/categories/'"${post_category}"'.html">'"${post_category}"'</a></li>'
echo '</ul>'
echo '<ul class="tags">'
for tag in ${post_tags//,/ }
do
echo '<li><a href="'${blog_url}'/tags/'${tag}'.html">'${tag}'</a></li>'
done
echo '</ul>'
# show only a summary (using the meta description)
#echo '<p>'"${post_descr}"'</p>'
# show full post content, excluding main header (already in post preview)
echo '</div>'
}

^ this function can be found in the create_pages script, and is run when the update_pages script re-builds the homepage (which happens automatically each time you create a new post, but can also be done manually by running ./update_pages [-all]).