Skip to content

Commit

Permalink
fix: remove news article limit
Browse files Browse the repository at this point in the history
As there is a limited number of articles at the moment anyway, remove the
limit of 10 articles per page, as we don't yet have a system to create
multiple pages.
  • Loading branch information
romangg committed Jun 30, 2024
1 parent e905389 commit e4472f8
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions pages/news/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,9 @@ const getImagePath = (path: string, file: string) => {
return path + '/' + file
}
const props = defineProps({ pageNumber: { type: Number, required: true } })
const postsPerPage = 10
const allPostsCountResponse = await useAsyncData('news-items-all',
() => queryContent('/news').count())
const allPostsCount = allPostsCountResponse.data.value!
const totalPages = Math.ceil(allPostsCount / postsPerPage)
if (props.pageNumber < 1 || props.pageNumber > totalPages) {
showError({ statusCode: 404, statusMessage: 'Page Not Found', fatal: true })
}
const { data } = await useAsyncData(`news-items-list-${props.pageNumber}`, () =>
const { data } = await useAsyncData('news-items-list', () =>
queryContent('/news')
.sort({ date: -1 })
.skip((props.pageNumber - 1) * postsPerPage)
.limit(postsPerPage)
.find(),
)
</script>

0 comments on commit e4472f8

Please sign in to comment.