Bookshelves

Next week we’re officially launching a feature that has been in testing for the last month: the ability to keep track of books you are reading to make it easier to include them on your blog, or post a new microblog post about a book. I want to document a few things about that feature here.

For an introduction, see the video I blogged about here.

You can use bookshelves as private lists of books, or you can have Micro.blog automatically include a book list at the bottom of a page on your blog. For example, I created a page called “Reading”, and then I select that when editing a bookshelf:

When you use this option, Micro.blog generates some basic HTML for you. It includes class names in the HTML so that you can customize the style of the book list. Click Design → “Edit CSS”. For my blog, I’ve added a little more spacing and made the book title bolder:

.bookshelf_book {
  padding-bottom: 7px;
}

.bookshelf_title {
  font-weight: 500;
}

.bookshelf_author {
}

If you need complete control, use a custom theme instead. Micro.blog makes book data available as Hugo data so that the data is available in templates:

{{ range .Site.Data.bookshelves.currentlyreading }}
   <a href="https://micro.blog/books/{{ .isbn }}">
     {{ .title }} by {{ .author }}
   </a>
{{ end }}

The bookshelf is referenced as a lowercased version of the name without any spaces. The data fields available are: title, author, isbn, and cover_url.

Happy reading! This feature will go live on June 1st, 2021.

4 Likes

Q: So the bookshelves are for my benefit. And then I create posts to share from them. correct?

Correct. They are private just for your own use until you either create a new post for a book, or choose the option to include a bookshelf in one of your blog post pages.

If you want to control placement (i.e. not bottom of page), do you have to use Hugo? Can you use that inline in the standard Pages editor?

You’ll have to use Hugo to have full control, and unfortunately that doesn’t work in the Pages editor. Hugo tags only work in templates in custom themes.

With Bookshelves we wanted the very simple use case (“just include these books on a page”) to be easy, and the hard things possible, but admittedly there’s not really a good middle-ground for simple customizations.