Rename blog result constants
This commit is contained in:
parent
d2c1188304
commit
df918a844a
|
@ -30,8 +30,8 @@ const CMS = {
|
|||
CTA_WHO_USES_OXEN: /^\{\{[\s]*who_uses_oxen[\s]*\}\}$/,
|
||||
CTA_SESSION_LOKINET: /^\{\{[\s]*session_lokinet[\s]*\}\}$/,
|
||||
},
|
||||
BLOG_RESULTS_PER_PAGE_MAIN: 13,
|
||||
BLOG_RESULTS_PER_PAGE_TAG: 12,
|
||||
BLOG_RESULTS_PER_PAGE: 13,
|
||||
BLOG_RESULTS_PER_PAGE_TAGGED: 12,
|
||||
};
|
||||
|
||||
export default CMS;
|
||||
|
|
|
@ -26,7 +26,7 @@ export const getServerSideProps: GetServerSideProps = async context => {
|
|||
// Pagination only occurs when tag isnt defined.
|
||||
// If tag is defined, pagination is for tag results
|
||||
const { posts, total: totalPosts } = await cms.fetchBlogEntries(
|
||||
tag ? 12 : CMS.BLOG_RESULTS_PER_PAGE_MAIN,
|
||||
tag ? 12 : CMS.BLOG_RESULTS_PER_PAGE,
|
||||
tag ? 1 : page,
|
||||
);
|
||||
|
||||
|
@ -35,26 +35,26 @@ export const getServerSideProps: GetServerSideProps = async context => {
|
|||
let tagTotalPosts;
|
||||
const filteredPosts = posts;
|
||||
const filteredTotalPosts = totalPosts;
|
||||
let resultsPerPage = CMS.BLOG_RESULTS_PER_PAGE_MAIN;
|
||||
let resultsPerPage = CMS.BLOG_RESULTS_PER_PAGE;
|
||||
if (tag) {
|
||||
const {
|
||||
posts: _tagPosts = [],
|
||||
total: _tagTotalPosts,
|
||||
} = await cms.fetchBlogEntriesByTag(
|
||||
tag ?? '',
|
||||
CMS.BLOG_RESULTS_PER_PAGE_TAG,
|
||||
CMS.BLOG_RESULTS_PER_PAGE_TAGGED,
|
||||
page,
|
||||
);
|
||||
tagPosts = _tagPosts;
|
||||
tagTotalPosts = _tagTotalPosts;
|
||||
resultsPerPage = CMS.BLOG_RESULTS_PER_PAGE_TAG;
|
||||
resultsPerPage = CMS.BLOG_RESULTS_PER_PAGE_TAGGED;
|
||||
} else {
|
||||
// Retrieve all blog posts without the `dev-update` tag when not searching by tag
|
||||
const {
|
||||
posts: _tagPosts = [],
|
||||
total: _tagTotalPosts,
|
||||
} = await cms.fetchBlogEntriesWithoutDevUpdates(
|
||||
CMS.BLOG_RESULTS_PER_PAGE_MAIN,
|
||||
CMS.BLOG_RESULTS_PER_PAGE,
|
||||
page,
|
||||
);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ export class CmsApi {
|
|||
}
|
||||
|
||||
public async fetchBlogEntries(
|
||||
quantity = CMS.BLOG_RESULTS_PER_PAGE_MAIN,
|
||||
quantity = CMS.BLOG_RESULTS_PER_PAGE,
|
||||
page = 1,
|
||||
): Promise<IFetchBlogEntriesReturn> {
|
||||
const entries = await this.client.getEntries({
|
||||
|
@ -75,7 +75,7 @@ export class CmsApi {
|
|||
|
||||
public async fetchBlogEntriesByTag(
|
||||
tag: string,
|
||||
quantity = CMS.BLOG_RESULTS_PER_PAGE_TAG,
|
||||
quantity = CMS.BLOG_RESULTS_PER_PAGE_TAGGED,
|
||||
page = 1,
|
||||
): Promise<IFetchBlogEntriesReturn> {
|
||||
const entries = await this.client.getEntries({
|
||||
|
@ -95,7 +95,7 @@ export class CmsApi {
|
|||
}
|
||||
|
||||
public async fetchBlogEntriesWithoutDevUpdates(
|
||||
quantity = CMS.BLOG_RESULTS_PER_PAGE_MAIN,
|
||||
quantity = CMS.BLOG_RESULTS_PER_PAGE,
|
||||
page = 1,
|
||||
): Promise<IFetchBlogEntriesReturn> {
|
||||
const DEV_UPDATE_TAG = 'dev-update';
|
||||
|
|
Loading…
Reference in New Issue