mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2026-03-02 02:41:34 +00:00
Infinite scroll
This commit is contained in:
parent
a3b4e2e64e
commit
b5f163891c
7 changed files with 93 additions and 11 deletions
6
src/site/pug/fragments/timeline_page.pug
Normal file
6
src/site/pug/fragments/timeline_page.pug
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
include ../includes/timeline_page.pug
|
||||
include ../includes/next_page_button.pug
|
||||
|
||||
+timeline_page(page, pageIndex)
|
||||
|
||||
+next_page_button(user, url)
|
||||
10
src/site/pug/includes/next_page_button.pug
Normal file
10
src/site/pug/includes/next_page_button.pug
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
mixin next_page_button(user, url)
|
||||
if user.timeline.hasNextPage()
|
||||
div.next-page-container#next-page-container
|
||||
-
|
||||
const nu = new URL(url)
|
||||
nu.searchParams.set("page", user.timeline.pages.length+1)
|
||||
a(href=`${nu.search}#page-${user.timeline.pages.length+1}` data-page=(user.timeline.pages.length+1) data-username=(user.data.username))#next-page.next-page Next page
|
||||
else
|
||||
div.page-number.no-more-pages
|
||||
span.number No more posts.
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
include includes/timeline_page.pug
|
||||
include includes/next_page_button.pug
|
||||
|
||||
- const numberFormat = new Intl.NumberFormat().format
|
||||
|
||||
|
|
@ -10,6 +11,7 @@ html
|
|||
title
|
||||
= `${user.data.full_name} (@${user.data.username}) | Bibliogram`
|
||||
link(rel="stylesheet" type="text/css" href="/static/css/main.css")
|
||||
script(src="/static/js/pagination.js" type="module")
|
||||
body
|
||||
.main-divider
|
||||
header.profile-overview
|
||||
|
|
@ -34,16 +36,8 @@ html
|
|||
|
|
||||
| followed by
|
||||
|
||||
main.timeline
|
||||
main#timeline.timeline
|
||||
each page, pageIndex in user.timeline.pages
|
||||
+timeline_page(page, pageIndex)
|
||||
|
||||
if user.timeline.hasNextPage()
|
||||
div.next-page-container
|
||||
-
|
||||
const nu = new URL(url)
|
||||
nu.searchParams.set("page", user.timeline.pages.length+1)
|
||||
a(href=`${nu.search}#page-${user.timeline.pages.length+1}` data-cursor=user.timeline.page_info.end_cursor)#next-page.next-page Next page
|
||||
else
|
||||
div.page-number.no-more-pages
|
||||
span.number No more posts.
|
||||
+next_page_button(user, url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue