From 82c73804f96aefb8ad9b471876ff96413aad845f Mon Sep 17 00:00:00 2001 From: Alberto Fernandez Date: Sat, 25 Nov 2023 23:42:14 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20update=20page=20number=20error?= =?UTF-8?q?=20message=20and=20remove=20slugs=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alberto Fernandez --- .github/workflows/gh-pages.yml | 1 - src/Posts/application/ListPostsUseCase.ts | 4 +++- src/Posts/domain/PostsRepository.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1640f6f..32e9cec 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -44,7 +44,6 @@ jobs: run: | touch .env echo NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }} >> .env - echo NEXT_PUBLIC_COPYRIGHT=${{ secrets.NEXT_PUBLIC_COPYRIGHT }} >> .env echo NEXT_PUBLIC_DISQUS_SHORTNAME=${{ secrets.NEXT_PUBLIC_DISQUS_SHORTNAME }} >> .env echo NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID }} >> .env echo NEXT_PUBLIC_POSTS_PER_PAGE=${{ secrets.NEXT_PUBLIC_POSTS_PER_PAGE }} >> .env diff --git a/src/Posts/application/ListPostsUseCase.ts b/src/Posts/application/ListPostsUseCase.ts index a247b40..58b6d37 100644 --- a/src/Posts/application/ListPostsUseCase.ts +++ b/src/Posts/application/ListPostsUseCase.ts @@ -27,7 +27,9 @@ export class ListPostsUseCase implements UseCase> { const totalPages: number = await this.postsRepository.getTotalPages(locale); if (page > totalPages || page < MINIMUM_PAGE) { - throw new Error(`Invalid page number ${page}`); + throw new Error( + `Invalid page number: ${page} (totalPages: ${totalPages})`, + ); } const postPaths: string[] = diff --git a/src/Posts/domain/PostsRepository.ts b/src/Posts/domain/PostsRepository.ts index aaf65ff..300fe47 100644 --- a/src/Posts/domain/PostsRepository.ts +++ b/src/Posts/domain/PostsRepository.ts @@ -47,7 +47,7 @@ export class PostsRepository { .replace(/\w*\//, "") .replace(/(?:\/index)?\.md$/, ""); - console.log(`${postPath.replace(postsDirectoryPath, "")} -> ${slug}`); + // console.log(`${postPath.replace(postsDirectoryPath, "")} -> ${slug}`); return slug; }