This commit is contained in:
undefined committed 2025-12-06 22:37:01 +08:00
1 parent 17ec582804
commit ddf003c4c5
3 files changed
+8 -3

No files matched your search

+5
View File
@@ -47,3 +47,8 @@ export function* paginate(page: number, numPages: number) {
if (page < numPages - 1) yield ['last', numPages];
}
}
export function buildQueryString(obj: Record<string, any>) {
return Object.entries(obj).filter(([key, value]) => value && !key.startsWith('__'))
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&');
}
+1 -1
View File
@@ -130,7 +130,7 @@ class Nunjucks extends nunjucks.Environment {
this.addGlobal('instanceof', (a, b) => a instanceof b);
this.addGlobal('paginate', misc.paginate);
this.addGlobal('size', misc.size);
this.addGlobal('utils', { status, getAlphabeticId });
this.addGlobal('utils', { status, getAlphabeticId, buildQueryString: misc.buildQueryString });
this.addGlobal('avatarUrl', avatar);
this.addGlobal('formatSeconds', misc.formatSeconds);
this.addGlobal('model', global.Hydro.model);