Skip to content

Commit

Permalink
Removed ads from pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
kizzandev committed Mar 8, 2024
1 parent 2ce8f08 commit 6725ee8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions src/pages/en/page/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import IconChevronRightDouble from '@components/icons/IconChevronRightDouble.ast
import { ARTICLES_PER_PAGE } from '@/articles';
import adsList from '@/private/ads/adList.json';
// import adsList from '@/private/ads/adList.json';
export const getStaticPaths = (async ({ paginate }) => {
const { ads } = adsList;
const filtered_ads = ads.filter((ad: any) => ad.lang === 'en');
// const { ads } = adsList;
// const filtered_ads = ads.filter((ad: any) => ad.lang === 'en');
const allArticles: MarkdownInstance<Record<string, any>>[] = await Astro.glob(
'../../../pages/en/blog/article/*.md',
Expand Down Expand Up @@ -54,7 +54,7 @@ export const getStaticPaths = (async ({ paginate }) => {
}
}
let pageArticlesWithAds = filteredArticles;
/*let pageArticlesWithAds = filteredArticles;
let idx = weightedRandomSelect(filtered_ads) || 0;
if (filtered_ads.length > 0 && filteredArticles.length > 5) {
pageArticlesWithAds = filteredArticles.reduce(
Expand Down Expand Up @@ -111,9 +111,10 @@ export const getStaticPaths = (async ({ paginate }) => {
};
pageArticlesWithAds.push(theAd);
}
}
}*/
return paginate(pageArticlesWithAds, {
// return paginate(pageArticlesWithAds, {
return paginate(filteredArticles, {
pageSize: total,
});
}) satisfies GetStaticPaths;
Expand Down
13 changes: 7 additions & 6 deletions src/pages/page/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import IconChevronRightDouble from '@components/icons/IconChevronRightDouble.ast
import { ARTICLES_PER_PAGE } from '@/articles';
import adsList from '@/private/ads/adList.json';
// import adsList from '@/private/ads/adList.json';
export const getStaticPaths = (async ({ paginate }) => {
const { ads } = adsList;
const filtered_ads = ads.filter((ad: any) => ad.lang === 'en');
// const { ads } = adsList;
// const filtered_ads = ads.filter((ad: any) => ad.lang === 'en');
const allArticles: MarkdownInstance<Record<string, any>>[] = await Astro.glob(
'../../pages/blog/article/*.md',
Expand Down Expand Up @@ -54,7 +54,7 @@ export const getStaticPaths = (async ({ paginate }) => {
}
}
let pageArticlesWithAds = filteredArticles;
/*let pageArticlesWithAds = filteredArticles;
let idx = weightedRandomSelect(filtered_ads) || 0;
if (filteredArticles.length > 5) {
pageArticlesWithAds = filteredArticles.reduce(
Expand Down Expand Up @@ -111,9 +111,10 @@ export const getStaticPaths = (async ({ paginate }) => {
};
pageArticlesWithAds.push(theAd);
}
}
}*/
return paginate(pageArticlesWithAds, {
// return paginate(pageArticlesWithAds, {
return paginate(filteredArticles, {
pageSize: total,
});
}) satisfies GetStaticPaths;
Expand Down

0 comments on commit 6725ee8

Please sign in to comment.