diff --git a/dist/static/modules.js b/dist/static/modules.js
new file mode 100644
index 0000000..9a5e395
--- /dev/null
+++ b/dist/static/modules.js
@@ -0,0 +1,19 @@
+class FormatNumber extends HTMLElement {
+ connectedCallback() {
+ this.innerHTML = this.formatNumber(this.innerHTML);
+ }
+
+ formatNumber(number) {
+ const parsed = parseFloat(number);;
+ if (isNaN(parsed)) {
+ return number;
+ }
+ return parsed.toLocaleString();
+ }
+}
+
+const main = () => {
+ customElements.define('format-number', FormatNumber);
+};
+
+main();
diff --git a/functions/index.js b/functions/index.js
index b81b1ed..6eca1b7 100644
--- a/functions/index.js
+++ b/functions/index.js
@@ -14,21 +14,29 @@ export const onRequestGet = async (context) => {
const [
blogPages,
docsPages,
+ magazinesPages,
] = await stats(env);
const doneIn = Date.now() - startTime;
const hasBlogs = result?.hits.blogs.length > 0;
const hasDocs = result?.hits.docs.length > 0;
+ const hasMagazines = result?.hits.magazines.length > 0;
const results = [];
+ if (hasDocs) {
+ results.push({
+ name: 'Docs',
+ hits: result.hits.docs,
+ });
+ }
if (hasBlogs) {
results.push({
name: 'Blogs',
hits: result.hits.blogs,
});
}
- if (hasDocs) {
+ if (hasMagazines) {
results.push({
- name: 'Docs',
- hits: result.hits.docs,
+ name: 'Magazines',
+ hits: result.hits.magazines,
});
}
@@ -49,6 +57,8 @@ export const onRequestGet = async (context) => {
hash,
blogPages,
docsPages,
+ magazinesPages,
+ totalPages: blogPages + docsPages + magazinesPages,
};
const html = Mustache.render(template, view);
diff --git a/functions/template.html b/functions/template.html
index b79347a..a3eff87 100644
--- a/functions/template.html
+++ b/functions/template.html
@@ -7,6 +7,7 @@
+
@@ -70,7 +71,8 @@ {{ title }}
About
Kukey.eu - curated search for web developers
Super MVP, contact me on Mastodon or check out the source code
- So far indexed {{ blogPages }} pages of blogs and {{ docsPages }} pages of docs. See all sources on GitHub . Edits welcomed!
+ So far indexed {{totalPages}} pages, including {{ blogPages }} pages of blogs, {{ magazinesPages}} pages of magazines and {{ docsPages }} pages of docs.
+ See all sources on GitHub . Edits welcomed!
diff --git a/lib/search.js b/lib/search.js
index fba0861..896c553 100644
--- a/lib/search.js
+++ b/lib/search.js
@@ -119,11 +119,13 @@ export const search = async (env, q, p = 0) => {
hits: {
'blogs': [],
'docs': [],
+ 'magazines': [],
},
};
await doSearch(result, env, 'blogs', q, p);
await doSearch(result, env, 'docs', q, p);
+ await doSearch(result, env, 'magazines', q, p);
return result;
};
@@ -131,6 +133,7 @@ export const search = async (env, q, p = 0) => {
export const stats = async (env) => {
const { numberOfDocuments: blogPages} = await getMeiliClient(env).index('blogs').getStats();
const { numberOfDocuments: docsPages} = await getMeiliClient(env).index('docs').getStats();
+ const { numberOfDocuments: magazinesPages} = await getMeiliClient(env).index('magazines').getStats();
- return [blogPages, docsPages];
+ return [blogPages, docsPages, magazinesPages];
};