Skip to content

Commit

Permalink
#199: Max pagination to reduce siteData.js bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Sep 14, 2020
1 parent 5476a80 commit e2f4232
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
10 changes: 6 additions & 4 deletions site/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
itemLayout: 'Post',
layout: 'Blog',
pagination: {
lengthPerPage: 5,
lengthPerPage: 1000,
},
title: 'Blog',
},
Expand All @@ -36,8 +36,7 @@ module.exports = {
itemLayout: 'CaseStudy',
layout: 'Work',
pagination: {
lengthPerPage: 5,

lengthPerPage: 1000,
},
title: 'Work',
},
Expand All @@ -48,6 +47,9 @@ module.exports = {
itemPermalink: '/:slug',
itemLayout: 'Page',
layout: 'About',
pagination: {
lengthPerPage: 1000,
},
title: 'About',
},
],
Expand All @@ -59,7 +61,7 @@ module.exports = {
scopeLayout: 'Tag',
title: 'Content',
pagination: {
lengthPerPage: 5,
lengthPerPage: 1000,
},
},
],
Expand Down
23 changes: 13 additions & 10 deletions site/.vuepress/theme/components/ContentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
itemtype="https://schema.org/BlogPosting"
/>
<div
v-if="(this.$pagination.paginationIndex + 1) < this.$pagination.length"
v-if="(this.paginationIndex * this.paginator) < this.$pagination.pages.length"
class="load-more"
@click="more"
>
Expand All @@ -33,18 +33,23 @@ import WorkSummary from '@theme/components/WorkSummary.vue';
export default {
components: {PostSummary, WorkSummary},
props: {
sortOrder: {
type: Array,
default: () => ([]),
},
moreText: {
type: String,
default: 'Load more stuff',
},
paginator: {
type: Number,
default: 5,
},
sortOrder: {
type: Array,
default: () => ([]),
},
},
data() {
return {
paginationComponent: null,
paginationIndex: 1,
pages: [],
};
},
Expand All @@ -56,10 +61,8 @@ export default {
},
methods: {
more() {
this.$pagination.paginationIndex++;
let next = this.$pagination._paginationPages[this.$pagination.paginationIndex];
let nextPages = this.$pagination._matchedPages.slice(next.interval[0], next.interval[1] + 1);
for (let i = 0; i < nextPages.length; i++) this.pages.push(nextPages[i]);
this.paginationIndex++;
this.pages = this.sort(this.$pagination.pages);
},
sortByType(a, b) {
if (this.sortOrder.indexOf(a.id) > this.sortOrder.indexOf(b.id)) {
Expand All @@ -71,7 +74,7 @@ export default {
}
},
sort(data) {
return data.sort(this.sortByType);
return data.sort(this.sortByType).slice(0, this.paginator * this.paginationIndex);
},
},
Expand Down
5 changes: 1 addition & 4 deletions site/.vuepress/theme/layouts/Tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
<p>{{ byline }}</p>
</div>
</SectionHeader>
<ContentList
v-if="$pagination"
:sort-order="sortOrder"
/>
<ContentList v-if="$pagination" />
<Content v-else />
</div>
</template>
Expand Down
1 change: 0 additions & 1 deletion site/work/imsglobal-d8-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ tags:
- non-profit
- support
- training
- development
- migrations
---
::: point Summary.
Expand Down
1 change: 0 additions & 1 deletion site/work/isna-vuepress-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ tags:
- development
- vue
- non-profit
- development
- migrations
---
::: point Summary.
Expand Down
1 change: 0 additions & 1 deletion site/work/poets-blackbaud.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ tags:
- php
- development
- non-profit
- development
- crm
- blackbaud
---
Expand Down

0 comments on commit e2f4232

Please sign in to comment.