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