generated from ztimson/template
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bc27fa632 |
+1
-1
@@ -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
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user