diff --git a/data/pages/history b/data/pages/history
index 2fcc0fb..2d445fe 100644
--- a/data/pages/history
+++ b/data/pages/history
@@ -6,6 +6,12 @@ and to visually communicate the paths surfers took through this history. #}
{% macro hl-change fmt %}
{% ifchanged visited_at|date:fmt %}{{visited_at|date:fmt}}{% else %}{{visited_at|date:fmt}}{% endif %}
{% endmacro %}
+{% macro q-history %}
+ FROM page_visit WHERE {{q}} = "" OR rowid IN (SELECT rowid FROM history_fts({{q}}))
+{% endmacro %}
+{% macro q-paged page %}
+ {% q-history %} ORDER BY visited_at DESC LIMIT {{pagesize}} OFFSET {{page}}*{{pagesize}}
+{% endmacro %}
[document-open-recent] {% trans %}History{% endtrans %}
@@ -19,13 +25,11 @@ and to visually communicate the paths surfers took through this history. #}
{% query %}INSERT OR IGNORE INTO history_fts(rowid, uri, title)
SELECT rowid, uri, title FROM page_visit;{% endquery %}
{% endif %}
-{% with pagesize=400 q=url.query.q %}
+{% with pagesize=400 q=url.query.q page=url.query.page|default:0 %}
-
{% query %}SELECT rowid, tab, uri, title, favicon, visited_at, referrer
- FROM page_visit
- WHERE {{q}} = "" OR rowid IN (SELECT rowid FROM history_fts({{q}}))
- ORDER BY visited_at DESC
- LIMIT {{ pagesize }} OFFSET {{ url.query.page|default:0 }}*{{ pagesize }};
+