Infinite scroll

This commit is contained in:
Cadence Fish
2020-01-13 04:39:50 +13:00
parent a3b4e2e64e
commit b5f163891c
7 changed files with 93 additions and 11 deletions

View File

@@ -10,5 +10,20 @@ module.exports = [
await user.timeline.fetchUpToPage(page - 1)
}
return render(200, "pug/user.pug", {url, user})
}},
{route: "/fragment/user/([\\w.]+)/(\\d+)", methods: ["GET"], code: async ({url, fill}) => {
const user = await fetchUser(fill[0])
const pageNumber = +fill[1]
const pageIndex = pageNumber - 1
await user.timeline.fetchUpToPage(pageIndex)
if (user.timeline.pages[pageIndex]) {
return render(200, "pug/fragments/timeline_page.pug", {page: user.timeline.pages[pageIndex], pageIndex, user, url})
} else {
return {
statusCode: 400,
contentType: "text/html",
content: "That page does not exist"
}
}
}}
]