Show author names in natural order everywhere

Names read from MARC personal-name fields are stored as "Steve Allen",
and names already stored as "Allen, Steve" are shown and printed in
natural order. Search matches both forms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-19 14:09:09 -07:00
1 parent 7ae1bcef0a
commit 60fa4ef6f7
17 files changed
+183 -15

No files matched your search

+2 -1
View File
@@ -1,5 +1,6 @@
import type { Book } from '../shared/types.ts';
import { cardLines, formatCallNumber, parseCallNumber, withYear } from '../shared/callnumber.ts';
import { displayAuthors } from '../shared/names.ts';
import { cutterFor, mainEntry } from '../shared/cutter.ts';
/** A call number for `authors`/`title` that shelves next to `neighbour`: its class part, a new cutter, then the year. */
@@ -21,7 +22,7 @@ export function findNeighbours(books: Book[], text: string, limit = 8): Book[] {
const out: Book[] = [];
for (const b of books) {
if (!b.callNumber || !parseCallNumber(b.callNumber)) continue;
if ([b.title, b.authors.join(' ')].some(s => s.toLowerCase().includes(needle))) out.push(b);
if ([b.title, b.authors.join(' '), displayAuthors(b.authors).join(' ')].some(s => s.toLowerCase().includes(needle))) out.push(b);
if (out.length >= limit) break;
}
return out;