mirror of
https://github.com/oxen-io/oxen-website.git
synced 2023-12-13 21:00:18 +01:00
Update number of blog results per page
This commit is contained in:
parent
342f8b0913
commit
e4c141867d
|
@ -30,7 +30,7 @@ const CMS = {
|
|||
CTA_WHO_USES_OXEN: /^\{\{[\s]*who_uses_oxen[\s]*\}\}$/,
|
||||
CTA_SESSION_LOKINET: /^\{\{[\s]*session_lokinet[\s]*\}\}$/,
|
||||
},
|
||||
BLOG_RESULTS_PER_PAGE: 20,
|
||||
BLOG_RESULTS_PER_PAGE: 21,
|
||||
};
|
||||
|
||||
export default CMS;
|
||||
|
|
|
@ -20,7 +20,7 @@ export const getServerSideProps: GetServerSideProps = async context => {
|
|||
|
||||
// Get tag query
|
||||
const tag = String(context.query.tag ?? '') ?? null;
|
||||
const page = Math.ceil(Number(context.query.page ?? 1));
|
||||
const page = Math.floor(Number(context.query.page ?? 1));
|
||||
|
||||
// Fetch posts even when tag, for related etc
|
||||
// Pagination only occurs when tag isnt defined.
|
||||
|
@ -29,6 +29,7 @@ export const getServerSideProps: GetServerSideProps = async context => {
|
|||
tag ? 8 : CMS.BLOG_RESULTS_PER_PAGE,
|
||||
tag ? 1 : page,
|
||||
);
|
||||
console.log(posts);
|
||||
|
||||
// Get tags for pagination
|
||||
let tagPosts = [];
|
||||
|
@ -42,13 +43,13 @@ export const getServerSideProps: GetServerSideProps = async context => {
|
|||
CMS.BLOG_RESULTS_PER_PAGE,
|
||||
page,
|
||||
);
|
||||
|
||||
tagPosts = _tagPosts;
|
||||
tagTotalPosts = _tagTotalPosts;
|
||||
}
|
||||
|
||||
const total = tagTotalPosts ?? totalPosts;
|
||||
const pageCount = Math.floor(total / CMS.BLOG_RESULTS_PER_PAGE);
|
||||
console.log(total);
|
||||
const pageCount = Math.ceil(total / CMS.BLOG_RESULTS_PER_PAGE);
|
||||
|
||||
return {
|
||||
props: {
|
||||
|
@ -168,7 +169,7 @@ const Blog = (props: Props) => {
|
|||
</Contained>
|
||||
|
||||
{/* Posts, or recent posts if tag */}
|
||||
<CardGrid rows={2}>
|
||||
<CardGrid rows={tag ? 2 : 5}>
|
||||
{(tag ? posts : otherPosts)?.map(post => (
|
||||
<ArticleCard key={post.id} {...post} />
|
||||
))}
|
||||
|
|
Loading…
Reference in a new issue