Compare commits

1 Commits
Author SHA1 Message Date
ztimson 5bc27fa632 Summary fix
Publish Library / Build NPM Project (push) Successful in 3m35s
Publish Library / Tag Version (push) Successful in 7s
2026-09-21 13:27:36 -04:00
2 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@ztimson/zim-utils", "name": "@ztimson/zim-utils",
"version": "0.4.5", "version": "0.4.6",
"description": "Native, dependency-light ZIM archive reader/searcher and Kiwix catalog downloader for Node.js", "description": "Native, dependency-light ZIM archive reader/searcher and Kiwix catalog downloader for Node.js",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",
+8 -2
View File
@@ -32,6 +32,12 @@ function tokenize(terms) {
return String(terms).split(/[,\s]+/).map(t => t.trim()).filter(Boolean); return String(terms).split(/[,\s]+/).map(t => t.trim()).filter(Boolean);
} }
function normalizeSummary(summary) {
if(typeof summary === 'string') return summary;
if(summary && typeof summary === 'object') return summary._text || '';
return '';
}
export class KiwixServer { export class KiwixServer {
static #empty = '<?xml version="1.0" encoding="UTF-8" ?>\n<library version="20110515"></library>\n'; static #empty = '<?xml version="1.0" encoding="UTF-8" ?>\n<library version="20110515"></library>\n';
@@ -218,7 +224,7 @@ export class KiwixServer {
id: e.id, id: e.id,
title: e.title, title: e.title,
updated: new Date(e.date), updated: new Date(e.date),
summary: e.description, summary: normalizeSummary(e.description),
language: e.language, language: e.language,
name: e.name, name: e.name,
category: tags.find(t => t.startsWith('_category'))?.slice(10) || '', category: tags.find(t => t.startsWith('_category'))?.slice(10) || '',
@@ -292,7 +298,7 @@ export class KiwixServer {
href: `${resultBook.href}/${page}`, href: `${resultBook.href}/${page}`,
icon: resultBook.icon, icon: resultBook.icon,
viewer: this.baseUrl + hit.link, viewer: this.baseUrl + hit.link,
summary: hit.description, summary: normalizeSummary(hit.description),
xapianScore: +hit.score || 0, xapianScore: +hit.score || 0,
}; };
}).filter(Boolean); }).filter(Boolean);