Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templater Cannot read properties of undefined (reading 'map') when author or category is returned empty #101

Open
grvn opened this issue Apr 15, 2024 · 1 comment

Comments

@grvn
Copy link

grvn commented Apr 15, 2024

following the instructions in the README.md
the following lines should be used to create lists of authors and categories

authors: <%=book.authors.map(author=>`\n  - ${author}`).join('')%>
categories: <%=book.categories.map(category=>`\n  - ${category}`).join('')%>

But if the search result doesn't contain a catagory, the template fails.

Example:

Create a template containing the two lines
Search for the book "Red Team Development and Operations"

( This book: https://books.google.com/books/about/Red_Team_Development_and_Operations.html?hl=&id=84w_zQEACAAJ )

The plugin fails to detect any category and the teplate fails.

@baodrate
Copy link

baodrate commented Oct 1, 2024

a workaround:

categories: <%=(book.categories||[]).map(category=>`\n  - ${category}`).join('')%>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants