(intro)
Requirements:
- Go 1.14
- Hugo 0.61.0
If not already, init your project as Hugo Module:
$: hugo mod init {repo_url}
Configure your project's module to import this module:
# config.yaml
module:
imports:
- path: github.com/theNewDynamic/hugo-module-tnd-booksEach book lists an array of editions identified by a binding.
title: "L.A. Confidential"
description: "_L.A. Confidential_ is an epic crime novel that stands as a steel-edged time capsule—Los Angeles in the 1950s, a remarkable era defined in dark shadings."
editions:
- binding: paperback
isbn: 9780446674249
date: 1997-09-01T15:53:00.000Z
publisher: Grand Central Publishing
cover_image: /uploads/la_confidential_cover.jpg
- binding: ebook
isbn: 9781455528745
asin: B00AMILAEK
publisher: Grand Central Publishing- harcover
- paperback
- audiobook
- ebook
The module sports a sophisticated Buylink generator which relies on retailers IDs and edition bindings. Here are the current available retailers, their ids, the bindings they sell, and the expected edition's data for link generation
- id: indiebound
- expect: ISBN
- type: hardcover, paperback
- id: barnesandnoble
- expect: ISBN
- type: hardcover, paperback
- id: barnesandnoble_nook
- expect: ISBN
- type: ebook
- id: libro
- expect: ISBN
- type: audiobook
- id: amazon
- expect: ISBN or ASIN
- type: hardcover, paperback
- id: amazon_audible
- expect: ASIN
- type: audiobook
- id: amazon_kindle
- expect: ASIN
- type: ebook
- id: apple_books
- expect: ISBN or custom
apple_books_urlkey on the edition - type: ebook
Settings are added to the project's parameter under the tnd_books map as shown below.
# config.yaml's example and defaults
params:
tnd_books:
authors_key: authors
date_format: January 2, 2006
default_author: falseDirect the Front Matter key used to store the list of authors as content files.
If set, Books without any Front Matter "authors" will resolve to use this content file as author. This is useful for author site where most books are written by the same author.
Whenever the module templates is printing dates, this format in Go Layout string will will be used.
The retailers config key allows users to overwrite the default list of retailers to limit, order or overwrite labels:
# config.yaml's retailers example and defaults
params:
tnd_books:
- id: barnesandnoble
label: Barnes & Noble
- id: barnesandnoble_nook
label: Barnes & Noble Nook
- id: amazon
label: Amazon
- id: amazon_audible
label: Amazon Audible
- id: amazon_kindle
label: Amazon Kindle
- id: apple_books
label: "Apple Books"The module can help create a page for a book excerpt whose content file contains the excerpt key.
To add those pages to project you should:
- Add a cascade key to assign the output format to all books:
# content/book/_index.md
---
title: Books
# First make sure the cascade is not inherited by the section itself.
ouputs:
- HTML
# Add children ouputs through cascade.
cascade:
outputs:
- HTML
- tnd_books_excerptBy default the excerpt will live at /books/{:slug}/excerpt/.
This project is maintained and love by thenewDynamic.