Skip to content

Commit 1a8e3fc

Browse files
committed
feat(ghost,hashnode): flags to debug and skip builds
1 parent d07d599 commit 1a8e3fc

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

sample.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ POSTS_PER_PAGE=25
9191
SITE_DOMAIN=localhost:8080
9292
LOCALE_FOR_UI=italian
9393
LOCALE_FOR_GHOST=italian
94+
95+
# HASHNODE_DEBUG_MODE_FIRST_PAGE_ONLY=true
96+
# DO_NOT_FETCH_FROM_GHOST=true

utils/ghost/fetch-from-ghost.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ const fetchFromGhost = async endpoint => {
1111
limit: 200
1212
};
1313

14+
if (process.env.DO_NOT_FETCH_FROM_GHOST) {
15+
console.log(
16+
'DO_NOT_FETCH_FROM_GHOST is active. This is likely because Ghost is not available for this environment.'
17+
);
18+
return [];
19+
}
20+
1421
while (currPage && currPage <= lastPage) {
1522
const ghostRes = await ghostAPI[endpoint]
1623
.browse({

utils/hashnode/fetch-from-hashnode.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,15 @@ const fetchFromHashnode = async contentType => {
116116
);
117117

118118
after = pageInfo.endCursor;
119-
hasNextPage = pageInfo.hasNextPage;
119+
if (process.env.HASHNODE_DEBUG_MODE_FIRST_PAGE_ONLY) {
120+
console.log(
121+
'HASHNODE_DEBUG_MODE_FIRST_PAGE_ONLY is active. Fetching only the first page.'
122+
);
123+
}
124+
125+
hasNextPage =
126+
pageInfo.hasNextPage &&
127+
!process.env.HASHNODE_DEBUG_MODE_FIRST_PAGE_ONLY;
120128

121129
data.push(...resData);
122130

0 commit comments

Comments
 (0)